[Bf-blender-cvs] [f0c8b4e] depsgraph_refactor: Removing operation node types from the node type enum, using only the identifier strings.

Lukas Tönne noreply at git.blender.org
Fri Jun 13 08:54:32 CEST 2014


Commit: f0c8b4e4f59cfc62991a7f73a3e5f012db3e0007
Author: Lukas Tönne
Date:   Thu Jun 12 08:18:28 2014 +0200
https://developer.blender.org/rBf0c8b4e4f59cfc62991a7f73a3e5f012db3e0007

Removing operation node types from the node type enum, using only the
identifier strings.

This typing was already redundant, since operations are primarily
identified by their name string. Having to pass a type enum in addition
makes it more complicated and requires taking care of the component type
association as well, without adding any real benefit.

Operations could be defined in a more compact way in a central place
though (essentially using duck-typing).

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

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/depsgraph_build_nodes.cpp
M	source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M	source/blender/depsgraph/intern/depsgraph_debug.cpp
M	source/blender/depsgraph/intern/depsgraph_eval.cpp
M	source/blender/depsgraph/intern/depsgraph_intern.h
M	source/blender/depsgraph/intern/depsgraph_query.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_component.cpp
M	source/blender/depsgraph/intern/depsnode_component.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.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index 4456400..5e7cee9 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -60,55 +60,73 @@ Depsgraph::~Depsgraph()
 
 /* Query Conditions from RNA ----------------------- */
 
-/* Determine node-querying criteria for finding a suitable node,
- * given a RNA Pointer (and optionally, a property too)
- */
-static void find_node_criteria_from_pointer(const PointerRNA *ptr, const PropertyRNA *prop,
-                                            ID **id, string *subdata,
-                                            eDepsNode_Type *type, string *name)
+static bool pointer_to_id_node_criteria(const PointerRNA *ptr, const PropertyRNA *prop,
+                                        ID **id)
+{
+	if (!prop) {
+		if (RNA_struct_is_ID(ptr->type)) {
+			*id = (ID *)ptr->data;
+			return true;
+		}
+	}
+	
+	return false;
+}
+
+static bool pointer_to_component_node_criteria(const PointerRNA *ptr, const PropertyRNA *prop,
+                                               ID **id,
+                                               eDepsNode_Type *type, string *subdata)
 {
 	/* set default values for returns */
-	*id       = (ID *)ptr->id.data;        /* for obvious reasons... */
-	*subdata  = "";                        /* default to no subdata (e.g. bone) name lookup in most cases */
-	*type     = DEPSNODE_TYPE_PARAMETERS;  /* all unknown data effectively falls under "parameter evaluation" */
-	*name     = "";                        /* default to no name to lookup in most cases */
+	*id        = (ID *)ptr->id.data;        /* for obvious reasons... */
+	*subdata   = "";                        /* default to no subdata (e.g. bone) name lookup in most cases */
 	
 	/* handling of commonly known scenarios... */
 	if (ptr->type == &RNA_PoseBone) {
 		bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-		
 		/* bone - generally, we just want the bone component... */
 		*type = DEPSNODE_TYPE_BONE;
 		*subdata = pchan->name;
+		return true;
 	}
 	else if (ptr->type == &RNA_Object) {
 		Object *ob = (Object *)ptr->data;
-		
 		/* transforms props? */
 		// ...
 	}
 	else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
 		Sequence *seq = (Sequence *)ptr->data;
-		
 		/* sequencer strip */
 		*type = DEPSNODE_TYPE_SEQUENCER;
 		*subdata = seq->name; // xxx?
+		return true;
 	}
+	else if (prop) {
+		*type = DEPSNODE_TYPE_PARAMETERS;  /* all unknown data effectively falls under "parameter evaluation" */
+		return true;
+	}
+	
+	return false;
 }
 
 /* Convenience wrapper to find node given just pointer + property */
-DepsNode *Depsgraph::find_node_from_pointer(const PointerRNA *ptr, const PropertyRNA *prop)
+DepsNode *Depsgraph::find_node_from_pointer(const PointerRNA *ptr, const PropertyRNA *prop) const
 {
 	ID *id;
 	eDepsNode_Type type;
-	string subdata;
 	string name;
 	
 	/* get querying conditions */
-	find_node_criteria_from_pointer(ptr, prop, &id, &subdata, &type, &name);
+	if (pointer_to_id_node_criteria(ptr, prop, &id)) {
+		return find_id_node(id);
+	}
+	else if (pointer_to_component_node_criteria(ptr, prop, &id, &type, &name)) {
+		IDDepsNode *id_node = find_id_node(id);
+		if (id_node)
+			return id_node->find_component(type, name);
+	}
 	
-	/* use standard node finding code... */
-	return find_node(id, subdata, type, name);
+	return NULL;
 }
 
 /* Node Management ---------------------------- */
@@ -122,6 +140,28 @@ RootDepsNode *Depsgraph::add_root_node()
 	return root_node;
 }
 
