return 1
return cmp(self.index, other.index)
+ def pivot_vertex(self, v):
+ n = self.vertices.index(v)
+ return [(n+i)%len(self.vertices) for i in range(len(self.vertices))]
+
def pivot_vertices(self, *vt):
flags = [(v in vt) for v in self.vertices]
l = len(self.vertices)
self.loops = self.loops[:]
self.materials = self.materials[:]
- if self.use_uv=='NONE':
+ if self.use_uv=='NONE' or not self.uv_layers:
self.uv_layers = []
- elif self.uv_layers:
+ else:
self.uv_layers = [UvLayer(u) for u in self.uv_layers]
self.uv_layers = sorted([u for u in self.uv_layers if not u.hidden], key=(lambda u: (u.unit or 1000, u.name)))
v.tan = mathutils.Vector()
v.bino = mathutils.Vector()
for f in v.faces:
- vi = f.vertices.index(v)
- uv0 = layer_uvs[f.loop_indices[vi]]
- uv1 = layer_uvs[f.loop_indices[vi+1]]
- uv2 = layer_uvs[f.loop_indices[vi-1]]
+ vi = f.pivot_vertex(v)
+ uv0 = layer_uvs[f.loop_indices[vi[0]]]
+ uv1 = layer_uvs[f.loop_indices[vi[1]]]
+ uv2 = layer_uvs[f.loop_indices[vi[-1]]]
du1 = uv1[0]-uv0[0]
du2 = uv2[0]-uv0[0]
dv1 = uv1[1]-uv0[1]
dv2 = uv2[1]-uv0[1]
- edge1 = f.vertices[vi+1].co-f.vertices[vi].co
- edge2 = f.vertices[vi-1].co-f.vertices[vi].co
+ edge1 = f.vertices[vi[1]].co-f.vertices[vi[0]].co
+ edge2 = f.vertices[vi[-1]].co-f.vertices[vi[0]].co
div = (du1*dv2-du2*dv1)
if div:
mul = edge1.angle(edge2)/div
for o, m in objs:
bmesh = o.to_mesh(context.scene, True, "PREVIEW")
bmeshes.append(bmesh)
+
+ # Object.to_mesh does not copy custom properties
+ bmesh.winding_test = o.data.winding_test
+ bmesh.smoothing = o.data.smoothing
+ bmesh.use_lines = o.data.use_lines
+ bmesh.vertex_groups = o.data.vertex_groups
+ bmesh.max_groups_per_vertex = o.data.max_groups_per_vertex
+ bmesh.use_uv = o.data.use_uv
+ bmesh.tbn_vecs = o.data.tbn_vecs
+ bmesh.tbn_uvtex = o.data.tbn_uvtex
+
me = Mesh(bmesh)
me.transform(m)