Commit: 85c162b475bd2d049a054636e15a14589b79f0c7
Author: Joshua Leung
Date:   Tue Dec 16 15:18:47 2014 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB85c162b475bd2d049a054636e15a14589b79f0c7

Added methods to give useful identifiers for nodes

* All basic nodes now use an identifier string defined in DepsNode,
  which gives the node type and the name of the node (if present)
* Operation nodes now report the operation opcode (human readable)
  as well as the name (if present)

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

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_operation.cpp
M       source/blender/depsgraph/intern/depsnode_operation.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build.h 
b/source/blender/depsgraph/intern/depsgraph_build.h
index e586ff5..368a275 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -256,10 +256,7 @@ struct DepsNodeHandle {
 BLI_INLINE string get_node_info_string(DepsNode *node)
 {
        if (node != NULL) {
-               char typebuf[5];
-               sprintf(typebuf, "%d", node->type);
-               
-               return string("Node(") + typebuf + ", " + node->name + ")";
+               return node->identifier();
        }
        else {
                return string("<No Node>");
diff --git a/source/blender/depsgraph/intern/depsnode.cpp 
b/source/blender/depsgraph/intern/depsnode.cpp
index f623b78..405548a 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -25,6 +25,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "BLI_utildefines.h"
 
@@ -65,6 +66,15 @@ DepsNode::~DepsNode()
 }
 
 
+/* Generic identifier for Depsgraph Nodes */
+string DepsNode::identifier()
+{
+       char typebuf[5];
+       sprintf(typebuf, "%d", type);
+       
+       return string("Node(") + "t: " + typebuf + ", n: '" + name + "')";
+}
+
 /* ******************************************************** */
 /* Generic Nodes */
 
diff --git a/source/blender/depsgraph/intern/depsnode.h 
b/source/blender/depsgraph/intern/depsnode.h
index 346e2bf..e80541c 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -68,6 +68,8 @@ public:
        DepsNode();
        virtual ~DepsNode();
        
+       virtual string identifier();
+       
        virtual void init(const ID *id, const string &subdata) {}
        virtual void copy(DepsgraphCopyContext *dcc, const DepsNode *src) {}
        
diff --git a/source/blender/depsgraph/intern/depsnode_operation.cpp 
b/source/blender/depsgraph/intern/depsnode_operation.cpp
index 8df9abc..9d06f8e 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.cpp
+++ b/source/blender/depsgraph/intern/depsnode_operation.cpp
@@ -62,6 +62,21 @@ OperationDepsNode::~OperationDepsNode()
        DEPSNODE_RELATIONS_ITER_END;
 }
 
+string OperationDepsNode::identifier()
+{
+       /* identifiers for operations */
+       const char *DEG_OPNAMES[] = {
+               #define DEF_DEG_OPCODE(label) #label,
+               #include "depsnode_opcodes.h"
+               #undef DEF_DEG_OPCODE
+               
+               "<Invalid>"
+       };
+       
+       BLI_assert((opcode > 0) && (opcode < ARRAY_SIZE(DEG_OPNAMES)));
+       return string(DEG_OPNAMES[opcode]) + "(" + name + ")";
+}
+
 void OperationDepsNode::tag_update(Depsgraph *graph)
 {
        /* tag for update, but also note that this was the source of an update 
*/
diff --git a/source/blender/depsgraph/intern/depsnode_operation.h 
b/source/blender/depsgraph/intern/depsnode_operation.h
index 0441edf..63ff10f 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.h
+++ b/source/blender/depsgraph/intern/depsnode_operation.h
@@ -67,6 +67,8 @@ struct OperationDepsNode : public DepsNode {
        OperationDepsNode();
        ~OperationDepsNode();
        
+       string identifier();
+       
        void tag_update(Depsgraph *graph);
        
        bool is_noop() const { return (bool)evaluate == false; }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to