Also add an additional safeguard against an infinite loop
island.append(face)
for n in f.get_neighbors():
- n.flag = True
- queue.append(n)
+ if not n.flag:
+ n.flag = True
+ queue.append(n)
# Unflag the island for the next phase
for f in island:
if f.flag:
continue
- score = sum(n.flag for n in f.get_neighbors())
+ score = sum(not n.flag for n in f.get_neighbors())
if score>0 and score<best:
face = f
best = score
strip = mesh.create_strip(face, self.max_strip_len)
if strip:
island_strips.append(strip)
+ else:
+ face.flag = True
else:
# Couldn't find a candidate face for starting a strip, so we're
# done with this island
raise KeyError("No edge %s"%(key,))
def get_neighbors(self):
- neighbors = [e.other_face(f) for e in self.edges]
+ neighbors = [e.other_face(self) for e in self.edges]
return list(filter(bool, neighbors))