From c5f27e908a4fe1603c39c970dcedb571c8e2d05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Perdig=C3=A3o?= Date: Mon, 7 Oct 2024 22:04:42 -0300 Subject: [PATCH] Polyline tool - increment snap implementation. --- src/bonsai/bonsai/tool/snap.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/tool/snap.py b/src/bonsai/bonsai/tool/snap.py index 719941591f..cafc429c9d 100644 --- a/src/bonsai/bonsai/tool/snap.py +++ b/src/bonsai/bonsai/tool/snap.py @@ -88,7 +88,6 @@ class Snap(bonsai.core.tool.Snap): def clear_snapping_ref(cls): bpy.context.scene.BIMPolylineProperties.snap_mouse_ref.clear() - @classmethod def snap_on_axis(cls, intersection, tool_state, lock_angle=False): def create_axis_line_data(rot_mat, origin): @@ -360,9 +359,28 @@ class Snap(bonsai.core.tool.Snap): rot_intersection, tool_state.snap_angle, axis_start, axis_end = cls.snap_on_axis( intersection, tool_state, False ) - if rot_intersection: + + increment = None + if rv3d.view_perspective == "PERSP": + if rv3d.view_distance < 10: + increment = 0.1 + else: + increment = 1 + if rv3d.view_perspective == "ORTHO" or ( + rv3d.view_perspective == "CAMERA" and context.scene.camera.data.type == "ORTHO" + ): + window_scale = rv3d.window_matrix.to_scale() + if window_scale[0] < -0.1 and window_scale[1] < -0.1: + increment = 0.1 + else: + increment = 1 + + if rot_intersection and polyline_points: detected_snaps.append({"Axis": (rot_intersection, axis_start, axis_end)}) + if increment: + for i in range(len(intersection)): + intersection[i] = increment * round(intersection[i] / increment) detected_snaps.append({"Plane": intersection}) return detected_snaps