diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2019-03-13 01:55:33 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2019-03-15 22:09:32 +0300 |
commit | 713010bd7795c539c1c18afc3df9f25ab8ba6c12 (patch) | |
tree | 00a02d1383b0e01fb6f81e7242ed3285dfe215f4 /source/blender/blenkernel/intern/collection.c | |
parent | fcffbe1d1b31ed518b7a710c09d5fda389d8182e (diff) |
Fix T62313 - No way to remove object from master collection in 3d view
This introduces a new iterator, FOREACH_COLLECTION, that unlike the
FOREACH_SCENE_COLLECTION it iterates over all the Blender file
collections, including the scene master collection, as well the database
ones (bmain).
Reviewers: brecht
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 25 |
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; } |