[Bf-blender-cvs] [86bfce6794a] blender2.8: Depsgraph: Don't call DEG ID update functions directly

Sergey Sharybin noreply at git.blender.org
Tue Nov 28 15:09:09 CET 2017


Commit: 86bfce6794a527e553b3a9a294dda89f035ed3b6
Author: Sergey Sharybin
Date:   Tue Nov 28 12:13:07 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB86bfce6794a527e553b3a9a294dda89f035ed3b6

Depsgraph: Don't call DEG ID update functions directly

There might be much more logic involved there, also we might not know proper
evaluated CoW pointer there yet. So we leave this to dependency graph to
decide what exactly to do here.

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

M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/editors/object/object_add.c

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

diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 7b1f1fc8ca9..930794a1778 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -151,9 +151,9 @@ enum {
 	DEG_TAG_TIME        = (1 << 2),
 
 	/* Particle system changed. */
-	DEG_TAG_PSYSC_REDO  =  (1 << 3),
-	DEG_TAG_PSYS_RESET  =  (1 << 4),
-	DEG_TAG_PSYS_TYPE   =  (1 << 5),
+	DEG_TAG_PSYSC_REDO  = (1 << 3),
+	DEG_TAG_PSYS_RESET  = (1 << 4),
+	DEG_TAG_PSYS_TYPE   = (1 << 5),
 	DEG_TAG_PSYS_CHILD  = (1 << 6),
 	DEG_TAG_PSYS_PHYS   = (1 << 7),
 	DEG_TAG_PSYS        = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7)),
@@ -167,6 +167,9 @@ enum {
 	DEG_TAG_SHADING_UPDATE  = (1 << 9),
 	DEG_TAG_SELECT_UPDATE   = (1 << 10),
 	DEG_TAG_BASE_FLAGS_UPDATE = (1 << 11),
+
+	/* Only inform editors about the change. Don't modify datablock itself. */
+	DEG_TAG_EDITORS_UPDATE = (1 << 12),
 };
 void DEG_id_tag_update(struct ID *id, int flag);
 void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag);
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index faaf3a828b2..b21a65c8273 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -352,6 +352,15 @@ void id_tag_update_base_flags(Depsgraph *graph, IDDepsNode *id_node)
 	}
 }
 
+void id_tag_update_editors_update(Main *bmain, Depsgraph * /*graph*/, ID *id)
+{
+	/* NOTE: We handle this immediately, without delaying anything, to be
+	 * sure we don't cause threading issues with OpenGL.
+	 */
+	/* TODO(sergey): Make sure this works for CoW-ed datablocks as well. */
+	deg_editors_id_update(bmain, id);
+}
+
 void id_tag_update_ntree_special(Main *bmain, Depsgraph *graph, ID *id, int flag)
 {
 	bNodeTree *ntree = NULL;
@@ -421,6 +430,9 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
 	if (flag & DEG_TAG_BASE_FLAGS_UPDATE) {
 		id_tag_update_base_flags(graph, id_node);
 	}
+	if (flag & DEG_TAG_EDITORS_UPDATE) {
+		id_tag_update_editors_update(bmain, graph, id);
+	}
 	id_tag_update_ntree_special(bmain, graph, id, flag);
 }
 
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 77b30951dee..649e4c7f221 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -449,10 +449,13 @@ Object *ED_object_add_type(
 		ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH); /* copied from rna_object.c */
 	}
 
+	/* TODO(sergey): This is weird to manually tag objects for update, better to
+	 * use DEG_id_tag_update here perhaps.
+	 */
 	DEG_id_type_tag(bmain, ID_OB);
 	DEG_relations_tag_update(bmain);
-	if (ob->data) {
-		ED_render_id_flush_update(bmain, ob->data);
+	if (ob->data != NULL) {
+		DEG_id_tag_update_ex(bmain, (ID *)ob->data, DEG_TAG_EDITORS_UPDATE);
 	}
 
 	if (enter_editmode)
@@ -2340,8 +2343,8 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer,
 
 	/* DAG_relations_tag_update(bmain); */ /* caller must do */
 
-	if (ob->data) {
-		ED_render_id_flush_update(bmain, ob->data);
+	if (ob->data != NULL) {
+		DEG_id_tag_update_ex(bmain, (ID *)ob->data, DEG_TAG_EDITORS_UPDATE);
 	}
 
 	BKE_main_id_clear_newpoins(bmain);



More information about the Bf-blender-cvs mailing list