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:
authorDalai Felinto <dfelinto@gmail.com>2018-03-29 22:23:43 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-03-30 02:03:47 +0300
commit1251043636d37f36bc2e7c845e6542898476707d (patch)
tree77925fd003f592360c1e296b35cb8bb3dc585b51 /source/blender/blenkernel/intern/collection.c
parentb882257fbd38f56b512a79027f91f8ff282f31b5 (diff)
Collections: API to check if object is in collection
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 880d28970c0..aed0ffb9fc3 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -390,7 +390,7 @@ static void collection_object_add(const ID *owner_id, SceneCollection *sc, Objec
*/
bool BKE_collection_object_add(const ID *owner_id, SceneCollection *sc, Object *ob)
{
- if (BLI_findptr(&sc->objects, ob, offsetof(LinkData, data))) {
+ if (BKE_collection_object_exists(sc, ob)) {
/* don't add the same object twice */
return false;
}
@@ -512,6 +512,17 @@ void BKE_collection_object_move(ID *owner_id, SceneCollection *sc_dst, SceneColl
}
}
+/**
+ * Whether the object is directly inside the collection.
+ */
+bool BKE_collection_object_exists(struct SceneCollection *scene_collection, struct Object *ob)
+{
+ if (BLI_findptr(&scene_collection->objects, ob, offsetof(LinkData, data))) {
+ return true;
+ }
+ return false;
+}
+
static void layer_collection_sync(LayerCollection *lc_dst, LayerCollection *lc_src)
{
lc_dst->flag = lc_src->flag;