Fix small issue with snap axis when using measure tool with different planes

This commit is contained in:
Bruno Perdigão
2024-10-10 18:21:30 -03:00
parent 014edcdadc
commit b4d652d12e
4 changed files with 9 additions and 7 deletions
@@ -124,20 +124,20 @@ class PolylineOperator:
def choose_axis(self, event, x=True, y=True, z=False):
if x:
if event.value == "PRESS" and event.type == "X":
if not event.shift and event.value == "PRESS" and event.type == "X":
self.tool_state.axis_method = "X" if self.tool_state.axis_method != event.type else None
self.tool_state.lock_axis = False if self.tool_state.lock_axis else True
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
tool.Blender.update_viewport()
if y:
if event.value == "PRESS" and event.type == "Y":
if not event.shift and event.value == "PRESS" and event.type == "Y":
self.tool_state.axis_method = "Y" if self.tool_state.axis_method != event.type else None
self.tool_state.lock_axis = False if self.tool_state.lock_axis else True
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
tool.Blender.update_viewport()
if z:
if event.value == "PRESS" and event.type == "Z":
if not event.shift and event.value == "PRESS" and event.type == "Z":
self.tool_state.axis_method = "Z" if self.tool_state.axis_method != event.type else None
self.tool_state.lock_axis = False if self.tool_state.lock_axis else True
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
@@ -336,7 +336,6 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
self.choose_axis(event)
self.handle_snap_selection(context, event)
if (
@@ -2394,7 +2394,7 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
BACKSPACE: Remove Point
X, Y, Z: Choose Axis
S-X, S-Y, S-Z: Choose Plane
SHIFT: Lock axis
L: Lock axis
"""
def modal(self, context, event):
@@ -2413,7 +2413,6 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
self.choose_axis(event, z=True)
self.choose_plane(event)
self.handle_snap_selection(context, event)
+5 -1
View File
@@ -185,7 +185,10 @@ class Snap(bonsai.core.tool.Snap):
# Get axis that are closer than the stick factor threshold
elegible_axis = []
for axis in snap_axis:
if not axis:
continue
rot_mat = Matrix.Rotation(math.radians(360 - axis), 3, pivot_axis)
rot_intersection = rot_mat @ translated_intersection
proximity = rot_intersection.y
@@ -200,7 +203,8 @@ class Snap(bonsai.core.tool.Snap):
# Get the elegible axis with the lowest proximity
if elegible_axis:
proximity, axis = sorted(elegible_axis)[0]
else:
pass
# If lock axis is on it will use the snap angle so there is no need to search for elegible axis
if elegible_axis or tool_state.lock_axis: