diff --git a/op_island_align_edge.py b/op_island_align_edge.py index 13eeadc..b15eee7 100644 --- a/op_island_align_edge.py +++ b/op_island_align_edge.py @@ -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)