public List <List <LinkedShape> > FormGroupsWithNeighbors(float propagate, Vector3 propagationDirection, int maxGroupSize, Vector3 originPoint) { List <LinkedShape> picked = new List <LinkedShape>(); List <LinkedShape> potentials = new List <LinkedShape>(); propagationDirection.Normalize(); //propagate *= 0.6f; this.cost = 0; potentials.Add(this); bool hasPicked = true; while (hasPicked) { hasPicked = false; LinkedShape recorder = null; float record = propagate; //Trouve le potentiel noeud le moins cher. Les noeuds avec un coup plus grand que 'propagate' ne seront jamais choisient foreach (LinkedShape item in potentials) { if (item.cost <= record) { record = item.cost; recorder = item; } } //Ajoue d'un nouveau noeud if (recorder != null) { potentials.Remove(recorder); recorder.AddToPickedList(picked, potentials, propagationDirection, originPoint); hasPicked = true; } } List <List <LinkedShape> > groupList = new List <List <LinkedShape> >(); foreach (LinkedShape item in picked) { groupList.Add(new List <LinkedShape>(1) { item }); } return(groupList); }