]> git.tdb.fi Git - libs/gl.git/commitdiff
Fixes for exporting objects consisting only of lines
authorMikko Rasa <tdb@tdb.fi>
Sat, 5 Mar 2022 08:55:47 +0000 (10:55 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 5 Mar 2022 17:42:34 +0000 (19:42 +0200)
blender/io_mspgl/mesh.py

index fb568ec416fb04739ef7b49c8b2bbd0a1f9f972e..7a33778dd68572e4b3c8cf60530693dde733b3c7 100644 (file)
@@ -181,7 +181,7 @@ class Mesh:
                if mesh.use_uv=='NONE' or not mesh.uv_layers:
                        self.uv_layers = []
                else:
-                       self.uv_layers = [UvLayer(u) for u in mesh.uv_layers]
+                       self.uv_layers = [UvLayer(u) for u in mesh.uv_layers if u.data]
 
                        # Assign texture unit numbers to UV layers that lack one
                        missing_unit = [u for u in self.uv_layers if u.unit is None]
@@ -193,7 +193,7 @@ class Mesh:
 
                        self.uv_layers = sorted(self.uv_layers, key=(lambda u: u.unit))
 
-                       if mesh.use_uv=='UNIT0':
+                       if mesh.use_uv=='UNIT0' and self.uv_layers:
                                self.uv_layers = [self.uv_layers[0]]
                                if self.uv_layers[0].unit!=0:
                                        self.uv_layers = []
@@ -708,7 +708,8 @@ class Mesh:
                # Keep track of the score and number of unused faces for each vertex
                vertex_info = [[0, len(v.faces)] for v in self.vertices]
                for vi in vertex_info:
-                       vi[0] = valence_boost_scale*(vi[1]**valence_boost_power)
+                       if vi[1]:
+                               vi[0] = valence_boost_scale*(vi[1]**valence_boost_power)
 
                face = None
                reordered_faces = []
@@ -783,6 +784,11 @@ class Mesh:
                                        v.index = len(reordered_vertices)
                                        reordered_vertices.append(v)
 
+               for v in self.vertices:
+                       if v.index<0:
+                               v.index = len(reordered_vertices)
+                               reordered_vertices.append(v)
+
                self.vertices = reordered_vertices
 
                for e in self.edges: