Skip to content

Commit

Permalink
Revert "fix(loader): Preserves collection hierarchies when importing …
Browse files Browse the repository at this point in the history
…them from blend file"

This reverts commit 94b35bf.
  • Loading branch information
cornerfarmer committed Sep 27, 2024
1 parent 94b35bf commit 8ee2265
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions blenderproc/python/loader/BlendLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ def load_blend(path: str, obj_types: Optional[Union[List[str], str]] = None, nam
for obj in getattr(data_to, data_block):
# Check that the object type is desired
if obj.type.lower() in obj_types:
# If object does not yet belong to a imported collection
if len(obj.users_collection) == 0:
# Link objects to the scene collection
bpy.context.collection.objects.link(obj)
# Link objects to the scene
bpy.context.collection.objects.link(obj)
loaded_objects.append(convert_to_entity_subclass(obj))

# If a camera was imported
Expand All @@ -91,17 +89,6 @@ def load_blend(path: str, obj_types: Optional[Union[List[str], str]] = None, nam
# Remove object again if its type is not desired
bpy.data.objects.remove(obj, do_unlink=True)
print("Selected " + str(len(loaded_objects)) + " of the loaded objects by type")
elif data_block == "collections":
# Build up mapping of possible parent-child collection relationships
collection_parents = {}
for collection in getattr(data_to, data_block):
for child in collection.children:
collection_parents[child.name] = collection

# Add all collections to scene collection which do not yet belong to any other collection
for collection in getattr(data_to, data_block):
if collection.name not in collection_parents:
bpy.context.collection.children.link(collection)
else:
loaded_objects.extend(getattr(data_to, data_block))

Expand Down

0 comments on commit 8ee2265

Please sign in to comment.