+TimeSourceDepsNode *Depsgraph::find_time_source(const ID *id) const
+{
+	/* search for one attached to a particular ID? */
+	if (id) {
+		/* check if it was added as a component 
+		 * (as may be done for subgraphs needing timeoffset) 
+		 */
+		IDDepsNode *id_node = find_id_node(id);
+		
+		if (id_node) {
+			// XXX: review this
+//			return id_node->find_component(DEPSNODE_TYPE_TIMESOURCE);
+		}
+	}
+	else {
+		/* use "official" timesource */
+		return root_node->time_source;
+	}
+	
+	return NULL;
+}
+
 SubgraphDepsNode *Depsgraph::add_subgraph_node(const ID *id)
 {
 	DepsNodeFactory *factory = DEG_get_node_factory(DEPSNODE_TYPE_SUBGRAPH);
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index cd54c33..cfe7faf 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -114,7 +114,7 @@ struct Depsgraph {
 	 * > returns: A node matching the required characteristics if it exists
 	 *            OR NULL if no such node exists in the graph
 	 */
-	DepsNode *find_node(const ID *id, const string &subdata, eDepsNode_Type type, const string &name);
+	DepsNode *find_node(const ID *id, eDepsNode_Type type, const string &subdata, const string &name);
 	/* Convenience wrapper to find node given just pointer + property
 	 * < ptr: pointer to the data that node will represent
 	 * < (prop): optional property affected - providing this effectively results in inner nodes being returned
@@ -122,10 +122,12 @@ struct Depsgraph {
 	 * > returns: A node matching the required characteristics if it exists
 	 *            OR NULL if no such node exists in the graph
 	 */
-	DepsNode *find_node_from_pointer(const PointerRNA *ptr, const PropertyRNA *prop);
+	DepsNode *find_node_from_pointer(const PointerRNA *ptr, const PropertyRNA *prop) const;
 	
 	RootDepsNode *add_root_node();
 	
+	TimeSourceDepsNode *find_time_source(const ID *id = NULL) const;
+	
 	SubgraphDepsNode *add_subgraph_node(const ID *id);
 	void remove_subgraph_node(SubgraphDepsNode *subgraph_node);
 	void clear_subgraph_nodes();
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 6c46edb..886027f 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -216,20 +216,19 @@ ComponentDepsNode *DepsgraphNodeBuilder::add_component_node(IDDepsNode *id_node,
 	return comp_node;
 }
 
-OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ComponentDepsNode *comp_node, eDepsNode_Type type,
+OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ComponentDepsNode *comp_node,
                                                             eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description)
 {
-	OperationDepsNode *op_node = comp_node->add_operation(type, optype, op, description);
+	OperationDepsNode *op_node = comp_node->add_operation(optype, op, description);
 	m_graph->operations.push_back(op_node);
 	return op_node;
 }
 
-OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(IDDepsNode *id_node, eDepsNode_Type type,
+OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(IDDepsNode *id_node, eDepsNode_Type comp_type,
                                                             eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description)
 {
-	DepsNodeFactory *factory = DEG_get_node_factory(type);
-	ComponentDepsNode *comp_node = id_node->add_component(factory->component_type());
-	OperationDepsNode *op_node = comp_node->add_operation(type, optype, op, description);
+	ComponentDepsNode *comp_node = id_node->add_component(comp_type);
+	OperationDepsNode *op_node = comp_node->add_operation(optype, op, description);
 	
 	m_graph->operations.push_back(op_node);
 	
@@ -263,7 +262,7 @@ void DepsgraphNodeBuilder::verify_entry_exit_operations(ComponentDepsNode *node)
 	}
 	else if (entry_ops.size() > 1) {
 		/* multiple entry ops, add a barrier node as a single entry point */
-		node->entry_operation = add_operation_node(node, DEPSNODE_TYPE_OP_NOOP, DEPSOP_TYPE_INIT, NULL, "Entry");
+		node->entry_operation = add_operation_node(node, DEPSOP_TYPE_INIT, NULL, "Entry");
 		for (OperationsVector::const_iterator it = entry_ops.begin(); it != entry_ops.end(); ++it) {
 			OperationDepsNode *op_node = *it;
 			m_graph->add_new_relation(node->entry_operation, op_node, DEPSREL_TYPE_OPERATION, "Component entry relation");
@@ -276,7 +275,7 @@ void DepsgraphNodeBuilder::verify_entry_exit_operations(ComponentDepsNode *node)
 	}
 	else if (exit_ops.size() > 1) {
 		/* multiple exit ops, add a barrier node as a single exit point */
-		node->exit_operation = add_operation_node(node, DEPSNODE_TYPE_OP_NOOP, DEPSOP_TYPE_OUT, NULL, "Exit");
+		node->exit_operation = add_operation_node(node, DEPSOP_TYPE_OUT, NULL, "Exit");
 		for (OperationsVector::const_iterator it = exit_ops.begin(); it != exit_ops.end(); ++it) {
 			OperationDepsNode *op_node = *it;
 			m_graph->add_new_relation(op_node, node->exit_operation, DEPSREL_TYPE_OPERATION, "Component exit relation");
@@ -355,8 +354,7 @@ OperationDepsNode *DepsgraphRelationBuilder::find_node(const OperationKey &key)
 	if (!id_node)
 		return NULL;
 	
-	DepsNodeFactory *factory = DEG_get_node_factory(key.type);
-	ComponentDepsNode *comp_node = id_node->find_component(factory->component_type(), key.component_name);
+	ComponentDepsNode *comp_node = id_node->find_component(key.component_type, key.component_name);
 	if (!comp_node)
 		return NULL;
 	
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 68131c7..9d964ef 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -67,9 +67,9 @@ struct DepsgraphNodeBuilder {
 	IDDepsNode *add_id_node(IDPtr id);
 	TimeSourceDepsNode *add_time_source(IDPtr id);
 	ComponentDepsNode *add_component_node(IDDepsNode *id_node, eDepsNode_Type comp_type, const string &comp_name = "");
-	OperationDepsNode *add_operation_node(ComponentDepsNode *comp_node, eDepsNode_Type type,
+	OperationDepsNode *add_operation_node(ComponentDepsNode *comp_node,
 	                                      eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description);
-	OperationDepsNode *add_operation_node(IDDepsNode *id_node, eDepsNode_Type type,
+	OperationDepsNode *add_operation_node(IDDepsNode *id_node, eDepsNode_Type comp_type,
 	                                      eDepsOperation_Type optype, DepsEvalOperationCb op, cons

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list