mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
See #7046. Improve snapping inaccuracies in orthographic view
This commit is contained in:
@@ -216,7 +216,12 @@ class Raycast(bonsai.core.tool.Raycast):
|
||||
# Makes the snapping point more or less sticky than others
|
||||
# It changes the distance and affects how the snapping point are sorted
|
||||
# We multiply by the increment snap which is based on the viewport zoom
|
||||
snap_threshold = rv3d.view_distance / 100
|
||||
if rv3d.view_perspective == "PERSP":
|
||||
snap_threshold = rv3d.view_distance / 100
|
||||
if rv3d.view_perspective == "ORTHO" or (
|
||||
rv3d.view_perspective == "CAMERA" and context.scene.camera.data.type == "ORTHO"
|
||||
):
|
||||
snap_threshold = rv3d.window_matrix.to_scale()[1] * -1 / 100
|
||||
|
||||
try:
|
||||
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
||||
@@ -309,7 +314,12 @@ class Raycast(bonsai.core.tool.Raycast):
|
||||
rv3d = context.region_data
|
||||
mouse_pos = event.mouse_region_x, event.mouse_region_y
|
||||
ray_origin, ray_target, ray_direction = cls.get_viewport_ray_data(context, event)
|
||||
snap_threshold = rv3d.view_distance / 100
|
||||
if rv3d.view_perspective == "PERSP":
|
||||
snap_threshold = rv3d.view_distance / 100
|
||||
if rv3d.view_perspective == "ORTHO" or (
|
||||
rv3d.view_perspective == "CAMERA" and context.scene.camera.data.type == "ORTHO"
|
||||
):
|
||||
snap_threshold = rv3d.window_matrix.to_scale()[1] * -1 / 100
|
||||
|
||||
try:
|
||||
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
||||
@@ -387,7 +397,13 @@ class Raycast(bonsai.core.tool.Raycast):
|
||||
rv3d = context.region_data
|
||||
mouse_pos = event.mouse_region_x, event.mouse_region_y
|
||||
ray_origin, ray_target, ray_direction = cls.get_viewport_ray_data(context, event)
|
||||
snap_threshold = rv3d.view_distance / 100
|
||||
if rv3d.view_perspective == "PERSP":
|
||||
snap_threshold = rv3d.view_distance / 100
|
||||
if rv3d.view_perspective == "ORTHO" or (
|
||||
rv3d.view_perspective == "CAMERA" and context.scene.camera.data.type == "ORTHO"
|
||||
):
|
||||
snap_threshold = rv3d.window_matrix.to_scale()[1] * -1 / 100
|
||||
|
||||
|
||||
try:
|
||||
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
||||
|
||||
@@ -517,7 +517,13 @@ class Snap(bonsai.core.tool.Snap):
|
||||
|
||||
def sort_points_by_weighted_distance(snapping_points):
|
||||
for snap in snapping_points:
|
||||
zoom_factor = bpy.context.region_data.view_distance
|
||||
rv3d = bpy.context.region_data
|
||||
if rv3d.view_perspective == "PERSP":
|
||||
zoom_factor = rv3d.view_distance
|
||||
if rv3d.view_perspective == "ORTHO" or (
|
||||
rv3d.view_perspective == "CAMERA" and context.scene.camera.data.type == "ORTHO"
|
||||
):
|
||||
zoom_factor = rv3d.window_matrix.to_scale()[1] * -1
|
||||
if snap["type"] == "Vertex":
|
||||
snap["distance"] *= zoom_factor / 10
|
||||
if snap["type"] == "Edge Center":
|
||||
|
||||
Reference in New Issue
Block a user