From: Mikko Rasa Date: Sat, 5 Mar 2022 08:55:47 +0000 (+0200) Subject: Fixes for exporting objects consisting only of lines X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=52dd0394da580cc18ad1463e1646d06ac12dac8a;p=libs%2Fgl.git Fixes for exporting objects consisting only of lines --- diff --git a/blender/io_mspgl/mesh.py b/blender/io_mspgl/mesh.py index fb568ec4..7a33778d 100644 --- a/blender/io_mspgl/mesh.py +++ b/blender/io_mspgl/mesh.py @@ -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: