This commit is contained in:
Andrej730
2025-02-14 17:49:43 +05:00
parent 3832077d0f
commit 1014487d82
2 changed files with 15 additions and 15 deletions
+3 -3
View File
@@ -299,7 +299,9 @@ class Raycast(bonsai.core.tool.Raycast):
if tool.Cad.are_vectors_equal(e1["point"], e2["point"], tolerance=0.1):
edge_intersection = tool.Cad.intersect_edges_v2(e1["edge_verts"], e2["edge_verts"])
if edge_intersection[1]:
mouse_intersection, _ = mathutils.geometry.intersect_point_line(edge_intersection[1], ray_target, loc)
mouse_intersection, _ = mathutils.geometry.intersect_point_line(
edge_intersection[1], ray_target, loc
)
distance = (edge_intersection[1] - mouse_intersection).length
if distance < 0.2:
snap_point = {
@@ -309,5 +311,3 @@ class Raycast(bonsai.core.tool.Raycast):
"distance": distance,
}
return snap_point
+12 -12
View File
@@ -245,7 +245,7 @@ class Snap(bonsai.core.tool.Snap):
valid_intersections = []
for i in intersections:
if i is not None:
distance = (i-last_point).length
distance = (i - last_point).length
if not math.isclose(distance, 0.0, abs_tol=1e-4):
valid_intersections.append(i)
@@ -405,8 +405,8 @@ class Snap(bonsai.core.tool.Snap):
snap_point = {
"type": "Vertex",
"point": obj.location,
"distance": 10, # High value so it has low priority
"object": obj,
"distance": 10, # High value so it has low priority
"object": obj,
"group": "Edge-Vertex",
}
detected_snaps.append(snap_point)
@@ -423,10 +423,12 @@ class Snap(bonsai.core.tool.Snap):
results.append(cast_rays_and_get_best_object(objs_to_raycast, mouse_pos))
for result in results:
snap_obj = result[0]
hit = result[1]
hit = result[1]
face_index = result[2]
if hit is not None:
snap_points = tool.Raycast.ray_cast_by_proximity(context, event, snap_obj, snap_obj.data.polygons[face_index])
snap_points = tool.Raycast.ray_cast_by_proximity(
context, event, snap_obj, snap_obj.data.polygons[face_index]
)
if snap_points:
for point in snap_points:
point["group"] = "Object"
@@ -487,7 +489,7 @@ class Snap(bonsai.core.tool.Snap):
"point": rot_intersection,
"object": None,
"group": "Axis",
"type": "Axis",
"type": "Axis",
"axis_start": axis_start,
"axis_end": axis_end,
"distance": 10, # High value so it has low priority
@@ -496,9 +498,9 @@ class Snap(bonsai.core.tool.Snap):
snap_point = {
"point": intersection,
"object": None,
"group": "Plane",
"type": "Plane",
"object": None,
"group": "Plane",
"type": "Plane",
"distance": 10, # High value so it has low priority
}
detected_snaps.append(snap_point)
@@ -565,9 +567,7 @@ class Snap(bonsai.core.tool.Snap):
cls.update_snapping_point(point["point"], point["type"])
return snaps_by_type
cls.update_snapping_point(
snaps_by_type[0]["point"], snaps_by_type[0]["type"], snaps_by_type[0]["object"]
)
cls.update_snapping_point(snaps_by_type[0]["point"], snaps_by_type[0]["type"], snaps_by_type[0]["object"])
return snaps_by_type
@classmethod