From 913b1fd29a8cb721c4cb001a10872e7c09e6bbfe Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 12 Mar 2019 14:57:59 +0100 Subject: BKE Collections: add helper to find the scene of a master collection. --- source/blender/blenkernel/BKE_collection.h | 1 + source/blender/blenkernel/intern/collection.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 0390078fc7f..a4b68a8cba2 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -66,6 +66,7 @@ struct Collection *BKE_collection_copy_master(struct Main *bmain, struct Collect struct Collection *BKE_collection_master(const struct Scene *scene); struct Collection *BKE_collection_master_add(void); +struct Scene *BKE_collection_master_scene_search(const struct Main *bmain, const struct Collection *master_collection); /* Collection Objects */ diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index a4d2ee55de1..b00448cc8c3 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -483,6 +483,19 @@ Collection *BKE_collection_master(const Scene *scene) return scene->master_collection; } +Scene *BKE_collection_master_scene_search(const Main *bmain, const Collection *master_collection) +{ + BLI_assert((master_collection->flag & COLLECTION_IS_MASTER) != 0); + + for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { + if (scene->master_collection == master_collection) { + return scene; + } + } + + return NULL; +} + /*********************** Cyclic Checks ************************/ static bool collection_object_cyclic_check_internal(Object *object, Collection *collection) -- cgit v1.2.3