[Bf-blender-cvs] [fee813c] depsgraph_refactor: Depsgraph: Code cleanup, de-duplicate some logging code

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


Commit: fee813cd226679df1125d9e296fec34d7f07dce1
Author: Sergey Sharybin
Date:   Mon Mar 16 18:14:12 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBfee813cd226679df1125d9e296fec34d7f07dce1

Depsgraph: Code cleanup, de-duplicate some logging code

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

M	source/blender/depsgraph/intern/depsnode.h
M	source/blender/depsgraph/intern/depsnode_operation.cpp
M	source/blender/depsgraph/intern/depsnode_operation.h
M	source/blender/depsgraph/util/depsgraph_util_cycle.cpp

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

diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index 25d04fb..8c153ec 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -86,6 +86,7 @@ struct DepsNode {
 	virtual ~DepsNode();
 
 	virtual string identifier() const;
+	string full_identifier() const;
 
 	virtual void init(const ID * /*id*/,
 	                  const string &/*subdata*/) {}
diff --git a/source/blender/depsgraph/intern/depsnode_operation.cpp b/source/blender/depsgraph/intern/depsnode_operation.cpp
index bfe374d..de8755f 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.cpp
+++ b/source/blender/depsgraph/intern/depsnode_operation.cpp
@@ -66,6 +66,21 @@ string OperationDepsNode::identifier() const
 	return string(DEG_OPNAMES[opcode]) + "(" + name + ")";
 }
 
+/* Full node identifier, including owner name.
+ * used for logging and debug prints.
+ */
+string OperationDepsNode::full_identifier() const
+{
+	string owner_str = "";
+	if (owner->type == DEPSNODE_TYPE_BONE) {
+		owner_str = owner->owner->name + "." + owner->name;
+	}
+	else {
+		owner_str = owner->owner->name;
+	}
+	return owner_str + "." + identifier();
+}
+
 void OperationDepsNode::tag_update(Depsgraph *graph)
 {
 	if (flag & DEPSOP_FLAG_NEEDS_UPDATE) {
diff --git a/source/blender/depsgraph/intern/depsnode_operation.h b/source/blender/depsgraph/intern/depsnode_operation.h
index 8990a1b..2b70ff0 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.h
+++ b/source/blender/depsgraph/intern/depsnode_operation.h
@@ -55,6 +55,7 @@ struct OperationDepsNode : public DepsNode {
 	~OperationDepsNode();
 
 	string identifier() const;
+	string full_identifier() const;
 
 	void tag_update(Depsgraph *graph);
 
diff --git a/source/blender/depsgraph/util/depsgraph_util_cycle.cpp b/source/blender/depsgraph/util/depsgraph_util_cycle.cpp
index aafad0b..255385d 100644
--- a/source/blender/depsgraph/util/depsgraph_util_cycle.cpp
+++ b/source/blender/depsgraph/util/depsgraph_util_cycle.cpp
@@ -45,37 +45,6 @@ struct StackEntry {
 	DepsRelation *via_relation;
 };
 
-static void deg_graph_print_cycle_rel(const OperationDepsNode *to,
-                                      const OperationDepsNode *from,
-                                      const DepsRelation *rel)
-{
-	string to_owner = "", from_owner = "";
-
-	/* NOTE: subdata name only matters for bones; all other components currently
-	 * should just use the ID instead.
-	 */
-	if (to->owner->type == DEPSNODE_TYPE_BONE) {
-		to_owner = to->owner->owner->name + "." + to->owner->name + ".";
-	}
-	else {
-		to_owner = to->owner->owner->name + ".";
-	}
-
-	if (from->owner->type == DEPSNODE_TYPE_BONE) {
-		from_owner = from->owner->owner->name + "." + from->owner->name + ".";
-	}
-	else {
-		from_owner = from->owner->owner->name + ".";
-	}
-
-	printf("  '%s%s' depends on '%s%s' through '%s'\n",
-	       to_owner.c_str(),
-	       to->identifier().c_str(),
-	       from_owner.c_str(),
-	       from->identifier().c_str(),
-	       rel->name.c_str());
-}
-
 void deg_graph_detect_cycles(Depsgraph *graph)
 {
 	/* Not is not visited at all during traversal. */
@@ -127,14 +96,18 @@ void deg_graph_detect_cycles(Depsgraph *graph)
 				OperationDepsNode *to = (OperationDepsNode *)rel->to;
 				if (to->done == NODE_IN_STACK) {
 					printf("Dependency cycle detected:\n");
-					deg_graph_print_cycle_rel(to, node, rel);
+					printf("  '%s' depends on '%s' through '%s'\n",
+					       to->full_identifier().c_str(),
+					       node->full_identifier().c_str(),
+					       rel->name.c_str());
 
 					StackEntry *current = &entry;
 					while (current->node != to) {
 						BLI_assert(current != NULL);
-						deg_graph_print_cycle_rel(current->node,
-						                          current->from->node,
-						                          current->via_relation);
+						printf("  '%s' depends on '%s' through '%s'\n",
+						       current->node->full_identifier().c_str(),
+						       current->from->node->full_identifier().c_str(),
+						       current->via_relation->name.c_str());
 						current = current->from;
 					}
 					/* TODO(sergey): So called roussian rlette cycle solver. */




More information about the Bf-blender-cvs mailing list