diff options
author | Bastien Montagne <bastien@blender.org> | 2022-02-03 17:38:51 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-02-03 17:38:51 +0300 |
commit | bcded0a1588dea0934f9a0cb3c4237ecae13c2c2 (patch) | |
tree | 6cc6409027b9c971a0864a971f7e5c664bdc6b11 /source/blender/blenkernel | |
parent | 5920de9247f2094b88716feca4811b7aa6f60505 (diff) | |
parent | 946c70e6a7892985289bf8dfaead8512d33eba79 (diff) |
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_collection.h | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 17 |
2 files changed, 23 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 402bffea91d..bce15349880 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -123,12 +123,21 @@ struct Collection *BKE_collection_object_find(struct Main *bmain, bool BKE_collection_is_empty(const struct Collection *collection); /** - * Add object to collection + * Add object to given collection, ensuring this collection is 'editable' (i.e. local and not a + * liboverride), and finding a suitable parent one otherwise. */ bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob); /** + * Same as #BKE_collection_object_add, but uncondionnaly adds the object to the given collection. + * + * NOTE: required in certain cases, like do-versionning or complex ID management tasks. + */ +bool BKE_collection_object_add_notest(struct Main *bmain, + struct Collection *collection, + struct Object *ob); +/** * Add \a ob_dst to all scene collections that reference object \a ob_src is in. * Used for copying objects. * diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index e6ce4eb9440..79f40c1c888 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1094,14 +1094,12 @@ static bool collection_object_remove(Main *bmain, return true; } -bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) +bool BKE_collection_object_add_notest(Main *bmain, Collection *collection, Object *ob) { - if (ELEM(NULL, collection, ob)) { + if (ob == NULL) { return false; } - collection = collection_parent_editable_find_recursive(collection); - /* Only case where this pointer can be NULL is when scene itself is linked, this case should * never be reached. */ BLI_assert(collection != NULL); @@ -1122,6 +1120,17 @@ bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) return true; } +bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) +{ + if (collection == NULL) { + return false; + } + + collection = collection_parent_editable_find_recursive(collection); + + return BKE_collection_object_add_notest(bmain, collection, ob); +} + void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst) { bool is_instantiated = false; |