From eee35ebdfbed405c45d51dc9d5f29dfd87cea0fc Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 10 Jun 2020 18:27:32 +0200 Subject: Make `BKE_scene_copy` fully handle all duplicate modes, deep copy included. This greatly simplifies and unifies logic. Also addresses T77255: full scene copy will now use same preferences parameters as object or collection duplicate to choose which data-blocks to copy along. --- source/blender/blenkernel/intern/scene.c | 7 ++++--- source/blender/editors/scene/scene_edit.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f6cbf831629..1b06217f1df 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -851,6 +851,10 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, eSceneCopyMethod type) id_us_min(&sce_copy->gpd->id); BKE_id_copy_ex(bmain, (ID *)sce_copy->gpd, (ID **)&sce_copy->gpd, LIB_ID_COPY_ACTIONS); } + + /* Deep-duplicate collections and objects (using preferences' settings for which sub-data to + * duplicate along the object itself). */ + BKE_collection_duplicate(bmain, NULL, sce_copy->master_collection, true, true, true); } else { /* Remove sequencer if not full copy */ @@ -859,9 +863,6 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, eSceneCopyMethod type) BKE_sequencer_editing_free(sce_copy, true); } - /* NOTE: part of SCE_COPY_FULL operations - * are done outside of blenkernel with ED_object_single_users! */ - return sce_copy; } } diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index d78b1532a39..059337dd6fe 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -61,13 +61,13 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me else { /* different kinds of copying */ Scene *scene_old = WM_window_get_active_scene(win); - scene_new = BKE_scene_copy(bmain, scene_old, method); - - /* these can't be handled in blenkernel currently, so do them here */ + /* We are going to deep-copy collections, objects and various object data, we need to have + * up-to-date obdata for that. */ if (method == SCE_COPY_FULL) { ED_editors_flush_edits(bmain); - ED_object_single_users(bmain, scene_new, true, true); } + + scene_new = BKE_scene_copy(bmain, scene_old, method); } WM_window_set_active_scene(bmain, C, win, scene_new); -- cgit v1.2.3