Skip to content

Commit

Permalink
#391 fix undo for ToCollider and SELECTION on
Browse files Browse the repository at this point in the history
  • Loading branch information
Weisl committed Jun 4, 2023
1 parent ae60393 commit aa95d5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions collider_conversion/conversion_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ def execute(self, context):

new_collider = obj.copy()
new_collider.data = obj.data.copy()
bpy.context.collection.objects.link(new_collider)

user_collections = obj.users_collection

# New collider to scene
bpy.context.collection.objects.link(new_collider)

# store initial state for operation cancel
self.original_obj_data.append(self.store_initial_obj_state(obj, user_collections))


for collection in obj.users_collection:
collection.objects.unlink(obj)

Expand Down
6 changes: 5 additions & 1 deletion collider_shapes/add_bounding_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,15 +951,19 @@ def get_time_elapsed(self):
def cancel_cleanup(self, context):
if self.is_mesh_to_collider:
if self.new_colliders_list:
for collider_obj, data in zip(self.new_colliders_list, self.original_obj_data):
for collider_obj in self.new_colliders_list:
# Remove previously created collisions
if collider_obj:
objs = bpy.data.objects
objs.remove(collider_obj, do_unlink=True)


for data in self.original_obj_data:
# Assign unlinked data to user groups
original_obj = data['obj']
original_user_groups = data['users_collection']

bpy.context.collection.objects.link(original_obj)
for col in original_user_groups:
self.add_to_collections(original_obj, col)

Expand Down

0 comments on commit aa95d5b

Please sign in to comment.