Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index b00448cc8c3..29d9d105d6b 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -558,17 +558,32 @@ bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
return (BLI_findptr(&objects, ob, offsetof(Base, object)));
}
-Collection *BKE_collection_object_find(Main *bmain, Collection *collection, Object *ob)
+static Collection *collection_next_find(Main *bmain, Scene *scene, Collection *collection)
{
- if (collection)
- collection = collection->id.next;
- else
+ if (scene && collection == BKE_collection_master(scene)) {
+ return bmain->collections.first;
+ }
+ else {
+ return collection->id.next;
+ }
+}
+
+Collection *BKE_collection_object_find(Main *bmain, Scene *scene, Collection *collection, Object *ob)
+{
+ if (collection) {
+ collection = collection_next_find(bmain, scene, collection);
+ }
+ else if (scene) {
+ collection = BKE_collection_master(scene);
+ }
+ else {
collection = bmain->collections.first;
+ }
while (collection) {
if (BKE_collection_has_object(collection, ob))
return collection;
- collection = collection->id.next;
+ collection = collection_next_find(bmain, scene, collection);
}
return NULL;
}