[Bf-blender-cvs] [393089c] depsgraph_refactor: Added new node method 'build_operations' which will replace the current 'validate_link' for constructing the inner nodes from ID- and component nodes.

Lukas Tönne noreply at git.blender.org
Tue May 13 18:41:06 CEST 2014


Commit: 393089c48a4470ccefc234793700182090bd509f
Author: Lukas Tönne
Date:   Wed May 7 15:04:52 2014 +0200
https://developer.blender.org/rB393089c48a4470ccefc234793700182090bd509f

Added new node method 'build_operations' which will replace the current
'validate_link' for constructing the inner nodes from ID- and component
nodes.

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

M	source/blender/depsgraph/intern/depsgraph.cpp
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build.h
M	source/blender/depsgraph/intern/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode.h
M	source/blender/depsgraph/intern/depsnode_component.cpp
M	source/blender/depsgraph/intern/depsnode_component.h
M	source/blender/depsgraph/intern/depsnode_operation.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index 03706a3..64be3f0 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -209,6 +209,14 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from, OperationDeps
 	return rel;
 }
 
+void Depsgraph::build_operations(const OperationBuilder &builder) const
+{
+	for (Depsgraph::IDNodeMap::const_iterator it = this->id_hash.begin(); it != this->id_hash.end(); ++it) {
+		DepsNode *node = it->second;
+		node->build_operations(builder);
+	}
+}
+
 /* Ensure that all implicit constraints between nodes are satisfied 
  * (e.g. components are only allowed to be executed in a certain order)
  */
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 88d40e8..281594e 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -56,6 +56,8 @@ struct SubgraphDepsNode;
 struct ComponentDepsNode;
 struct OperationDepsNode;
 
+struct OperationBuilder;
+
 
 /* ************************************* */
 /* Relationships Between Nodes */
@@ -140,6 +142,8 @@ struct Depsgraph {
 	                               eDepsRelation_Type type, 
 	                               const string &description);
 	
+	void build_operations(const OperationBuilder &builder) const;
+	
 	/* Ensure that all implicit constraints between nodes are satisfied 
 	 * (e.g. components are only allowed to be executed in a certain order)
 	 */
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 49a419a..a975693 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -234,6 +234,25 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(IDDepsNode *id_node,
 	return op_node;
 }
 
+
+/* ************************************************* */
+/* Operation Builder */
+
+OperationBuilder::OperationBuilder(Depsgraph *graph) :
+    m_graph(graph)
+{
+}
+
+OperationDepsNode *OperationBuilder::add_operation_node(ComponentDepsNode *comp_node, eDepsNode_Type type, eDepsOperation_Type optype,
+                                                        DepsEvalOperationCb op, const string &description,
+                                                        PointerRNA ptr)
+{
+	OperationDepsNode *op_node = comp_node->add_operation(type, optype, op, description);
+	op_node->ptr = ptr;
+	return op_node;
+}
+
+
 /* ************************************************* */
 /* Relations Builder */
 
@@ -359,6 +378,10 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
 	relation_builder.add_relation(RootKey(), IDKey(scene), DEPSREL_TYPE_ROOT_TO_ACTIVE, "Root to Active Scene");
 	relation_builder.build_scene(scene);
 	
+	/* add internal nodes (operations) for all components */
+	OperationBuilder op_builder(graph);
+	graph->build_operations(op_builder);
+	
 #if 0
 	/* ensure that all implicit constraints between nodes are satisfied */
 	DEG_graph_validate_links(graph);
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index b716950..e3bceed 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -51,6 +51,7 @@ struct World;
 
 struct Depsgraph;
 struct DepsNode;
+struct DepsNodeHandle;
 struct RootDepsNode;
 struct SubgraphDepsNode;
 struct IDDepsNode;
@@ -102,6 +103,17 @@ private:
 	Depsgraph *m_graph;
 };
 
+struct OperationBuilder {
+	OperationBuilder(Depsgraph *graph);
+	
+	OperationDepsNode *add_operation_node(ComponentDepsNode *comp_node, eDepsNode_Type type, eDepsOperation_Type optype,
+	                                      DepsEvalOperationCb op, const string &description,
+	                                      PointerRNA ptr);
+	
+private:
+	Depsgraph *m_graph;
+};
+
 struct RootKey
 {
 	RootKey() {}
diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index 59b8d5e..bb1c6a3 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -82,11 +82,22 @@ TimeSourceDepsNode *RootDepsNode::add_time_source(const string &name)
 	return time_source;
 }
 
+void RootDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	if (time_source)
+		time_source->build_operations(builder);
+}
+
 DEG_DEPSNODE_DEFINE(RootDepsNode, DEPSNODE_TYPE_ROOT, "Root DepsNode");
 static DepsNodeFactoryImpl<RootDepsNode> DNTI_ROOT;
 
 /* Time Source Node ======================================= */
 
+void TimeSourceDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	/* TODO */
+}
+
 DEG_DEPSNODE_DEFINE(TimeSourceDepsNode, DEPSNODE_TYPE_TIMESOURCE, "Time Source");
 static DepsNodeFactoryImpl<TimeSourceDepsNode> DNTI_TIMESOURCE;
 
@@ -171,6 +182,14 @@ void IDDepsNode::clear_components()
 	components.clear();
 }
 
