[Bf-blender-cvs] [21dc675] depsgraph_refactor: Depsgraph: Code cleanup, move functions to corresponding implementation files

Sergey Sharybin noreply at git.blender.org
Mon Mar 16 14:34:51 CET 2015


Commit: 21dc6752861178d440fe68db29ad203c101f0347
Author: Sergey Sharybin
Date:   Mon Mar 16 16:35:28 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rB21dc6752861178d440fe68db29ad203c101f0347

Depsgraph: Code cleanup, move functions to corresponding implementation files

Previously some utility functions for nodes and relations builder were
implemented in general builder file, which kept it a bit tricky to
keep track of the changes.

Now all nodes/relations builder functions are implemented in single file,
without spreading out across the whole filesystem.

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

M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M	source/blender/depsgraph/intern/depsgraph_build_relations.cpp

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index dc4ae34..a803309 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -67,7 +67,6 @@ extern "C" {
 #include "BKE_effect.h"
 #include "BKE_fcurve.h"
 #include "BKE_group.h"
-#include "BKE_idcode.h"
 #include "BKE_key.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
@@ -178,236 +177,6 @@ string deg_fcurve_id_name(const FCurve *fcu)
 	return string(fcu->rna_path) + index_buf;
 }
 
-/* ************************************************* */
-/* Node Builder */
-
-DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph) :
-    m_bmain(bmain),
-    m_graph(graph)
-{
-}
-
-DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
-{
-}
-
-RootDepsNode *DepsgraphNodeBuilder::add_root_node()
-{
-	return m_graph->add_root_node();
-}
-
-IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
-{
-	const char *idtype_name = BKE_idcode_to_name(GS(id->name));
-	return m_graph->add_id_node(id, string(id->name+2) + "[" + idtype_name + "]");
-}
-
-TimeSourceDepsNode *DepsgraphNodeBuilder::add_time_source(ID *id)
-{
-	/* determine which node to attach timesource to */
-	if (id) {
-#if 0 /* XXX TODO */
-		/* get ID node */
-		IDDepsNode id_node = m_graph->find_id_node(id);
-
-		/* depends on what this is... */
-		switch (GS(id->name)) {
-			case ID_SCE: /* Scene - Usually sequencer strip causing time remapping... */
-			{
-				// TODO...
-			}
-			break;
-
-			case ID_GR: /* Group */
-			{
-				// TODO...
-			}
-			break;
-
-			// XXX: time source...
-
-			default:     /* Unhandled */
-				printf("%s(): Unhandled ID - %s \n", __func__, id->name);
-				break;
-		}
-#endif
-	}
-	else {
-		/* root-node */
-		RootDepsNode *root_node = m_graph->root_node;
-		if (root_node) {
-			return root_node->add_time_source("Time Source");
-		}
-	}
-
-	return NULL;
-}
-
-ComponentDepsNode *DepsgraphNodeBuilder::add_component_node(ID *id, eDepsNode_Type comp_type, const string &comp_name)
-{
-	IDDepsNode *id_node = add_id_node(id);
-	ComponentDepsNode *comp_node = id_node->add_component(comp_type, comp_name);
-	comp_node->owner = id_node;
-	return comp_node;
-}
-
-OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ComponentDepsNode *comp_node,
-                                                            eDepsOperation_Type optype,
-                                                            DepsEvalOperationCb op,
-                                                            eDepsOperation_Code opcode,
-                                                            const string &description)
-{
-	OperationDepsNode *op_node = comp_node->has_operation(opcode, description);
-	if (op_node == NULL) {
-		op_node = comp_node->add_operation(optype, op, opcode, description);
-		m_graph->operations.push_back(op_node);
-	}
-	else {
-		fprintf(stderr, "add_operation: Operation already exists - %s has %s at %p\n",
-		        comp_node->identifier().c_str(),
-		        op_node->identifier().c_str(),
-		        op_node);
-		BLI_assert(!"Should not happen!");
-	}
-	return op_node;
-}
-
-OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ID *id,
-                                                            eDepsNode_Type comp_type,
-                                                            const string &comp_name,
-                                                            eDepsOperation_Type optype,
-                                                            DepsEvalOperationCb op,
-                                                            eDepsOperation_Code opcode,
-                                                            const string &description)
-{
-	ComponentDepsNode *comp_node = add_component_node(id, comp_type, comp_name);
-	return add_operation_node(comp_node, optype, op, opcode, description);
-}
-
-bool DepsgraphNodeBuilder::has_operation_node(ID *id,
-                                              eDepsNode_Type comp_type,
-                                              const string &comp_name,
-                                              eDepsOperation_Type optype,
-                                              eDepsOperation_Code opcode,
-                                              const string &description)
-{
-	return find_operation_node(id, comp_type, comp_name, optype, opcode, description) != NULL;
-}
-
-OperationDepsNode *DepsgraphNodeBuilder::find_operation_node(ID *id,
-                                                             eDepsNode_Type comp_type,
-                                                             const string &comp_name,
-                                                             eDepsOperation_Type optype,
-                                                             eDepsOperation_Code opcode,
-                                                             const string &description)
-{
-	ComponentDepsNode *comp_node = add_component_node(id, comp_type, comp_name);
-	return comp_node->has_operation(opcode, description);
-}
-
-/* ************************************************* */
-/* Relations Builder */
-
-RNAPathKey::RNAPathKey(ID *id, const string &path) :
-    id(id)
-{
-	/* create ID pointer for root of path lookup */
-	PointerRNA id_ptr;
-	RNA_id_pointer_create(id, &id_ptr);
-	/* try to resolve path... */
-	if (!RNA_path_resolve(&id_ptr, path.c_str(), &this->ptr, &this->prop)) {
-		this->ptr = PointerRNA_NULL;
-		this->prop = NULL;
-	}
-}
-
-DepsgraphRelationBuilder::DepsgraphRelationBuilder(Depsgraph *graph) :
-    m_graph(graph)
-{
-}
-
-RootDepsNode *DepsgraphRelationBuilder::find_node(const RootKey &key) const
-{
-	return m_graph->root_node;
-}
-
-TimeSourceDepsNode *DepsgraphRelationBuilder::find_node(const TimeSourceKey &key) const
-{
-	if (key.id) {
-		/* XXX TODO */
-		return NULL;
-	}
-	else {
-		return m_graph->root_node->time_source;
-	}
-}
-
-ComponentDepsNode *DepsgraphRelationBuilder::find_node(const ComponentKey &key) const
-{
-	IDDepsNode *id_node = m_graph->find_id_node(key.id);
-	if (!id_node) {
-		fprintf(stderr, "find_node component: Could not find ID %s\n",
-		        (key.id != NULL) ? key.id->name : "<null>");
-		return NULL;
-	}
-
-	ComponentDepsNode *node = id_node->find_component(key.type, key.name);
-	return node;
-}
-
-OperationDepsNode *DepsgraphRelationBuilder::find_node(const OperationKey &key) const
-{
-	IDDepsNode *id_node = m_graph->find_id_node(key.id);
-	if (!id_node) {
-		fprintf(stderr, "find_node operation: Could not find ID\n");
-		return NULL;
-	}
-
-	ComponentDepsNode *comp_node = id_node->find_component(key.component_type, key.component_name);
-	if (!comp_node) {
-		fprintf(stderr, "find_node operation: Could not find component\n");
-		return NULL;
-	}
-
-	OperationDepsNode *op_node = comp_node->find_operation(key.opcode, key.name);
-	if (!op_node) {
-		fprintf(stderr, "find_node_operation: Failed for (%s, '%s')\n", DEG_OPNAMES[key.opcode], key.name.c_str());
-	}
-	return op_node;
-}
-
-DepsNode *DepsgraphRelationBuilder::find_node(const RNAPathKey &key) const
-{
-	return m_graph->find_node_from_pointer(&key.ptr, key.prop);
-}
-
-void DepsgraphRelationBuilder::add_time_relation(TimeSourceDepsNode *timesrc, DepsNode *node_to, const string &description)
-{
-	if (timesrc && node_to) {
-		m_graph->add_new_relation(timesrc, node_to, DEPSREL_TYPE_TIME, description);
-	}
-	else {
-		DEG_DEBUG_PRINTF("add_time_relation(%p = %s, %p = %s, %s) Failed\n",
-		                 timesrc,   (timesrc) ? timesrc->identifier().c_str() : "<None>",
-		                 node_to,   (node_to) ? node_to->identifier().c_str() : "<None>",
-		                 description.c_str());
-	}
-}
-
-void DepsgraphRelationBuilder::add_operation_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
-                                                      eDepsRelation_Type type, const string &description)
-{
-	if (node_from && node_to) {
-		m_graph->add_new_relation(node_from, node_to, type, description);
-	}
-	else {
-		DEG_DEBUG_PRINTF("add_operation_relation(%p = %s, %p = %s, %d, %s) Failed\n",
-		                 node_from, (node_from) ? node_from->identifier().c_str() : "<None>",
-		                 node_to,   (node_to)   ? node_to->identifier().c_str() : "<None>",
-		                 type, description.c_str());
-	}
-}
-
 /* -------------------------------------------------- */
 
 /* performs a transitive reduction to remove redundant relations
@@ -564,34 +333,6 @@ static void deg_graph_build_finalize(Depsgraph *graph)
 	}
 }
 
-/* ************************************************* */
-/* Datablock User Relationships Builder */
-
-DepsgraphIDUsersBuilder::DepsgraphIDUsersBuilder(Depsgraph *graph) :
-    m_graph(graph)
-{
-}
-
-
-void DepsgraphIDUsersBuilder::add_relation(const ID *from_id, const ID *to_id,
-	                                       eDepsRelation_Type type, const string &description)
-{
-	IDDepsNode *node_from = m_graph->find_id_node(from_id);
-	IDDepsNode *node_to = m_graph->find_id_node(to_id);
-
-	if (node_from && node_to) {
-		m_graph->add_new_relation(node_from, node_to, type, description);
-	}
-	else {
-		fprintf(stderr, "ID Builder add_relation(%s => %s, %s => %s, %d, %s) Failed\n",
-		        (from_id) ? from_id->name : "<No ID>",
-		        (node_from) ? node_from->identifier().c_str() : "<None>",
-		        (to_id) ? to_id->name : "<No ID>",
-		        (node_to)   ? node_to->identifier().c_str() : "<None>",
-		        type, description.c_str());
-	}
-}
-
 /* *************** */
 /* Cycle detection */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp b/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
index 3c03e6f..d5faa1c 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
@@ -107,6 +107,31 @@ extern "C" {
  *       For example, "ob.data" becomes "obdata -> object"
  */
 
+DepsgraphIDUsersBuilder::DepsgraphIDUsersBuilder(Depsgraph *graph) :
+    m_graph(graph)
+{
+}
+
+
+void DepsgraphIDUsersBuilder::add_relation(const ID *from_id, const ID *to_id,
+	                    

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list