X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mesh_mspgl%2Fexport_mspgl.py;fp=blender%2Fio_mesh_mspgl%2Fexport_mspgl.py;h=124114e5fe60cb1111cf0385428bb149c749cd26;hb=ea6445c234d1db93e7c62cce228e94b2b652c1c5;hp=0e96c4249631ebc17844f1e3267beab1469c49f7;hpb=bd479bfbe3aa6096e9a27b4b766d56b231b387c4;p=libs%2Fgl.git diff --git a/blender/io_mesh_mspgl/export_mspgl.py b/blender/io_mesh_mspgl/export_mspgl.py index 0e96c424..124114e5 100644 --- a/blender/io_mesh_mspgl/export_mspgl.py +++ b/blender/io_mesh_mspgl/export_mspgl.py @@ -94,6 +94,7 @@ class Exporter: island_strips = [] while 1: if not island: + # No current island; find any unused face to start from queue = [] for f in mesh.faces: if not f.flag: @@ -104,38 +105,46 @@ class Exporter: if not queue: break + # Find all faces connected to the first one while queue: - f = queue[0] - del queue[0] - island.append(f) + face = queue.pop(0) + island.append(face) - for e in f.edges: - other = e.other_face(f) - if other and not other.flag: - other.flag = True - queue.append(other) + for n in f.get_neighbors(): + n.flag = True + queue.append(n) + # Unflag the island for the next phase for f in island: f.flag = False + # Find an unused face with as few unused neighbors as possible, but + # at least one. This heuristic gives a preference to faces in corners + # or along borders of a non-closed island. best = 5 face = None for f in island: if f.flag: continue - score = 0 - for e in f.edges: - other = e.other_face(f) - if other and not other.flag: - score += 1 + + score = sum(n.flag for n in f.get_neighbors()) if score>0 and score