[Bf-blender-cvs] [b87a071] depsgraph_refactor: Depsgraph: Move get entry/exit operations to node
Sergey Sharybin
noreply at git.blender.org
Wed Jan 14 14:48:23 CET 2015
Commit: b87a0719d1a3ffb7f0772047db8006bb20b9ed43
Author: Sergey Sharybin
Date: Wed Jan 14 17:15:28 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBb87a0719d1a3ffb7f0772047db8006bb20b9ed43
Depsgraph: Move get entry/exit operations to node
This way we've got a bit less template magic going on and make it possible
to cleanly access entry/exit operation of nodes outside of the builders.
===================================================================
M source/blender/depsgraph/intern/depsgraph_build.h
M source/blender/depsgraph/intern/depsgraph_build_relations.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.h
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 648d4b8..baf0366 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -308,57 +308,16 @@ struct DepsNodeHandle
/* Get unique identifier for FCurves and Drivers */
string deg_fcurve_id_name(const FCurve *fcu);
-/* Inline Function Templates -------------------------------------------------- */
-
-#include "depsnode_component.h"
-
-template <class NodeType>
-BLI_INLINE OperationDepsNode *get_entry_operation(NodeType *node)
-{ return NULL; }
-
-template <class NodeType>
-BLI_INLINE OperationDepsNode *get_exit_operation(NodeType *node)
-{ return NULL; }
-
-BLI_INLINE OperationDepsNode *get_entry_operation(OperationDepsNode *node)
-{ return node; }
-
-BLI_INLINE OperationDepsNode *get_exit_operation(OperationDepsNode *node)
-{ return node; }
-
-BLI_INLINE OperationDepsNode *get_entry_operation(ComponentDepsNode *node)
-{
- if (node) {
- if (node->entry_operation)
- return node->entry_operation;
- else if (node->operations.size() == 1)
- return node->operations.begin()->second;
- }
- return NULL;
-}
-
-BLI_INLINE OperationDepsNode *get_exit_operation(ComponentDepsNode *node)
-{
- if (node) {
- if (node->exit_operation)
- return node->exit_operation;
- else if (node->operations.size() == 1)
- return node->operations.begin()->second;
- }
- return NULL;
-}
-
template <typename KeyFrom, typename KeyTo>
-void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, const KeyTo &key_to,
- eDepsRelation_Type type, const string &description)
+void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from,
+ const KeyTo &key_to,
+ eDepsRelation_Type type,
+ const string &description)
{
- //DepsNode *node_from = find_node(key_from);
- //DepsNode *node_to = find_node(key_to);
-
- // XXX: warning - don't use node_from and node_to directly, as that breaks the templates...
- OperationDepsNode *op_from = get_exit_operation(find_node(key_from));
- OperationDepsNode *op_to = get_entry_operation(find_node(key_to));
-
+ DepsNode *node_from = find_node(key_from);
+ DepsNode *node_to = find_node(key_to);
+ OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
+ OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
if (op_from && op_to) {
add_operation_relation(op_from, op_to, type, description);
}
@@ -377,31 +336,36 @@ void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, const KeyTo
}
template <typename KeyTo>
-void DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from, const KeyTo &key_to,
- eDepsRelation_Type type, const string &description)
+void DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from,
+ const KeyTo &key_to,
+ eDepsRelation_Type type,
+ const string &description)
{
BLI_assert(type == DEPSREL_TYPE_TIME);
TimeSourceDepsNode *time_from = find_node(key_from);
- OperationDepsNode *op_to = get_entry_operation(find_node(key_to));
-
+ DepsNode *node_to = find_node(key_to);
+ OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
if (time_from && op_to) {
add_time_relation(time_from, op_to, description);
}
else {
-
}
}
template <typename KeyType>
-void DepsgraphRelationBuilder::add_node_handle_relation(const KeyType &key_from, const DepsNodeHandle *handle,
- eDepsRelation_Type type, const string &description)
+void DepsgraphRelationBuilder::add_node_handle_relation(const KeyType &key_from,
+ const DepsNodeHandle *handle,
+ eDepsRelation_Type type,
+ const string &description)
{
- OperationDepsNode *op_from = get_exit_operation(find_node(key_from));
- OperationDepsNode *op_to = get_entry_operation(handle->node);
+ DepsNode *node_from = find_node(key_from);
+ OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
+ OperationDepsNode *op_to = handle->node->get_entry_operation();
if (op_from && op_to) {
add_operation_relation(op_from, op_to, type, description);
}
else {
+ abort();
if (!op_from) {
/* XXX TODO handle as error or report if needed */
}
@@ -412,10 +376,10 @@ void DepsgraphRelationBuilder::add_node_handle_relation(const KeyType &key_from,
}
template <typename KeyType>
-DepsNodeHandle DepsgraphRelationBuilder::create_node_handle(const KeyType &key, const string &default_name)
+DepsNodeHandle DepsgraphRelationBuilder::create_node_handle(const KeyType &key,
+ const string &default_name)
{
return DepsNodeHandle(this, find_node(key), default_name);
}
-
-#endif // __DEPSGRAPH_BUILD_H__
+#endif // __DEPSGRAPH_BUILD_H__ */
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 9fb3359..bffc224 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -208,7 +208,7 @@ bool pchan_check_common_solver_root(const DepsgraphRelationBuilder::RootPChanMap
} /* namespace */
-/* ************************************************* */
+/* ***************** */
/* Relations Builder */
void DepsgraphRelationBuilder::build_scene(Scene *scene)
diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index 83137ce..bb0ed86 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -93,6 +93,9 @@ struct DepsNode {
virtual void copy(DepsgraphCopyContext *dcc, const DepsNode *src) {}
virtual void tag_update(Depsgraph *graph) {}
+
+ virtual OperationDepsNode *get_entry_operation() { return NULL; }
+ virtual OperationDepsNode *get_exit_operation() { return NULL; }
};
/* Macros for common static typeinfo. */
diff --git a/source/blender/depsgraph/intern/depsnode_component.cpp b/source/blender/depsgraph/intern/depsnode_component.cpp
index 934fe1b..3d26ecd 100644
--- a/source/blender/depsgraph/intern/depsnode_component.cpp
+++ b/source/blender/depsgraph/intern/depsnode_component.cpp
@@ -201,6 +201,24 @@ void ComponentDepsNode::tag_update(Depsgraph *graph)
}
}
+OperationDepsNode *ComponentDepsNode::get_entry_operation()
+{
+ if (entry_operation)
+ return entry_operation;
+ else if (operations.size() == 1)
+ return operations.begin()->second;
+ return NULL;
+}
+
+OperationDepsNode *ComponentDepsNode::get_exit_operation()
+{
+ if (exit_operation)
+ return exit_operation;
+ else if (operations.size() == 1)
+ return operations.begin()->second;
+ return NULL;
+}
+
/* Parameter Component Defines ============================ */
DEG_DEPSNODE_DEFINE(ParametersComponentDepsNode, DEPSNODE_TYPE_PARAMETERS, "Parameters Component");
diff --git a/source/blender/depsgraph/intern/depsnode_component.h b/source/blender/depsgraph/intern/depsnode_component.h
index fa36d25..6b321b5 100644
--- a/source/blender/depsgraph/intern/depsnode_component.h
+++ b/source/blender/depsgraph/intern/depsnode_component.h
@@ -134,7 +134,10 @@ struct ComponentDepsNode : public DepsNode {
* NOTE: this does not free the actual context in question
*/
virtual void eval_context_free(EvaluationContext *eval_ctx) {}
-
+
+ OperationDepsNode *get_entry_operation();
+ OperationDepsNode *get_exit_operation();
+
IDDepsNode *owner;
OperationMap operations; /* inner nodes for this component */
diff --git a/source/blender/depsgraph/intern/depsnode_operation.h b/source/blender/depsgraph/intern/depsnode_operation.h
index 674132a..d02153d 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.h
+++ b/source/blender/depsgraph/intern/depsnode_operation.h
@@ -72,7 +72,10 @@ struct OperationDepsNode : public DepsNode {
void tag_update(Depsgraph *graph);
bool is_noop() const { return (bool)evaluate == false; }
-
+
+ OperationDepsNode *get_entry_operation() { return this; }
+ OperationDepsNode *get_exit_operation() { return this; }
+
ComponentDepsNode *owner; /* component that contains the operation */
DepsEvalOperationCb evaluate; /* callback for operation */
More information about the Bf-blender-cvs
mailing list