From: Mikko Rasa Date: Sat, 4 May 2019 20:16:58 +0000 (+0300) Subject: Simplify the vertex splitting algorithm X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3b14c996f1249a3e8660a699bb9e16815344bdf2;p=libs%2Fgl.git Simplify the vertex splitting algorithm It now uses single-pass loops instead of temporary lists where feasible. --- diff --git a/blender/io_mspgl/mesh.py b/blender/io_mspgl/mesh.py index a05d4537..077acc2e 100644 --- a/blender/io_mspgl/mesh.py +++ b/blender/io_mspgl/mesh.py @@ -378,61 +378,54 @@ class Mesh: v.uvs = [(0.0, 0.0)]*len(self.uv_layers) def split_vertices(self, find_group_func, progress, *args): - groups = [] - for i in range(len(self.vertices)): + vertex_count = len(self.vertices) + for i in range(vertex_count): v = self.vertices[i] for f in v.faces: f.flag = False - vg = [] + groups = [] for f in v.faces: if not f.flag: - vg.append(find_group_func(v, f, *args)) + groups.append(find_group_func(v, f, *args)) - groups.append(vg) + for g in groups[1:]: + nv = Vertex(v) + nv.index = len(self.vertices) + self.vertices.append(nv) - progress.set_progress(i*0.5/len(self.vertices)) - - for i in range(len(self.vertices)): - for g in groups[i][1:]: - v = Vertex(self.vertices[i]) - v.index = len(self.vertices) - self.vertices.append(v) - - v_edges = [] - for e in self.vertices[i].edges: + for e in v.edges: e_faces_in_g = [f for f in e.faces if f in g] - if e_faces_in_g: - boundary = len(e_faces_in_g)