mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Improve snapping for empty objects.
This commit is contained in:
@@ -154,6 +154,24 @@ class Raycast(bonsai.core.tool.Raycast):
|
||||
except:
|
||||
loc = Vector((0, 0, 0))
|
||||
|
||||
# For empty object we just get the object location and return
|
||||
if obj.type == "EMPTY":
|
||||
v = obj.location
|
||||
intersection = tool.Cad.point_on_edge(v, (ray_target, loc))
|
||||
intersection = tool.Cad.point_on_edge(v, (ray_target, loc))
|
||||
distance = (v - intersection).length
|
||||
if distance < snap_threshold:
|
||||
snap_point = {
|
||||
"object": obj,
|
||||
"type": "Vertex",
|
||||
"point": v.copy(),
|
||||
"distance": distance,
|
||||
}
|
||||
points.append(snap_point)
|
||||
print("empty", snap_point)
|
||||
return points
|
||||
|
||||
|
||||
if not custom_bmesh:
|
||||
bm = bmesh.new()
|
||||
if face is None: # Object without faces
|
||||
|
||||
@@ -403,13 +403,13 @@ class Snap(bonsai.core.tool.Snap):
|
||||
|
||||
# Edge-Vertex
|
||||
for obj in objs_to_raycast:
|
||||
if obj.type == "MESH":
|
||||
if len(obj.data.polygons) == 0:
|
||||
snap_points = tool.Raycast.ray_cast_by_proximity(context, event, obj)
|
||||
if snap_points:
|
||||
for point in snap_points:
|
||||
point["group"] = "Edge-Vertex"
|
||||
detected_snaps.append(point)
|
||||
if obj.type in {"MESH", "EMPTY"}:
|
||||
# if len(obj.data.polygons) == 0:
|
||||
snap_points = tool.Raycast.ray_cast_by_proximity(context, event, obj)
|
||||
if snap_points:
|
||||
for point in snap_points:
|
||||
point["group"] = "Edge-Vertex"
|
||||
detected_snaps.append(point)
|
||||
if obj.type == "CURVE":
|
||||
new_object = bpy.data.objects.new("new_object", obj.to_mesh().copy())
|
||||
snap_points = tool.Raycast.ray_cast_by_proximity(context, event, new_object)
|
||||
@@ -417,15 +417,6 @@ class Snap(bonsai.core.tool.Snap):
|
||||
for point in snap_points:
|
||||
point["group"] = "Edge-Vertex"
|
||||
detected_snaps.append(point)
|
||||
if obj.type == "EMPTY":
|
||||
snap_point = {
|
||||
"type": "Vertex",
|
||||
"point": obj.location,
|
||||
"distance": 10, # High value so it has low priority
|
||||
"object": obj,
|
||||
"group": "Edge-Vertex",
|
||||
}
|
||||
detected_snaps.append(snap_point)
|
||||
|
||||
# Obj
|
||||
if (space.shading.type == "SOLID" and space.shading.show_xray) or (
|
||||
|
||||
Reference in New Issue
Block a user