From db0568329e46cf58eed2d0f8ab633bdc52251bfc Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 28 May 2019 21:02:40 +0200 Subject: Fix T65175: nodetree animation stays linked after duplicating a lamp Reviewers: mont29, brecht Maniphest Tasks: T65175 Differential Revision: https://developer.blender.org/D4956 --- source/blender/blenkernel/intern/anim_sys.c | 5 +++++ source/blender/blenkernel/intern/object.c | 18 +++++++++--------- source/blender/editors/object/object_relations.c | 3 --- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 4a939180fb0..952859e0c7b 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -59,6 +59,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_nla.h" +#include "BKE_node.h" #include "BKE_report.h" #include "BKE_texture.h" @@ -365,6 +366,10 @@ void BKE_animdata_copy_id_action(Main *bmain, ID *id, const bool set_newid) BKE_action_copy(bmain, adt->tmpact); } } + bNodeTree *ntree = ntreeFromID(id); + if (ntree) { + BKE_animdata_copy_id_action(bmain, &ntree->id, set_newid); + } } /* Merge copies of the data from the src AnimData into the destination AnimData */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index fcb1066b633..a4dbbb5d238 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1512,12 +1512,11 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag) else { obn->mat[a] = ID_NEW_SET(obn->mat[a], BKE_material_copy(bmain, obn->mat[a])); + if (dupflag & USER_DUP_ACT) { + BKE_animdata_copy_id_action(bmain, &obn->mat[a]->id, true); + } } id_us_min(id); - - if (dupflag & USER_DUP_ACT) { - BKE_animdata_copy_id_action(bmain, &obn->mat[a]->id, true); - } } } } @@ -1530,12 +1529,10 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag) else { psys->part = ID_NEW_SET(psys->part, BKE_particlesettings_copy(bmain, psys->part)); + if (dupflag & USER_DUP_ACT) { + BKE_animdata_copy_id_action(bmain, &psys->part->id, true); + } } - - if (dupflag & USER_DUP_ACT) { - BKE_animdata_copy_id_action(bmain, &psys->part->id, true); - } - id_us_min(id); } } @@ -1712,6 +1709,9 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag) else { (*matarar)[a] = ID_NEW_SET((*matarar)[a], BKE_material_copy(bmain, (*matarar)[a])); + if (dupflag & USER_DUP_ACT) { + BKE_animdata_copy_id_action(bmain, &(*matarar)[a]->id, true); + } } id_us_min(id); } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 6df012cdc80..6879a7f4a06 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1967,9 +1967,6 @@ static void single_mat_users( if (ma->id.us > 1) { man = BKE_material_copy(bmain, ma); BKE_animdata_copy_id_action(bmain, &man->id, false); - if (man->nodetree != NULL) { - BKE_animdata_copy_id_action(bmain, &man->nodetree->id, false); - } man->id.us = 0; assign_material(bmain, ob, man, a, BKE_MAT_ASSIGN_USERPREF); -- cgit v1.2.3