mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Snap - Improve how viewport zoom affects snapping.
This commit is contained in:
@@ -193,9 +193,7 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
# Makes the snapping point more or less sticky than others
|
# Makes the snapping point more or less sticky than others
|
||||||
# It changes the distance and affects how the snapping point are sorted
|
# 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
|
# We multiply by the increment snap which is based on the viewport zoom
|
||||||
snap_threshold = 10 * tool.Snap.get_increment_snap_value(bpy.context)
|
snap_threshold = rv3d.view_distance / 100
|
||||||
if face:
|
|
||||||
snap_threshold = tool.Snap.get_increment_snap_value(bpy.context)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
||||||
@@ -288,7 +286,7 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
rv3d = context.region_data
|
rv3d = context.region_data
|
||||||
mouse_pos = event.mouse_region_x, event.mouse_region_y
|
mouse_pos = event.mouse_region_x, event.mouse_region_y
|
||||||
ray_origin, ray_target, ray_direction = cls.get_viewport_ray_data(context, event)
|
ray_origin, ray_target, ray_direction = cls.get_viewport_ray_data(context, event)
|
||||||
snap_threshold = tool.Snap.get_increment_snap_value(bpy.context)
|
snap_threshold = rv3d.view_distance / 100
|
||||||
|
|
||||||
try:
|
try:
|
||||||
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
||||||
@@ -365,7 +363,7 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
rv3d = context.region_data
|
rv3d = context.region_data
|
||||||
mouse_pos = event.mouse_region_x, event.mouse_region_y
|
mouse_pos = event.mouse_region_x, event.mouse_region_y
|
||||||
ray_origin, ray_target, ray_direction = cls.get_viewport_ray_data(context, event)
|
ray_origin, ray_target, ray_direction = cls.get_viewport_ray_data(context, event)
|
||||||
snap_threshold = tool.Snap.get_increment_snap_value(bpy.context)
|
snap_threshold = rv3d.view_distance / 100
|
||||||
|
|
||||||
try:
|
try:
|
||||||
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
loc = view3d_utils.region_2d_to_location_3d(region, rv3d, mouse_pos, ray_direction)
|
||||||
|
|||||||
@@ -483,17 +483,17 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
|
|
||||||
def sort_points_by_weighted_distance(snapping_points):
|
def sort_points_by_weighted_distance(snapping_points):
|
||||||
for snap in snapping_points:
|
for snap in snapping_points:
|
||||||
weight_factor = 100 * cls.get_increment_snap_value(context)
|
zoom_factor = bpy.context.region_data.view_distance
|
||||||
if snap["type"] == "Vertex":
|
if snap["type"] == "Vertex":
|
||||||
snap["distance"] *= weight_factor / 12
|
snap["distance"] *= (zoom_factor / 10)
|
||||||
if snap["type"] == "Edge":
|
|
||||||
snap["distance"] *= weight_factor
|
|
||||||
if snap["type"] == "Edge Center":
|
if snap["type"] == "Edge Center":
|
||||||
snap["distance"] *= weight_factor / 5
|
snap["distance"] *= (zoom_factor / 8)
|
||||||
if snap["type"] == "Edge Intersection":
|
if snap["type"] == "Edge Intersection":
|
||||||
snap["distance"] *= weight_factor / 10
|
snap["distance"] *= (zoom_factor / 5)
|
||||||
|
if snap["type"] == "Edge":
|
||||||
|
snap["distance"] *= zoom_factor
|
||||||
if snap["type"] in ["Plane", "Axis", "Face"]:
|
if snap["type"] in ["Plane", "Axis", "Face"]:
|
||||||
snap["distance"] = weight_factor / 50
|
snap["distance"] *= zoom_factor
|
||||||
return sorted(snapping_points, key=lambda x: x["distance"])
|
return sorted(snapping_points, key=lambda x: x["distance"])
|
||||||
|
|
||||||
snaps_by_group = filter_snapping_points_by_group(detected_snaps)
|
snaps_by_group = filter_snapping_points_by_group(detected_snaps)
|
||||||
|
|||||||
Reference in New Issue
Block a user