Polyline tool - increment snap implementation.

This commit is contained in:
Bruno Perdigão
2024-10-07 22:04:42 -03:00
parent 0f4e4730e2
commit c5f27e908a
+20 -2
View File
@@ -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