[Bf-blender-cvs] [496cf09] depsgraph_refactor: Fix incomplete info for operation keys.

Lukas Tönne noreply at git.blender.org
Wed Apr 9 08:06:43 CEST 2014


Commit: 496cf09718cd85ade18a0453bc44cb5f1b8cda92
Author: Lukas Tönne
Date:   Wed Apr 9 07:55:51 2014 +0200
https://developer.blender.org/rB496cf09718cd85ade18a0453bc44cb5f1b8cda92

Fix incomplete info for operation keys.

Operations are stored by name keys (multiple operations of the same type
can exist in the same component, currently e.g. in rigid body components
using multiple world build/sync operations). To keep name strings
manageable for now use string constants for the existing operations,
instead of literals used only in the build methods (compiler then helps
avoid mismatches).

Every operation type is also directly associated to a specific component
type. This was previously done only implicitly via the add_to_graph
functions. Now the associated component type is directly accessible from
node factory type information, so we can use a simple id+operation name
key when building the graph, and don't need hidden factorization inside
the graph->find_node method (deprecated code to be removed later).

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

M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_intern.h
M	source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M	source/blender/depsgraph/intern/depsgraph_types.h
M	source/blender/depsgraph/intern/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode.h
M	source/blender/depsgraph/intern/depsnode_operation.cpp
M	source/blender/depsgraph/intern/depsnode_operation.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 96d1447..23faee8 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -398,7 +398,7 @@ void DepsgraphNodeBuilder::build_constraints(ComponentDepsNode *comp_node, eDeps
 	/* create node for constraint stack */
 	add_operation_node(comp_node, constraint_op_type, 
 	                   DEPSOP_TYPE_EXEC, BKE_constraints_evaluate,
-	                   "Constraint Stack");
+	                   DEPSNODE_OP_NAME_CONSTRAINT_STACK);
 }
 
 void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
@@ -451,10 +451,13 @@ OperationDepsNode *DepsgraphRelationBuilder::find_node(const OperationKey &key)
 	if (!id_node)
 		return NULL;
 	
