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 <bastien@blender.org>2022-02-03 17:38:51 +0300
committerBastien Montagne <bastien@blender.org>2022-02-03 17:38:51 +0300
commitbcded0a1588dea0934f9a0cb3c4237ecae13c2c2 (patch)
tree6cc6409027b9c971a0864a971f7e5c664bdc6b11
parent5920de9247f2094b88716feca4811b7aa6f60505 (diff)
parent946c70e6a7892985289bf8dfaead8512d33eba79 (diff)
Merge branch 'blender-v3.1-release'
-rw-r--r--source/blender/blenkernel/BKE_collection.h11
-rw-r--r--source/blender/blenkernel/intern/collection.c17
-rw-r--r--source/blender/blenloader/intern/versioning_280.c6
3 files changed, 26 insertions, 8 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;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index ceddc451a46..57105ca5884 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -349,7 +349,7 @@ static void do_version_scene_collection_convert(
LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
Object *ob = link->data;
if (ob) {
- BKE_collection_object_add(bmain, collection, ob);
+ BKE_collection_object_add_notest(bmain, collection, ob);
id_us_min(&ob->id);
}
}
@@ -459,7 +459,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
/* Note usually this would do slow collection syncing for view layers,
* but since no view layers exists yet at this point it's fast. */
- BKE_collection_object_add(bmain, collections[layer], base->object);
+ BKE_collection_object_add_notest(bmain, collections[layer], base->object);
}
if (base->flag & SELECT) {
@@ -1235,7 +1235,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
(*collection_hidden)->flag |= COLLECTION_HIDE_VIEWPORT | COLLECTION_HIDE_RENDER;
}
- BKE_collection_object_add(bmain, *collection_hidden, ob);
+ BKE_collection_object_add_notest(bmain, *collection_hidden, ob);
BKE_collection_object_remove(bmain, collection, ob, true);
}
}