diff options
Diffstat (limited to 'release/scripts/op/uvcalc_smart_project.py')
-rw-r--r-- | release/scripts/op/uvcalc_smart_project.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/release/scripts/op/uvcalc_smart_project.py b/release/scripts/op/uvcalc_smart_project.py index 13bf6244f4d..0589b7e861a 100644 --- a/release/scripts/op/uvcalc_smart_project.py +++ b/release/scripts/op/uvcalc_smart_project.py @@ -22,7 +22,7 @@ # <pep8 compliant> -from mathutils import Matrix, Vector, RotationMatrix +from mathutils import Matrix, Vector import time import geometry import bpy @@ -275,15 +275,15 @@ def testNewVecLs2DRotIsBetter(vecs, mat=-1, bestAreaSoFar = -1): # Takes a list of faces that make up a UV island and rotate # until they optimally fit inside a square. -ROTMAT_2D_POS_90D = RotationMatrix( radians(90.0), 2) -ROTMAT_2D_POS_45D = RotationMatrix( radians(45.0), 2) +ROTMAT_2D_POS_90D = Matrix.Rotation( radians(90.0), 2) +ROTMAT_2D_POS_45D = Matrix.Rotation( radians(45.0), 2) RotMatStepRotation = [] rot_angle = 22.5 #45.0/2 while rot_angle > 0.1: RotMatStepRotation.append([\ - RotationMatrix( radians(rot_angle), 2),\ - RotationMatrix( radians(-rot_angle), 2)]) + Matrix.Rotation( radians(rot_angle), 2),\ + Matrix.Rotation( radians(-rot_angle), 2)]) rot_angle = rot_angle/2.0 @@ -524,7 +524,7 @@ def mergeUvIslands(islandList): then move us 1 whole width accross, Its possible this is a bad idea since 2 skinny Angular faces could join without 1 whole move, but its a lot more optimal to speed this up - since we have alredy tested for it. + since we have already tested for it. It gives about 10% speedup with minimal errors. ''' @@ -604,7 +604,7 @@ def getUvIslands(faceGroups, me): # Get seams so we dont cross over seams edge_seams = {} # shoudl be a set for ed in me.edges: - if ed.seam: + if ed.use_seam: edge_seams[ed.key] = None # dummy var- use sets! # Done finding seams @@ -792,7 +792,7 @@ def VectoMat(vec): class thickface(object): __slost__= 'v', 'uv', 'no', 'area', 'edge_keys' def __init__(self, face, uvface, mesh_verts): - self.v = [mesh_verts[i] for i in face.verts] + self.v = [mesh_verts[i] for i in face.vertices] if len(self.v)==4: self.uv = uvface.uv1, uvface.uv2, uvface.uv3, uvface.uv4 else: @@ -821,7 +821,7 @@ def main(context, island_margin, projection_limit): #XXX ob = objects.active ob= objects[0] - if ob and ob.selected == 0 and ob.type == 'MESH': + if ob and (not ob.select) and ob.type == 'MESH': # Add to the list obList =[ob] del objects @@ -896,10 +896,10 @@ def main(context, island_margin, projection_limit): me.add_uv_texture() uv_layer = me.active_uv_texture.data - me_verts = list(me.verts) + me_verts = list(me.vertices) if USER_ONLY_SELECTED_FACES: - meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces) if f.selected] + meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces) if f.select] #else: # meshFaces = map(thickface, me.faces) @@ -1027,7 +1027,7 @@ def main(context, island_margin, projection_limit): bestAng = fvec.dot(projectVecs[0]) bestAngIdx = 0 - # Cycle through the remaining, first alredy done + # Cycle through the remaining, first already done while i-1: i-=1 @@ -1124,7 +1124,8 @@ class SmartProject(bpy.types.Operator): description="Margin to reduce bleed from adjacent islands.", default=0.0, min=0.0, max=1.0) - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_object != None def execute(self, context): @@ -1138,12 +1139,10 @@ menu_func = (lambda self, context: self.layout.operator(SmartProject.bl_idname, def register(): - bpy.types.register(SmartProject) bpy.types.VIEW3D_MT_uv_map.append(menu_func) def unregister(): - bpy.types.unregister(SmartProject) bpy.types.VIEW3D_MT_uv_map.remove(menu_func) if __name__ == "__main__": |