mirror of
https://github.com/drewcassidy/TexTools-Blender
synced 2024-09-01 14:54:44 +00:00
Fix Align Island by Edge giving wrong result
This commit is contained in:
parent
b227c34d70
commit
bcb546cafc
@ -126,17 +126,15 @@ def align_island(uv_vert0, uv_vert1, faces):
|
||||
loop[uv_layers].select = True
|
||||
|
||||
diff = uv_vert1 - uv_vert0
|
||||
angle = math.atan2(diff.y, diff.x)%(math.pi/2)
|
||||
current_angle = math.atan2(diff.y, diff.x)
|
||||
angle_to_rotate = round(current_angle / (math.pi/2)) * (math.pi/2) - current_angle
|
||||
|
||||
bpy.ops.uv.select_linked()
|
||||
|
||||
bpy.context.tool_settings.transform_pivot_point = 'CURSOR'
|
||||
bpy.ops.uv.cursor_set(location=uv_vert0 + diff/2)
|
||||
|
||||
if angle >= (math.pi/4):
|
||||
angle = angle - (math.pi/2)
|
||||
|
||||
bpy.ops.transform.rotate(value=angle, orient_axis='Z', constraint_axis=(False, False, False), orient_type='GLOBAL', mirror=False, use_proportional_edit=False)
|
||||
bpy.ops.transform.rotate(value=angle_to_rotate, orient_axis='Z', constraint_axis=(False, False, False), orient_type='GLOBAL', mirror=False, use_proportional_edit=False)
|
||||
|
||||
|
||||
bpy.utils.register_class(op)
|
||||
|
Loading…
Reference in New Issue
Block a user