Skip to content

Commit

Permalink
fix: fix maximum recursion depth exceeded error when smart duplicatin…
Browse files Browse the repository at this point in the history
…g an object with cylic utils
  • Loading branch information
tristan-hm committed Jul 23, 2024
1 parent 0fe30a7 commit 190c79a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,25 @@ def is_planar(bm, tolerance=0.0001):
return True


def get_all_util_objects(objs):
utils = set(())
def get_all_util_objects(base_objs, utils=None):
if utils is None:
utils = set(())

for obj in objs:
new_utils = set(())
for obj in base_objs:
if not obj.type in {'MESH', 'CURVE'}:
continue

utils.update([mod.object for mod in obj.modifiers if mod.type == 'BOOLEAN' and mod.object])
utils.update([mod.offset_object for mod in obj.modifiers if mod.type == 'ARRAY' and mod.use_object_offset and mod.offset_object])
utils.update([mod.mirror_object for mod in obj.modifiers if mod.type == 'MIRROR' and mod.mirror_object])
new_utils.update([mod.object for mod in obj.modifiers if mod.type == 'BOOLEAN' and mod.object])
new_utils.update([mod.offset_object for mod in obj.modifiers if mod.type == 'ARRAY' and mod.use_object_offset and mod.offset_object])
new_utils.update([mod.mirror_object for mod in obj.modifiers if mod.type == 'MIRROR' and mod.mirror_object])

if len(utils) > 0:
diff_utils = new_utils.difference(utils)
utils.update(new_utils)

if len(diff_utils) > 0:
# Recursively get all composited utils.
utils.update(get_all_util_objects(list(utils)))
utils.update(get_all_util_objects(diff_utils, utils))

return list(utils)

Expand Down

0 comments on commit 190c79a

Please sign in to comment.