+void IDDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	for (IDDepsNode::ComponentMap::const_iterator it = this->components.begin(); it != this->components.end(); ++it) {
+		DepsNode *component = it->second;
+		component->build_operations(builder);
+	}
+}
+
 /* Validate links between components */
 void IDDepsNode::validate_links(Depsgraph *graph)
 {
@@ -283,6 +302,12 @@ void SubgraphDepsNode::copy(DepsgraphCopyContext *dcc, const SubgraphDepsNode *s
 	/* for now, subgraph itself isn't copied... */
 }
 
+void SubgraphDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	if (graph)
+		graph->build_operations(builder);
+}
+
 /* Validate subgraph links... */
 void SubgraphDepsNode::validate_links(Depsgraph *graph)
 {
diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index e2b803e..10ec09b 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -49,6 +49,8 @@ struct DepsRelation;
 struct DepsgraphCopyContext;
 struct OperationDepsNode;
 
+struct OperationBuilder;
+
 /* ************************************* */
 /* Base-Defines for Nodes in Depsgraph */
 
@@ -76,6 +78,8 @@ public:
 	virtual void init(const ID *id, const string &subdata) {}
 	virtual void copy(DepsgraphCopyContext *dcc, const DepsNode *src) {}
 	
+	virtual void build_operations(const OperationBuilder &builder) const = 0;
+	
 	/* Recursively ensure that all implicit/builtin link rules have been applied */
 	/* i.e. init()/cleanup() callbacks as last items for components + component ordering rules obeyed */
 	virtual void validate_links(Depsgraph *graph) {}
@@ -105,6 +109,8 @@ struct ComponentDepsNode;
 struct TimeSourceDepsNode : public DepsNode {
 	// XXX: how do we keep track of the chain of time sources for propagation of delays?
 	
+	void build_operations(const OperationBuilder &builder) const;
+	
 	double cfra;                    /* new "current time" */
 	double offset;                  /* time-offset relative to the "official" time source that this one has */
 	
@@ -115,6 +121,8 @@ struct TimeSourceDepsNode : public DepsNode {
 struct RootDepsNode : public DepsNode {
 	TimeSourceDepsNode *add_time_source(const string &name = "");
 	
+	void build_operations(const OperationBuilder &builder) const;
+	
 	struct Scene *scene;             /* scene that this corresponds to */
 	TimeSourceDepsNode *time_source; /* entrypoint node for time-changed */
 	
@@ -134,6 +142,8 @@ struct IDDepsNode : public DepsNode {
 	void remove_component(eDepsNode_Type type);
 	void clear_components();
 	
+	void build_operations(const OperationBuilder &builder) const;
+	
 	void validate_links(Depsgraph *graph);
 	
 	void tag_update(Depsgraph *graph);
@@ -150,6 +160,8 @@ struct SubgraphDepsNode : public DepsNode {
 	void copy(DepsgraphCopyContext *dcc, const SubgraphDepsNode *src);
 	~SubgraphDepsNode();
 	
+	void build_operations(const OperationBuilder &builder) const;
+	
 	void validate_links(Depsgraph *graph);
 	
 	Depsgraph *graph;        /* instanced graph */
diff --git a/source/blender/depsgraph/intern/depsnode_component.cpp b/source/blender/depsgraph/intern/depsnode_component.cpp
index 0067c41..d9bfd8b 100644
--- a/source/blender/depsgraph/intern/depsnode_component.cpp
+++ b/source/blender/depsgraph/intern/depsnode_component.cpp
@@ -37,6 +37,7 @@ extern "C" {
 #include "depsnode_component.h" /* own include */
 #include "depsnode_operation.h"
 #include "depsgraph_intern.h"
+#include "depsgraph_build.h"
 
 #include "stubs.h" // XXX: THIS MUST BE REMOVED WHEN THE DEPSGRAPH REFACTOR IS DONE
 
@@ -141,36 +142,71 @@ void ComponentDepsNode::tag_update(Depsgraph *graph)
 
 /* Parameter Component Defines ============================ */
 
+void ParametersComponentDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	/* XXX TODO */
+}
+
 DEG_DEPSNODE_DEFINE(ParametersComponentDepsNode, DEPSNODE_TYPE_PARAMETERS, "Parameters Component");
 static DepsNodeFactoryImpl<ParametersComponentDepsNode> DNTI_PARAMETERS;
 
 /* Animation Component Defines ============================ */
 
+void AnimationComponentDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	/* XXX TODO */
+}
+
 DEG_DEPSNODE_DEFINE(AnimationComponentDepsNode, DEPSNODE_TYPE_ANIMATION, "Animation Component");
 static DepsNodeFactoryImpl<AnimationComponentDepsNode> DNTI_ANIMATION;
 
 /* Transform Component Defines ============================ */
 
+void TransformComponentDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	/* XXX TODO */
+}
+
 DEG_DEPSNODE_DEFINE(TransformComponentDepsNode, DEPSNODE_TYPE_TRANSFORM, "Transform Component");
 static DepsNodeFactoryImpl<TransformComponentDepsNode> DNTI_TRANSFORM;
 
 /* Proxy Component Defines ================================ */
 
+void ProxyComponentDepsNode::build_operations(const OperationBuilder &builder) const
+{
+	/* XXX TODO */
+}
+
 DEG_DEPSNODE_DEFINE(ProxyComponentDepsNode, DEPSNODE_TYPE_PROXY, "Proxy Component");
 static DepsNodeFactoryImpl<ProxyComponentDepsNode> DNTI_PROXY;
 
 /* Geometry Com

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list