X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mesh_mspgl%2Fmesh.py;fp=blender%2Fio_mesh_mspgl%2Fmesh.py;h=d674dbdb24975c25c2ca9fafca7e61b3e4a5d2cb;hb=ea6445c234d1db93e7c62cce228e94b2b652c1c5;hp=8b3ad37052a62eba8d03237a5386a43cf8775e22;hpb=bd479bfbe3aa6096e9a27b4b766d56b231b387c4;p=libs%2Fgl.git diff --git a/blender/io_mesh_mspgl/mesh.py b/blender/io_mesh_mspgl/mesh.py index 8b3ad370..d674dbdb 100644 --- a/blender/io_mesh_mspgl/mesh.py +++ b/blender/io_mesh_mspgl/mesh.py @@ -90,6 +90,10 @@ class Face: return e raise KeyError("No edge %s"%(key,)) + def get_neighbors(self): + neighbors = [e.other_face(f) for e in self.edges] + return list(filter(bool, neighbors)) + class Line: def __init__(self, e): @@ -358,6 +362,7 @@ class Mesh: v.bino.normalize() def create_strip(self, face, max_len): + # Find an edge with another unused face next to it edge = None for e in face.edges: other = e.other_face(face) @@ -368,6 +373,8 @@ class Mesh: if not edge: return None + # Add initial vertices so that we'll complete the edge on the first + # iteration vertices = face.pivot_vertices(*edge.vertices) if len(vertices)==3: result = [vertices[-1], vertices[0]] @@ -375,10 +382,13 @@ class Mesh: result = [vertices[-2], vertices[-1]] while 1: + face.flag = True + vertices = face.pivot_vertices(*result[-2:]) k = len(result)%2 - face.flag = True + # Quads need special handling because the winding of every other + # triangle in the strip is reversed if len(vertices)==4 and not k: result.append(vertices[3]) result.append(vertices[2]) @@ -388,11 +398,10 @@ class Mesh: if len(result)>=max_len: break + # Hop over the last edge edge = face.get_edge(*result[-2:]) - - next = edge.other_face(face) - if not next or next.flag: + face = edge.other_face(face) + if not face or face.flag: break - face = next return result