]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/mesh.py
Auto smooth angle is stored in radians, not degrees
[libs/gl.git] / blender / io_mspgl / mesh.py
index aa8df8d254665d4240b50a34934753515a56e96c..a41cbc1311c8a9c077ff78980ecfb1e48a37b4e3 100644 (file)
@@ -43,11 +43,13 @@ class Vertex:
                        self.uvs = mv.uvs[:]
                        self.tan = mv.tan
                        self.bino = mv.bino
+                       self.group_weight_scale = mv.group_weight_scale
                else:
                        self._mvert = mv
                        self.uvs = []
                        self.tan = None
                        self.bino = None
+                       self.group_weight_scale = 1
                self.flag = False
                self.faces = []
 
@@ -156,7 +158,7 @@ class Mesh:
                self.lines = [Line(e) for e in self.edges.values() if not e.faces]
 
                if self.use_auto_smooth:
-                       smooth_limit = math.cos(self.auto_smooth_angle*math.pi/180)
+                       smooth_limit = math.cos(self.auto_smooth_angle)
                else:
                        smooth_limit = -1
 
@@ -361,6 +363,12 @@ class Mesh:
                        if v.bino.length:
                                v.bino.normalize()
 
+       def sort_vertex_groups(self, max_groups):
+               for v in self.vertices:
+                       if v.groups:
+                               v.groups = sorted(v.groups, key=(lambda g: g.weight), reverse=True)
+                               v.group_weight_scale = 1.0/sum(g.weight for g in v.groups[:max_groups])
+
        def create_strip(self, face, max_len):
                # Find an edge with another unused face next to it
                edge = None