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]
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 = []
# 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 = []
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: