[Bf-blender-cvs] [deecfb54763] blender2.8: Depsgraph: Avoid creating ID nodes for objects which are coming from collections and not layers

Sergey Sharybin noreply at git.blender.org
Mon Jul 24 16:24:54 CEST 2017


Commit: deecfb54763596555353e82a97b00547310f62a9
Author: Sergey Sharybin
Date:   Mon Jul 24 15:39:31 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBdeecfb54763596555353e82a97b00547310f62a9

Depsgraph: Avoid creating ID nodes for objects which are coming from collections and not layers

If object is only listed in collection but not added to any of layers we shouldn't create
placeholder for it, because otherwise we'll leave lots of placeholder ID nodes.

Question: can we make this exception to be more reliable?

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

M	source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc

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

diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 9c1773bbf3e..248a58d4ff5 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -368,7 +368,7 @@ struct RemapCallbackUserData {
 };
 
 int foreach_libblock_remap_callback(void *user_data_v,
-                                    ID * /*id_self*/,
+                                    ID *id_self,
                                     ID **id_p,
                                     int /*cb_flag*/)
 {
@@ -384,7 +384,28 @@ int foreach_libblock_remap_callback(void *user_data_v,
 		else if (check_datablocks_copy_on_writable(id_orig)) {
 			ID *id_cow;
 			if (user_data->create_placeholders) {
-				id_cow = depsgraph->ensure_cow_id(id_orig);
+				/* Special workaround to stop creating temp datablocks for
+				 * objects which are coming from scene's collection and which
+				 * are never linked to any of layers.
+				 *
+				 * TODO(sergey): Ideally we need to tell ID looper to ignore
+				 * those or at least make it more reliable check where the
+				 * pointer is coming from.
+				 */
+				const short id_type = GS(id_orig->name);
+				const short id_type_self = GS(id_self->name);
+				if (id_type == ID_OB && id_type_self == ID_SCE) {
+					IDDepsNode *id_node = depsgraph->find_id_node(id_orig);
+					if (id_node == NULL) {
+						id_cow = id_orig;
+					}
+					else {
+						id_cow = id_node->id_cow;
+					}
+				}
+				else {
+					id_cow = depsgraph->ensure_cow_id(id_orig);
+				}
 			}
 			else {
 				id_cow = depsgraph->get_cow_id(id_orig);




More information about the Bf-blender-cvs mailing list