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:
authorBastien Montagne <montagne29@wanadoo.fr>2019-02-09 15:18:22 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-02-09 15:24:31 +0300
commitbf4f01779d818be876fde59914597308544c4d3a (patch)
tree6370684a9d2607073412e46ceb7483bdf0bc2322 /source/blender/blenkernel/intern/object.c
parent1bf8551f00d908609287f01fc65c6800d7dbbdb0 (diff)
BKE_object: add util to count number of scenes using an object.
Issue is, ob->id.us is not relevant anymore here, since several collection might be referencing it inside of a same scene, that is still only one usage from user perspective... Note that for now we are just counting scenes instantiating an object, time will say wether we need more refined/complete check (as a reminder, most [all?] other Object usages are *not* refcounting ones).
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 64345a72740..c1af6037e05 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3514,6 +3514,18 @@ bool BKE_object_is_animated(Scene *scene, Object *ob)
return false;
}
+/** Return the number of scenes using (instantiating) that object in their collections. */
+int BKE_object_scenes_users_get(Main *bmain, Object *ob)
+{
+ int num_scenes = 0;
+ for (Scene *scene = bmain->scene.first; scene != NULL; scene = scene->id.next) {
+ if (BKE_collection_has_object_recursive(BKE_collection_master(scene), ob)) {
+ num_scenes++;
+ }
+ }
+ return num_scenes;
+}
+
MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, bool use_default)
{
MovieClip *clip = use_default ? scene->clip : NULL;