Fix T65175: nodetree animation stays linked after duplicating a lamp

Reviewers: mont29, brecht

Maniphest Tasks: T65175

Differential Revision: https://developer.blender.org/D4956
This commit is contained in:
Philipp Oeser 2019-05-28 21:02:40 +02:00
parent 574e790340
commit db0568329e
Notes: blender-bot 2023-02-14 02:25:34 +01:00
Referenced by issue #65175, Animation Data on lamp stays linked even after unlinking all its data
3 changed files with 14 additions and 12 deletions

View File

@ -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 */

View File

@ -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);
}

View File

@ -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);