diff options
Diffstat (limited to 'release/scripts/startup/bl_operators/uvcalc_follow_active.py')
-rw-r--r-- | release/scripts/startup/bl_operators/uvcalc_follow_active.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index 748255671dd..99ae5a3e436 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -30,6 +30,7 @@ def extend(obj, operator, EXTEND_MODE): me = obj.data me_verts = me.vertices + # script will fail without UVs if not me.uv_textures: me.uv_textures.new() @@ -52,17 +53,15 @@ def extend(obj, operator, EXTEND_MODE): ''' def face_edge_vs(vi): - # assume a quad - return [(vi[0], vi[1]), (vi[1], vi[2]), (vi[2], vi[3]), (vi[3], vi[0])] + vlen = len(vi) + return [(vi[i], vi[(i + 1) % vlen]) for i in range(vlen)] vidx_source = face_source.vertices vidx_target = face_target.vertices - faceUVsource = me.uv_textures.active.data[face_source.index] - uvs_source = [faceUVsource.uv1, faceUVsource.uv2, faceUVsource.uv3, faceUVsource.uv4] - - faceUVtarget = me.uv_textures.active.data[face_target.index] - uvs_target = [faceUVtarget.uv1, faceUVtarget.uv2, faceUVtarget.uv3, faceUVtarget.uv4] + uv_layer = me.uv_loop_layers.active.data + uvs_source = [uv_layer[i].uv for i in face_source.loop_indices] + uvs_target = [uv_layer[i].uv for i in face_target.loop_indices] # vertex index is the key, uv is the value @@ -135,15 +134,12 @@ def extend(obj, operator, EXTEND_MODE): uvs_vhash_target[edgepair_outer_target[iB]][:] = uvs_vhash_source[edgepair_inner_source[0]] + (uvs_vhash_source[edgepair_inner_source[0]] - uvs_vhash_source[edgepair_outer_source[1]]) uvs_vhash_target[edgepair_outer_target[iA]][:] = uvs_vhash_source[edgepair_inner_source[1]] + (uvs_vhash_source[edgepair_inner_source[1]] - uvs_vhash_source[edgepair_outer_source[0]]) - if not me.uv_textures: - me.uv_textures.new() - - face_act = me.faces.active + face_act = me.polygons.active if face_act == -1: operator.report({'ERROR'}, "No active face") return - face_sel = [f for f in me.faces if len(f.vertices) == 4 and f.select] + face_sel = [f for f in me.polygons if len(f.vertices) == 4 and f.select] face_act_local_index = -1 for i, f in enumerate(face_sel): @@ -172,7 +168,7 @@ def extend(obj, operator, EXTEND_MODE): edge_faces[edkey] = [i] if EXTEND_MODE == 'LENGTH': - edge_loops = mesh_utils.edge_loops_from_faces(me, face_sel, [ed.key for ed in me.edges if ed.use_seam]) + edge_loops = mesh_utils.edge_loops_from_tessfaces(me, face_sel, [ed.key for ed in me.edges if ed.use_seam]) me_verts = me.vertices for loop in edge_loops: looplen = [0.0] |