diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_lib_id.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 3 |
4 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h index bb875f8d1c9..a50faedcc3c 100644 --- a/source/blender/blenkernel/BKE_lib_id.h +++ b/source/blender/blenkernel/BKE_lib_id.h @@ -166,8 +166,14 @@ struct ID *BKE_libblock_find_name(struct Main *bmain, */ typedef enum eLibIDDuplicateFlags { /** This call to a duplicate function is part of another call for some parent ID. - * Therefore, this sub-process should not clear `newid` pointers, nor handle remapping itself. */ + * Therefore, this sub-process should not clear `newid` pointers, nor handle remapping itself. + * NOTE: In some cases (like Object one), the duplicate function may be called on the root ID + * with this flag set, as remapping and/or other similar tasks need to be handled by the caller. + */ LIB_ID_DUPLICATE_IS_SUBPROCESS = 1 << 0, + /** This call is performed on a 'root' ID, and should therefore perform some decisions regarding + * sub-IDs (dependencies), check for linked vs. locale data, etc. */ + LIB_ID_DUPLICATE_IS_ROOT_ID = 1 << 1, } eLibIDDuplicateFlags; /* lib_remap.c (keep here since they're general functions) */ diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index d36e9b67d00..2d172f23428 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -692,14 +692,18 @@ Collection *BKE_collection_duplicate(Main *bmain, eLibIDDuplicateFlags duplicate_options) { const bool is_subprocess = (duplicate_options & LIB_ID_DUPLICATE_IS_SUBPROCESS) != 0; + const bool is_root_id = (duplicate_options & LIB_ID_DUPLICATE_IS_ROOT_ID) != 0; if (!is_subprocess) { BKE_main_id_newptr_and_tag_clear(bmain); + } + if (is_root_id) { /* In case root duplicated ID is linked, assume we want to get a local copy of it and duplicate * all expected linked data. */ if (ID_IS_LINKED(collection)) { duplicate_flags |= USER_DUP_LINKED_ID; } + duplicate_options &= ~LIB_ID_DUPLICATE_IS_ROOT_ID; } Collection *collection_new = collection_duplicate_recursive( diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1c08a46adc3..6e26ed4925d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2614,17 +2614,21 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src) Object *BKE_object_duplicate(Main *bmain, Object *ob, eDupli_ID_Flags dupflag, - const eLibIDDuplicateFlags duplicate_options) + eLibIDDuplicateFlags duplicate_options) { const bool is_subprocess = (duplicate_options & LIB_ID_DUPLICATE_IS_SUBPROCESS) != 0; + const bool is_root_id = (duplicate_options & LIB_ID_DUPLICATE_IS_ROOT_ID) != 0; if (!is_subprocess) { BKE_main_id_newptr_and_tag_clear(bmain); + } + if (is_root_id) { /* In case root duplicated ID is linked, assume we want to get a local copy of it and duplicate * all expected linked data. */ if (ID_IS_LINKED(ob)) { dupflag |= USER_DUP_LINKED_ID; } + duplicate_options &= ~LIB_ID_DUPLICATE_IS_ROOT_ID; } Material ***matarar; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a6190efbf75..5a668746956 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1984,9 +1984,12 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type) if (type == SCE_COPY_FULL) { /* Scene duplication is always root of duplication currently. */ const bool is_subprocess = false; + const bool is_root_id = true; if (!is_subprocess) { BKE_main_id_newptr_and_tag_clear(bmain); + } + if (is_root_id) { /* In case root duplicated ID is linked, assume we want to get a local copy of it and * duplicate all expected linked data. */ if (ID_IS_LINKED(sce)) { |