From ae4f1253711edd2e5990cf82e0c4c6e49e53e5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Perdig=C3=A3o?= Date: Wed, 19 Feb 2025 16:13:35 -0300 Subject: [PATCH] Fix auto-angle snapping in polyline tools. When locked to a plane, the mouse will be loosely locked to and angle that is divided by 15 degrees. This was not working properly for "XZ" and "YZ" planes. --- src/bonsai/bonsai/tool/snap.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bonsai/bonsai/tool/snap.py b/src/bonsai/bonsai/tool/snap.py index 10636f031a..249d856579 100644 --- a/src/bonsai/bonsai/tool/snap.py +++ b/src/bonsai/bonsai/tool/snap.py @@ -193,7 +193,7 @@ class Snap(bonsai.core.tool.Snap): rot_intersection = rot_mat @ translated_intersection proximity = rot_intersection.y if tool_state.plane_method == "XZ": - proximity = rot_intersection.z + proximity = rot_intersection.x is_on_rot_axis = abs(proximity) <= stick_factor if is_on_rot_axis: @@ -208,10 +208,14 @@ class Snap(bonsai.core.tool.Snap): # If lock axis is on it will use the snap angle so there is no need to search for eligible axis if elegible_axis or tool_state.lock_axis: # Adapt axis to make snap angle work with other plane method - if tool_state.plane_method == "XZ": - axis = -axis - if tool_state.plane_method == "YZ": - axis = 90 - (axis * -1) + if elegible_axis: + if tool_state.plane_method == "XZ": + axis = 90 - (axis * -1) + else: + if tool_state.plane_method == "XZ": + axis = -axis + if tool_state.plane_method == "YZ": + axis = 90 - (axis * -1) rot_mat = Matrix.Rotation(math.radians(360 - axis), 3, pivot_axis) rot_mat = tool.Polyline.use_transform_orientations(rot_mat) rot_intersection = rot_mat @ translated_intersection