-#if 0 /* XXX TODO! */
-	ComponentDepsNode *node = id_node->find_component(key.type);
-	return node;
-#endif
+	DepsNodeFactory *factory = DEG_get_node_factory(key.type);
+	ComponentDepsNode *comp_node = id_node->find_component(factory->component_type());
+	if (!comp_node)
+		return NULL;
+	
+	OperationDepsNode *op_node = comp_node->find_operation(key.name);
+	return op_node;
 }
 
 void DepsgraphRelationBuilder::add_node_relation(DepsNode *node_from, DepsNode *node_to,
@@ -646,7 +649,7 @@ void DepsgraphRelationBuilder::build_object_parent(Object *ob)
 void DepsgraphRelationBuilder::build_constraints(Scene *scene, IDPtr id, eDepsNode_Type constraint_op_type,
                                                  ListBase *constraints)
 {
-	OperationKey constraint_op_key(id, constraint_op_type);
+	OperationKey constraint_op_key(id, constraint_op_type, DEPSNODE_OP_NAME_CONSTRAINT_STACK);
 	
 	/* add dependencies for each constraint in turn */
 	for (bConstraint *con = (bConstraint *)constraints->first; con; con = con->next) {
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index a27255f..b21948e 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -88,9 +88,10 @@ struct ComponentKey
 
 struct OperationKey
 {
-	OperationKey(IDPtr id, eDepsNode_Type type) : id(id), type(type) {}
+	OperationKey(IDPtr id, eDepsNode_Type type, const string &name) : id(id), type(type), name(name) {}
 	IDPtr id;
 	eDepsNode_Type type;
+	string name;
 };
 
 struct DepsgraphRelationBuilder {
diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h
index db42d03..13ced33 100644
--- a/source/blender/depsgraph/intern/depsgraph_intern.h
+++ b/source/blender/depsgraph/intern/depsgraph_intern.h
@@ -112,6 +112,7 @@ struct DepsNodeFactory {
 	virtual eDepsNode_Type type() const = 0;
 	virtual eDepsNode_Class tclass() const = 0;
 	virtual const string &tname() const = 0;
+	virtual eDepsNode_Type component_type() const = 0;
 	
 	virtual DepsNode *create_node(const ID *id, const string &subdata, const string &name) const = 0;
 	virtual DepsNode *copy_node(DepsgraphCopyContext *dcc, const DepsNode *copy) const = 0;
@@ -122,6 +123,7 @@ struct DepsNodeFactoryImpl : public DepsNodeFactory {
 	eDepsNode_Type type() const { return NodeType::typeinfo.type; }
 	eDepsNode_Class tclass() const { return NodeType::typeinfo.tclass; }
 	const string &tname() const { return NodeType::typeinfo.tname; }
+	eDepsNode_Type component_type() const { return NodeType::typeinfo.component_type; }
 	
 	DepsNode *create_node(const ID *id, const string &subdata, const string &name) const
 	{
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index 90f0f1d..f91e785 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -56,6 +56,8 @@ extern "C" {
 #include "depsnode_component.h"
 #include "depsnode_operation.h"
 
+#include "depsgraph_util_map.h"
+
 #include "stubs.h" // XXX: THIS MUST BE REMOVED WHEN THE DEPSGRAPH REFACTOR IS DONE
 
 void BKE_animsys_eval_driver(void *context, void *item) {}
@@ -84,6 +86,8 @@ void BKE_curve_eval_geometry(void *context, void *item) {}
 void BKE_curve_eval_path(void *context, void *item) {}
 void BKE_lattice_eval_geometry(void *context, void *item) {}
 
+const char *DEPSNODE_OP_NAME_CONSTRAINT_STACK = "Constraint Stack";
+
 /* ******************************************************** */
 /* External API */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 3680036..4a82863 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -51,6 +51,8 @@ typedef enum eDepsNode_Class {
 
 /* Types of Nodes */
 typedef enum eDepsNode_Type {
+	DEPSNODE_TYPE_UNDEFINED        = -1,       /* fallback type for invalid return value */
+	
 	/* Generic Types */
 	DEPSNODE_TYPE_ROOT             = 0,        /* "Current Scene" - basically whatever kicks off the evaluation process */
 	DEPSNODE_TYPE_TIMESOURCE       = 1,        /* Time-Source */
@@ -91,6 +93,12 @@ typedef enum eDepsNode_Type {
 	DEPSNODE_TYPE_OP_RIGIDBODY     = 121,      /* Rigidbody Sim (Step) Evaluation */
 } eDepsNode_Type;
 
+/* Standard operation names */
+/* XXX this needs to be revisited, probably operation types could be
+ * combined in a concise struct with name+callback+eDepsOperation_Type
+ */
+extern const char *DEPSNODE_OP_NAME_CONSTRAINT_STACK;
+
 /* Type of operation */
 typedef enum eDepsOperation_Type {
 	/* Primary operation types */
diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index b3f378e..24658ae 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -44,16 +44,17 @@ extern "C" {
 
 /* Add ------------------------------------------------ */
 
-DepsNode::TypeInfo::TypeInfo(eDepsNode_Type type_, const string &tname_)
+DepsNode::TypeInfo::TypeInfo(eDepsNode_Type type, const string &tname, eDepsNode_Type component_type)
 {
-	this->type = type_;
-	if (type_ < DEPSNODE_TYPE_PARAMETERS)
+	this->type = type;
+	if (type < DEPSNODE_TYPE_PARAMETERS)
 		this->tclass = DEPSNODE_CLASS_GENERIC;
-	else if (type_ < DEPSNODE_TYPE_OP_PARAMETER)
+	else if (type < DEPSNODE_TYPE_OP_PARAMETER)
 		this->tclass = DEPSNODE_CLASS_COMPONENT;
 	else
 		this->tclass = DEPSNODE_CLASS_OPERATION;
-	this->tname = tname_;
+	this->tname = tname;
+	this->component_type = component_type;
 }
 
 DepsNode::DepsNode()
diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index 73ed9fe..fdb92ce 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -75,11 +75,12 @@ typedef enum eDepsNode_Flag {
 struct DepsNode {
 	/* Helper class for static typeinfo in subclasses */
 	struct TypeInfo {
-		TypeInfo(eDepsNode_Type type, const string &tname);
+		TypeInfo(eDepsNode_Type type, const string &tname, eDepsNode_Type component_type = DEPSNODE_TYPE_UNDEFINED);
 		
 		eDepsNode_Type type;
 		eDepsNode_Class tclass;
 		string tname;
+		eDepsNode_Type component_type; /*< associated component type for operations */
 	};
 	
 	typedef unordered_set<DepsRelation *> Relations;
diff --git a/source/blender/depsgraph/intern/depsnode_operation.cpp b/source/blender/depsgraph/intern/depsnode_operation.cpp
index ed75af1..a96753a 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.cpp
+++ b/source/blender/depsgraph/intern/depsnode_operation.cpp
@@ -79,7 +79,7 @@ void ParametersOperationDepsNode::add_to_graph(Depsgraph *graph, const ID *id)
 	add_to_component_node(graph, id, DEPSNODE_TYPE_PARAMETERS);
 }
 
-DEG_DEPSNODE_DEFINE(ParametersOperationDepsNode, DEPSNODE_TYPE_OP_PARAMETER, "Parameters Operation");
+DEG_DEPSNODE_OP_DEFINE(ParametersOperationDepsNode, DEPSNODE_TYPE_OP_PARAMETER, DEPSNODE_TYPE_PARAMETERS, "Parameters Operation");
 static DepsNodeFactoryImpl<ParametersOperationDepsNode> DNTI_OP_PARAMETERS;
 
 /* Proxy Operation ======================================== */
@@ -90,7 +90,7 @@ void ProxyOperationDepsNode::add_to_graph(Depsgraph *graph, const ID *id)
 	add_to_component_node(graph, id, DEPSNODE_TYPE_PROXY);
 }
 
-DEG_DEPSNODE_DEFINE(ProxyOperationDepsNode, DEPSNODE_TYPE_OP_PROXY, "Proxy Operation");
+DEG_DEPSNODE_OP_DEFINE(ProxyOperationDepsNode, DEPSNODE_TYPE_OP_PROXY, DEPSNODE_TYPE_PROXY, "Proxy Operation");
 static DepsNodeFactoryImpl<ProxyOperationDepsNode> DNTI_OP_PROXY;
 
 /* Animation Operation ==================================== */
@@ -101,7 +101,7 @@ void AnimationOperationDepsNode::add_to_graph(Depsgraph *graph, const ID *id)
 	add_to_component_node(graph, id, DEPSNODE_TYPE_ANIMATION);
 }
 
-DEG_DEPSNODE_DEFINE(AnimationOperationDepsNode, DEPSNODE_TYPE_OP_ANIMATION, "Animation Operation");
+DEG_DEPSNODE_OP_DEFINE(AnimationOperationDepsNode, DEPSNODE_TYPE_OP_ANIMATION, DEPSNODE_TYPE_ANIMATION, "Animation Operation");
 static DepsNodeFactoryImpl<AnimationOperationDepsNode> DNTI_OP_ANIMATION;
 
 /* Transform Operation ==================================== */
@@ -112,7 +112,7 @@ void TransformOperationDepsNode::add_to_graph(Depsgraph *graph, const ID *id)
 	add_to_component_node(graph, id, DEPSNODE_TYPE_TRANSFORM);
 }
 
-DEG_DEPSNODE_DEFINE(TransformOperationDepsNode, DEPSNODE_TYPE_OP_TRANSFORM, "Transform Operation");
+DEG_DEPSNODE_OP_DEFINE(TransformOperationDepsNode, DEPSNODE_TYPE_OP_TRANSFORM, DEPSNODE_TYPE_TRANSFORM, "Transform Operation");
 static DepsNodeFactoryImpl<TransformOperationDepsNode> DNTI_OP_TRANSFORM;
 
 /* Geometry Operation ===================================== */
@@ -123,7 +123,7 @@ void GeometryOperationDepsNode::add_to_graph(Depsgraph *graph, const ID *id)
 	add_to_component_node(graph, id, DEPSNODE_TYPE_GEOMETRY);
 }
 
-DEG_DEPSNODE_DEFINE(GeometryOperationDepsNode, DEPSNODE_TYPE_OP_GEOMETRY, "Geometry Operation");
+DEG_DEPSNODE_OP_DEFINE(GeometryOperationDepsNode, DEPSNODE_TYPE_OP_GEOMETRY, DEPSNODE_TYPE_GEOMETRY, "Geometry Operation");
 static DepsNodeFactoryImpl<GeometryOperationDepsNode> DNTI_OP_GEOMETRY;
 
 /* Sequencer 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list