]> git.tdb.fi Git - libs/gl.git/commitdiff
Deep copy vertex groups when copying vertices in the exporter
authorMikko Rasa <tdb@tdb.fi>
Tue, 30 Jul 2024 15:30:19 +0000 (18:30 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 30 Jul 2024 15:30:19 +0000 (18:30 +0300)
If multiple vertices reference the same group data after splitting
by normals, group mapping gets applied multiple times, resulting in
incorrect group indices.

blender/io_mspgl/mesh.py

index c0d9c11b872ee6e079e52dbb7d97648ec88c81fa..0856ef2a09b7f3afbafa83b31671ad0891fdc3f2 100644 (file)
@@ -47,9 +47,11 @@ class Vertex:
                if vertex.__class__==Vertex:
                        self.uvs = vertex.uvs[:]
                        self.tan = vertex.tan
+                       self.groups = [VertexGroup(g) for g in vertex.groups]
                else:
                        self.uvs = []
                        self.tan = None
+                       self.groups = []
                self.index = vertex.index
                self.co = mathutils.Vector(vertex.co)
                self.normal = mathutils.Vector(vertex.normal)
@@ -57,7 +59,6 @@ class Vertex:
                self.flag = False
                self.edges = []
                self.faces = []
-               self.groups = vertex.groups[:]
 
        def __cmp__(self, other):
                if other is None:
@@ -178,7 +179,7 @@ class Mesh:
                self.vertices = [Vertex(v) for v in mesh.vertices]
                if self.vertex_groups:
                        for v in self.vertices:
-                               v.groups = [VertexGroup(g) for g in v.groups]
+                               v.groups = [VertexGroup(g) for g in mesh.vertices[v.index].groups]
 
                self.faces = [Face(f) for f in mesh.polygons]
                self.edges = [Edge(e) for e in mesh.edges]