From df63195d2a7bc374398b0b6dfa389db3b40f5a70 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 30 Nov 2016 15:25:54 +0100 Subject: Cleanup id->newid usage, initial work. This aims at always ensuring that ID.newid (and relevant LIB_TAG_NEW) stay in clean (i.e. cleared) state by default. To achieve this, instead of clearing after all id copy call (would be horribly noisy, and bad for performances), we try to completely remove the setting of id->newid by default when copying a new ID. This implies that areas actually needing that info (mainly, object editing area (make single user...) and make local area) have to ensure they set it themselves as needed. This is far from simple change, many complex code paths to consider, so will need some serious testing. :/ --- source/blender/blenkernel/intern/scene.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern/scene.c') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6e1f11cb526..a699427315e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -186,8 +186,6 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) scen = BKE_libblock_copy(bmain, &sce->id); BLI_duplicatelist(&(scen->base), &(sce->base)); - BKE_main_id_clear_newpoins(bmain); - id_us_plus((ID *)scen->world); id_us_plus((ID *)scen->set); /* id_us_plus((ID *)scen->gm.dome.warptext); */ /* XXX Not refcounted? see readfile.c */ @@ -225,7 +223,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) } /* copy action and remove animation used by sequencer */ - BKE_animdata_copy_id_action(&scen->id); + BKE_animdata_copy_id_action(&scen->id, false); if (type != SCE_COPY_FULL) remove_sequencer_fcurves(scen); @@ -318,7 +316,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) /* camera */ if (type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) { - ID_NEW(scen->camera); + ID_NEW_REMAP(scen->camera); } /* before scene copy */ @@ -329,7 +327,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) if (scen->world) { id_us_plus((ID *)scen->world); scen->world = BKE_world_copy(bmain, scen->world); - BKE_animdata_copy_id_action((ID *)scen->world); + BKE_animdata_copy_id_action((ID *)scen->world, false); } if (sce->ed) { -- cgit v1.2.3 From efadc8051eaca1202d5f7074b8a644b26eb54e75 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 12 Dec 2016 14:31:50 +0100 Subject: Cleanup: Get rid of ntreeSwitchID(_ex) functions, use generic BKE_libblock_relink_ex instead. --- source/blender/blenkernel/intern/scene.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/scene.c') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a699427315e..091b8100d27 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -78,6 +78,7 @@ #include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_library.h" +#include "BKE_library_remap.h" #include "BKE_linestyle.h" #include "BKE_main.h" #include "BKE_mask.h" @@ -209,7 +210,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) if (sce->nodetree) { /* ID's are managed on both copy and switch */ scen->nodetree = ntreeCopyTree(bmain, sce->nodetree); - ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); + BKE_libblock_relink_ex(bmain, scen->nodetree, &sce->id, &scen->id, false); } obase = sce->base.first; -- cgit v1.2.3