Skip to content

Commit

Permalink
feat: allow snapping to occur through objects occluding the target wh…
Browse files Browse the repository at this point in the history
…ile using snap_align
  • Loading branch information
tristan-hm committed May 11, 2022
1 parent 73ff168 commit 8301845
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions utils/snap_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ def invoke(self, context, event):
self.snap_point = None
self.snap_point_rotation_cache = None

bpy.ops.object.hide_view_set(unselected=True)

a, b = context.selected_objects
self.reference_obj = a if a.name != context.object.name else b
self.reference_obj_original_location = self.reference_obj.location.copy()
Expand Down Expand Up @@ -183,8 +181,16 @@ def recalculate_points(self, context, mouse_coords):
depsgraph = context.evaluated_depsgraph_get()

hit, location, normal, face_index, object, matrix = context.scene.ray_cast(depsgraph, ray_origin, ray_direction)
hidden_objects = []
while hit and object.name != context.object.name:
hidden_objects.append(object)
object.hide_set(True)
hit, location, normal, face_index, object, matrix = context.scene.ray_cast(depsgraph, location + 0.001 * ray_direction, ray_direction)

for obj in hidden_objects:
obj.hide_set(False)

if hit and object.name == context.object.name:
if hit:
self.hit_location = location

self.primary_points = []
Expand All @@ -211,7 +217,6 @@ def recalculate_points(self, context, mouse_coords):


def clean_up(self, context):
bpy.ops.object.hide_view_clear()
for mod in context.active_object.modifiers:
if mod.type == 'BOOLEAN' and mod.object == self.reference_obj:
mod.show_viewport = self.affected_boolean_modifiers[mod.name]
Expand Down

0 comments on commit 8301845

Please sign in to comment.