[Bf-blender-cvs] [90bc8820684] master: Depsgraph: Remove root node concept

Sergey Sharybin noreply at git.blender.org
Tue Jun 13 14:15:28 CEST 2017


Commit: 90bc882068465865883da55e5c82fa99e0f8d66b
Author: Sergey Sharybin
Date:   Tue Jun 13 14:12:54 2017 +0200
Branches: master
https://developer.blender.org/rB90bc882068465865883da55e5c82fa99e0f8d66b

Depsgraph: Remove root node concept

Was rather weird and only used for time source. It is simpler to make depsgraph
to keep track of time source directly.

No need to introduce extra entitites without actual need.

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

M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
M	source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph.cc
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_types.h
M	source/blender/depsgraph/intern/eval/deg_eval_flush.cc
M	source/blender/depsgraph/intern/nodes/deg_node.cc
M	source/blender/depsgraph/intern/nodes/deg_node.h

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 99d8834da1b..ff5cba89741 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -160,11 +160,6 @@ DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
 {
 }
 
-RootDepsNode *DepsgraphNodeBuilder::add_root_node()
-{
-	return m_graph->add_root_node();
-}
-
 IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
 {
 	return m_graph->add_id_node(id, id->name);
@@ -172,12 +167,7 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
 
 TimeSourceDepsNode *DepsgraphNodeBuilder::add_time_source()
 {
-	/* root-node */
-	RootDepsNode *root_node = m_graph->root_node;
-	if (root_node != NULL) {
-		return root_node->add_time_source("Time Source");
-	}
-	return NULL;
+	return m_graph->add_time_source();
 }
 
 ComponentDepsNode *DepsgraphNodeBuilder::add_component_node(
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index ba8a5d01cb0..6bc1c1dead4 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -61,7 +61,6 @@ namespace DEG {
 
 struct Depsgraph;
 struct DepsNode;
-struct RootDepsNode;
 struct IDDepsNode;
 struct TimeSourceDepsNode;
 struct ComponentDepsNode;
@@ -73,7 +72,6 @@ struct DepsgraphNodeBuilder {
 
 	void begin_build(Main *bmain);
 
-	RootDepsNode *add_root_node();
 	IDDepsNode *add_id_node(ID *id);
 	TimeSourceDepsNode *add_time_source();
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 348501b107b..dbe8a5f1984 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -198,13 +198,6 @@ DepsgraphRelationBuilder::DepsgraphRelationBuilder(Depsgraph *graph) :
 {
 }
 
-RootDepsNode *DepsgraphRelationBuilder::find_node(const RootKey &key) const
-{
-	(void)key;
-	BLI_assert(!"Doesn't seem to be correct");
-	return m_graph->root_node;
-}
-
 TimeSourceDepsNode *DepsgraphRelationBuilder::find_node(
         const TimeSourceKey &key) const
 {
@@ -213,7 +206,7 @@ TimeSourceDepsNode *DepsgraphRelationBuilder::find_node(
 		return NULL;
 	}
 	else {
-		return m_graph->root_node->time_source;
+		return m_graph->time_source;
 	}
 }
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index c5a73ba2d98..02f8fc69070 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -84,10 +84,6 @@ struct ComponentDepsNode;
 struct OperationDepsNode;
 struct RootPChanMap;
 
-struct RootKey {
-	RootKey();
-};
-
 struct TimeSourceKey
 {
 	TimeSourceKey();
@@ -236,7 +232,6 @@ struct DepsgraphRelationBuilder
 	Depsgraph *getGraph();
 
 protected:
-	RootDepsNode *find_node(const RootKey &key) const;
 	TimeSourceDepsNode *find_node(const TimeSourceKey &key) const;
 	ComponentDepsNode *find_node(const ComponentKey &key) const;
 	OperationDepsNode *find_node(const OperationKey &key) const;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
index 478756e0cff..9d6ab3358a7 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
@@ -35,13 +35,6 @@
 namespace DEG {
 
 /////////////////////////////////////////
-// Root.
-
-RootKey::RootKey()
-{
-}
-
-/////////////////////////////////////////
 // Time source.
 
 TimeSourceKey::TimeSourceKey()
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
index 07712e060ca..51d4ed91419 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
@@ -77,19 +77,18 @@ static const char *deg_debug_colors_light[] = {
 
 #ifdef COLOR_SCHEME_NODE_TYPE
 static const int deg_debug_node_type_color_map[][2] = {
-    {DEG_NODE_TYPE_ROOT,         0},
-    {DEG_NODE_TYPE_TIMESOURCE,   1},
+    {DEG_NODE_TYPE_TIMESOURCE,   0},
     {DEG_NODE_TYPE_ID_REF,       2},
 
     /* Outer Types */
-    {DEG_NODE_TYPE_PARAMETERS,   3},
-    {DEG_NODE_TYPE_PROXY,        4},
-    {DEG_NODE_TYPE_ANIMATION,    5},
-    {DEG_NODE_TYPE_TRANSFORM,    6},
-    {DEG_NODE_TYPE_GEOMETRY,     7},
-    {DEG_NODE_TYPE_SEQUENCER,    8},
-    {DEG_NODE_TYPE_SHADING,      9},
-    {DEG_NODE_TYPE_CACHE,        10},
+    {DEG_NODE_TYPE_PARAMETERS,   2},
+    {DEG_NODE_TYPE_PROXY,        3},
+    {DEG_NODE_TYPE_ANIMATION,    4},
+    {DEG_NODE_TYPE_TRANSFORM,    5},
+    {DEG_NODE_TYPE_GEOMETRY,     6},
+    {DEG_NODE_TYPE_SEQUENCER,    7},
+    {DEG_NODE_TYPE_SHADING,      8},
+    {DEG_NODE_TYPE_CACHE,        9},
     {-1,                         0}
 };
 #endif
@@ -498,9 +497,6 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx,
 static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx,
                                            const Depsgraph *graph)
 {
-	if (graph->root_node) {
-		deg_debug_graphviz_node(ctx, graph->root_node);
-	}
 	GHASH_FOREACH_BEGIN (DepsNode *, node, graph->id_hash)
 	{
 		deg_debug_graphviz_node(ctx, node);
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 330f8a0dcb6..43d8d560856 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -69,7 +69,7 @@ static DEG_EditorUpdateSceneCb deg_editor_update_scene_cb = NULL;
 static DEG_EditorUpdateScenePreCb deg_editor_update_scene_pre_cb = NULL;
 
 Depsgraph::Depsgraph()
-  : root_node(NULL),
+  : time_source(NULL),
     need_update(false),
     layers(0)
 {
@@ -80,12 +80,11 @@ Depsgraph::Depsgraph()
 
 Depsgraph::~Depsgraph()
 {
-	/* Free root node - it won't have been freed yet... */
 	clear_id_nodes();
 	BLI_ghash_free(id_hash, NULL, NULL);
 	BLI_gset_free(entry_tags, NULL);
-	if (this->root_node != NULL) {
-		OBJECT_GUARDED_DELETE(this->root_node, RootDepsNode);
+	if (time_source != NULL) {
+		OBJECT_GUARDED_DELETE(time_source, TimeSourceDepsNode);
 	}
 	BLI_spin_end(&lock);
 }
@@ -260,19 +259,18 @@ static void id_node_deleter(void *value)
 	OBJECT_GUARDED_DELETE(id_node, IDDepsNode);
 }
 
-RootDepsNode *Depsgraph::add_root_node()
+TimeSourceDepsNode *Depsgraph::add_time_source()
 {
-	if (!root_node) {
-		DepsNodeFactory *factory = deg_get_node_factory(DEG_NODE_TYPE_ROOT);
-		root_node = (RootDepsNode *)factory->create_node(NULL, "", "Root (Scene)");
+	if (time_source == NULL) {
+		DepsNodeFactory *factory = deg_get_node_factory(DEG_NODE_TYPE_TIMESOURCE);
+		time_source = (TimeSourceDepsNode *)factory->create_node(NULL, "", "Time Source");
 	}
-	return root_node;
+	return time_source;
 }
 
 TimeSourceDepsNode *Depsgraph::find_time_source() const
 {
-	BLI_assert(root_node != NULL);
-	return root_node->time_source;
+	return time_source;
 }
 
 IDDepsNode *Depsgraph::find_id_node(const ID *id) const
@@ -413,9 +411,9 @@ void Depsgraph::clear_all_nodes()
 {
 	clear_id_nodes();
 	BLI_ghash_clear(id_hash, NULL, NULL);
-	if (this->root_node) {
-		OBJECT_GUARDED_DELETE(this->root_node, RootDepsNode);
-		root_node = NULL;
+	if (time_source != NULL) {
+		OBJECT_GUARDED_DELETE(time_source, TimeSourceDepsNode);
+		time_source = NULL;
 	}
 }
 
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 1c9ba8c4cb1..3e67e348e6e 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -49,7 +49,6 @@ struct PropertyRNA;
 namespace DEG {
 
 struct DepsNode;
-struct RootDepsNode;
 struct TimeSourceDepsNode;
 struct IDDepsNode;
 struct ComponentDepsNode;
@@ -108,8 +107,7 @@ struct Depsgraph {
 	 */
 	DepsNode *find_node_from_pointer(const PointerRNA *ptr, const PropertyRNA *prop) const;
 
-	RootDepsNode *add_root_node();
-
+	TimeSourceDepsNode *add_time_source();
 	TimeSourceDepsNode *find_time_source() const;
 
 	IDDepsNode *find_id_node(const ID *id) const;
@@ -138,8 +136,8 @@ struct Depsgraph {
 	 * (for quick lookups). */
 	GHash *id_hash;
 
-	/* "root" node - the one where all evaluation enters from. */
-	RootDepsNode *root_node;
+	/* Top-level time source node. */
+	TimeSourceDepsNode *time_source;
 
 	/* Indicates whether relations needs to be updated. */
 	bool need_update;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 850c3617c46..47bf5e7ecbb 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -207,23 +207,13 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
 
 	/* 1) Generate all the nodes in the graph first */
 	DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph);
-	/* create root node for scene first
-	 * - this way it should be the first in the graph,
-	 *   reflecting its role as the entrypoint
-	 */
 	node_builder.begin_build(bmain);
-	node_builder.add_root_node();
 	node_builder.build_scene(bmain, scene);
 
 	/* 2) Hook up relationships between operations - to determine evaluation
 	 *    order.
 	 */
 	DEG::DepsgraphRelationBuilder relation_builder(deg_graph);
-	/* Hook scene up to the root node as entrypoint to graph. */
-	/* XXX what does this relation actually mean?
-	 * it doesnt add any operations anyway and is not clear what part of the
-	 * scene is to be connected.
-	 */
 	relation_builder.begin_build(bmain);
 	relation_builder.build_scene(bmain, scene);
 
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 0d857a8dc52..c1a42941a7d 100644
--- a/source/blender/depsgraph/intern/depsgraph_typ

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list