Commit: 7a1a29ab5d6d4317f23609818648f3a8ccad7320
Author: Joshua Leung
Date:   Wed Dec 17 16:12:42 2014 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB7a1a29ab5d6d4317f23609818648f3a8ccad7320

Convenience API's and debugging funcs for all "keys" used when building the 
graph

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

M       source/blender/depsgraph/intern/depsgraph_build.cpp
M       source/blender/depsgraph/intern/depsgraph_build.h
M       source/blender/depsgraph/intern/depsnode_component.cpp
M       source/blender/depsgraph/intern/depsnode_component.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp 
b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 47d20cb..7f6e2aa 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -311,13 +311,6 @@ RNAPathKey::RNAPathKey(ID *id, const string &path) :
        }
 }
 
-RNAPathKey::RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop) :
-    id(id),
-    ptr(ptr),
-    prop(prop)
-{
-}
-
 DepsgraphRelationBuilder::DepsgraphRelationBuilder(Depsgraph *graph) :
     m_graph(graph)
 {
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h 
b/source/blender/depsgraph/intern/depsgraph_build.h
index bbeb9d3b..00c15a2 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -122,13 +122,32 @@ struct TimeSourceKey
        TimeSourceKey() : id(NULL) {}
        TimeSourceKey(ID *id) : id(id) {}
        
+       string identifier() const
+       {
+               return string("TimeSourceKey");
+       }
+       
        ID *id;
 };
 
 struct ComponentKey
 {
-       ComponentKey() : id(NULL), type(DEPSNODE_TYPE_UNDEFINED), name("") {}
-       ComponentKey(ID *id, eDepsNode_Type type, const string &name = "") : 
id(id), type(type), name(name) {}
+       ComponentKey() :
+           id(NULL), type(DEPSNODE_TYPE_UNDEFINED), name("")
+       {}
+       ComponentKey(ID *id, eDepsNode_Type type, const string &name = "") :
+           id(id), type(type), name(name)
+       {}
+       
+       string identifier() const
+       {
+               const char *idname = (id) ? id->name : "<None>";
+               
+               char typebuf[5];
+               sprintf(typebuf, "%d", type);
+               
+               return string("ComponentKey(") + idname + ", " + typebuf + ", 
'" + name + "')";
+       }
        
        ID *id;
        eDepsNode_Type type;
@@ -162,6 +181,16 @@ struct OperationKey
            id(id), component_type(component_type), 
component_name(component_name), opcode(opcode), name(name)
        {}
        
+       string identifier() const
+       {
+               char typebuf[5], codebuf[5];
+               
+               sprintf(typebuf, "%d", component_type);
+               sprintf(codebuf, "%d", opcode); // XXX: use the string defs 
instead
+               
+               return string("OperationKey(") + "t: " + typebuf + ", cn: '" + 
component_name + "', c: " + codebuf + ", n: '" + name + "')";
+       }
+       
        
        ID *id;
        eDepsNode_Type component_type;
@@ -172,8 +201,14 @@ struct OperationKey
 
 struct RNAPathKey
 {
+       // Note: see depsgraph_build.cpp for implementation
        RNAPathKey(ID *id, const string &path);
-       RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop);
+       
+       RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop) :
+           id(id), ptr(ptr), prop(prop)
+       {}
+       
+       
        ID *id;
        PointerRNA ptr;
        PropertyRNA *prop;
diff --git a/source/blender/depsgraph/intern/depsnode_component.cpp 
b/source/blender/depsgraph/intern/depsnode_component.cpp
index 718209e..860e448 100644
--- a/source/blender/depsgraph/intern/depsnode_component.cpp
+++ b/source/blender/depsgraph/intern/depsnode_component.cpp
@@ -97,12 +97,24 @@ string ComponentDepsNode::identifier() const
        return string("Component(") + idname + " - " + typebuf + " " + 
name.c_str() + ")";
 }
 
+OperationDepsNode *ComponentDepsNode::find_operation(OperationIDKey key) const
+{
+       OperationMap::const_iterator it = this->operations.find(key);
+       
+       if (it != this->operations.end()) {
+               return it->second;
+       }
+       else {
+               fprintf(stderr, "%s: find_operation(%s) failed\n",
+                       this->identifier().c_str(), key.identifier().c_str());
+               return NULL;
+       }
+}
+
 OperationDepsNode *ComponentDepsNode::find_operation(eDepsOperation_Code 
opcode, const string &name) const
 {
        OperationIDKey key(opcode, name);
-       
-       OperationMap::const_iterator it = this->operations.find(key);
-       return (it != this->operations.end()) ? it->second : NULL;
+       return find_operation(key);
 }
 
 OperationDepsNode *ComponentDepsNode::add_operation(eDepsOperation_Type 
optype, DepsEvalOperationCb op, eDepsOperation_Code opcode, const string &name)
diff --git a/source/blender/depsgraph/intern/depsnode_component.h 
b/source/blender/depsgraph/intern/depsnode_component.h
index 30e5a22..f892a7e 100644
--- a/source/blender/depsgraph/intern/depsnode_component.h
+++ b/source/blender/depsgraph/intern/depsnode_component.h
@@ -102,6 +102,7 @@ struct ComponentDepsNode : public DepsNode {
        
        string identifier() const;
        
+       OperationDepsNode *find_operation(OperationIDKey key) const;
        OperationDepsNode *find_operation(eDepsOperation_Code opcode, const 
string &name) const;
        
        /* Create a new node for representing an operation and add this to graph

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

Reply via email to