Fix T51624: Scene Full Copy ignores shader node links.

Properly remap nodes' pointers to copied IDs in copied ntrees.

Note that this only affects root trees, node groups are not concerned
here, since they are assumed to be reusable chunks and hence *not*
duplicated.
This commit is contained in:
Bastien Montagne 2017-05-29 11:00:01 +02:00
parent ea147e9a28
commit be31582e3d

@ -83,6 +83,7 @@
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_sca.h"
@ -2102,6 +2103,18 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
single_tex_users_expand(bmain);
}
/* Relink nodetrees' pointers that have been duplicated. */
FOREACH_NODETREE(bmain, ntree, id)
{
/* This is a bit convoluted, we want to root ntree of copied IDs and only those,
* so we first check that old ID has been copied and that ntree is root tree of old ID,
* then get root tree of new ID and remap its pointers to new ID... */
if (id->newid && (&ntree->id != id)) {
ntree = ntreeFromID(id->newid);
BKE_libblock_relink_to_newid(&ntree->id);
}
} FOREACH_NODETREE_END
/* Relink datablock pointer properties */
{
IDP_RelinkProperty(scene->id.properties);