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>2020-06-10 17:43:25 +0300
committerBastien Montagne <bastien@blender.org>2020-06-10 17:48:49 +0300
commit74ec37b70cbc8dc228f11d0796dbe68c24526b16 (patch)
tree5691206349ce3365d554ec64e136fc534908af76 /source/blender/blenkernel/intern/collection.c
parent1d0017089c6ad4bd9b87af1bb30024a86e7b2771 (diff)
Enable (deep) copy of overrides.
This commit enables basic copy of overrides on generic ID level, as well as from (deep) copy operators for objects and collections. So e.g. if your linked overridden caracter is in a collection, you can now (from the outliner) Duplicate that override collection to get a new overriding copy of the character. We still need operators (new or modifying existing ones) to handle that from 3DView e.g. Note that deep copy code for objects/collections (and incidently animdata) had to be modified to avoid duplicating/making local IDs that remain linked ones being used by overrides ones.
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index e8e3e61ced4..1388146eeb7 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -314,6 +314,7 @@ static Collection *collection_duplicate_recursive(Main *bmain,
Collection *collection_new;
bool do_full_process = false;
const int object_dupflag = (do_obdata) ? U.dupflag : 0;
+ const bool is_collection_liboverride = ID_IS_OVERRIDE_LIBRARY(collection_old);
if (!do_hierarchy || collection_old->id.newid == NULL) {
BKE_id_copy(bmain, &collection_old->id, (ID **)&collection_new);
@@ -359,6 +360,12 @@ static Collection *collection_duplicate_recursive(Main *bmain,
Object *ob_old = cob->ob;
Object *ob_new = (Object *)ob_old->id.newid;
+ /* If collection is an override, we do not want to duplicate any linked data-block, as that
+ * would generate a purely local data. */
+ if (is_collection_liboverride && ID_IS_LINKED(ob_old)) {
+ continue;
+ }
+
if (ob_new == NULL) {
ob_new = BKE_object_duplicate(bmain, ob_old, object_dupflag);
ID_NEW_SET(ob_old, ob_new);
@@ -430,7 +437,7 @@ Collection *BKE_collection_duplicate(Main *bmain,
Collection *collection_new = collection_duplicate_recursive(
bmain, parent, collection, do_hierarchy, do_objects, do_obdata);
- /* This code will follows into all ID links using an ID tagged with LIB_TAG_NEW.*/
+ /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/
BKE_libblock_relink_to_newid(&collection_new->id);
if (do_hierarchy) {