[Bf-blender-cvs] [be31582e3d4] master: Fix T51624: Scene Full Copy ignores shader node links.

Bastien Montagne noreply at git.blender.org
Mon May 29 11:42:10 CEST 2017


Commit: be31582e3d4207eac0b296e143fffe5b98e95df1
Author: Bastien Montagne
Date:   Mon May 29 11:00:01 2017 +0200
Branches: master
https://developer.blender.org/rBbe31582e3d4207eac0b296e143fffe5b98e95df1

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.

===================================================================

M	source/blender/editors/object/object_relations.c

===================================================================

diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 5a0921f7119..7ec43b02b38 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -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);




More information about the Bf-blender-cvs mailing list