Commit: 7abd923c74a3cf652e9032935c32d42c1c1f5709
Author: Lukas Tönne
Date:   Tue Jun 10 19:46:39 2014 +0200
https://developer.blender.org/rB7abd923c74a3cf652e9032935c32d42c1c1f5709

Use function binding instead of the generic PointerRNA for passing
constant arguments to operation functions.

This usually includes an ID datablock pointer and possibly some subdata
like a modifier, bone or particle system.

Note that this does not yet handle transient data that would get passed
only between operations during the depsgraph evaluation. Such a system
requires careful lifetime handling of the data and memory management.

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

M       source/blender/depsgraph/intern/depsgraph_build.cpp
M       source/blender/depsgraph/intern/depsgraph_build.h
M       source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M       source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M       source/blender/depsgraph/intern/depsnode_operation.cpp
M       source/blender/depsgraph/intern/depsnode_operation.h
M       source/blender/depsgraph/intern/stubs.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp 
b/source/blender/depsgraph/intern/depsgraph_build.cpp
index bc1f7bc..6c46edb 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -217,25 +217,19 @@ ComponentDepsNode 
*DepsgraphNodeBuilder::add_component_node(IDDepsNode *id_node,
 }
 
 OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ComponentDepsNode 
*comp_node, eDepsNode_Type type,
-                                                            
eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description,
-                                                            PointerRNA ptr)
+                                                            
eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description)
 {
        OperationDepsNode *op_node = comp_node->add_operation(type, optype, op, 
description);
-       op_node->ptr = ptr;
-       
        m_graph->operations.push_back(op_node);
-       
        return op_node;
 }
 
 OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(IDDepsNode 
*id_node, eDepsNode_Type type,
-                                                            
eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description,
-                                                            PointerRNA ptr)
+                                                            
eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description)
 {
        DepsNodeFactory *factory = DEG_get_node_factory(type);
        ComponentDepsNode *comp_node = 
id_node->add_component(factory->component_type());
        OperationDepsNode *op_node = comp_node->add_operation(type, optype, op, 
description);
-       op_node->ptr = ptr;
        
        m_graph->operations.push_back(op_node);
        
@@ -269,7 +263,7 @@ void 
DepsgraphNodeBuilder::verify_entry_exit_operations(ComponentDepsNode *node)
        }
        else if (entry_ops.size() > 1) {
                /* multiple entry ops, add a barrier node as a single entry 
point */
-               node->entry_operation = add_operation_node(node, 
DEPSNODE_TYPE_OP_NOOP, DEPSOP_TYPE_INIT, NULL, "Entry", PointerRNA_NULL);
+               node->entry_operation = add_operation_node(node, 
DEPSNODE_TYPE_OP_NOOP, DEPSOP_TYPE_INIT, NULL, "Entry");
                for (OperationsVector::const_iterator it = entry_ops.begin(); 
it != entry_ops.end(); ++it) {
                        OperationDepsNode *op_node = *it;
                        m_graph->add_new_relation(node->entry_operation, 
op_node, DEPSREL_TYPE_OPERATION, "Component entry relation");
@@ -282,7 +276,7 @@ void 
DepsgraphNodeBuilder::verify_entry_exit_operations(ComponentDepsNode *node)
        }
        else if (exit_ops.size() > 1) {
                /* multiple exit ops, add a barrier node as a single exit point 
*/
-               node->exit_operation = add_operation_node(node, 
DEPSNODE_TYPE_OP_NOOP, DEPSOP_TYPE_OUT, NULL, "Exit", PointerRNA_NULL);
+               node->exit_operation = add_operation_node(node, 
DEPSNODE_TYPE_OP_NOOP, DEPSOP_TYPE_OUT, NULL, "Exit");
                for (OperationsVector::const_iterator it = exit_ops.begin(); it 
!= exit_ops.end(); ++it) {
                        OperationDepsNode *op_node = *it;
                        m_graph->add_new_relation(op_node, 
node->exit_operation, DEPSREL_TYPE_OPERATION, "Component exit relation");
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h 
b/source/blender/depsgraph/intern/depsgraph_build.h
index f586001..68131c7 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -68,11 +68,9 @@ struct DepsgraphNodeBuilder {
        TimeSourceDepsNode *add_time_source(IDPtr id);
        ComponentDepsNode *add_component_node(IDDepsNode *id_node, 
eDepsNode_Type comp_type, const string &comp_name = "");
        OperationDepsNode *add_operation_node(ComponentDepsNode *comp_node, 
eDepsNode_Type type,
-                                             eDepsOperation_Type optype, 
DepsEvalOperationCb op, const string &description,
-                                             PointerRNA ptr);
+                                             eDepsOperation_Type optype, 
DepsEvalOperationCb op, const string &description);
        OperationDepsNode *add_operation_node(IDDepsNode *id_node, 
eDepsNode_Type type,
-                                             eDepsOperation_Type optype, 
DepsEvalOperationCb op, const string &description,
-                                             PointerRNA ptr);
+                                             eDepsOperation_Type optype, 
DepsEvalOperationCb op, const string &description);
        
        void verify_entry_exit_operations();
        
@@ -81,7 +79,8 @@ struct DepsgraphNodeBuilder {
        void build_group(Group *group);
        IDDepsNode *build_object(Scene *scene, Object *ob);
        ComponentDepsNode *build_object_transform(Object *ob, IDDepsNode 
*ob_node);
-       void build_constraints(ComponentDepsNode *comp_node, eDepsNode_Type 
constraint_op_type);
+       void build_object_constraints(Object *ob, IDDepsNode *ob_node);
+       void build_pose_constraints(Object *ob, bPoseChannel *pchan, 
BoneComponentDepsNode *bone_node);
        void build_rigidbody(IDDepsNode *scene_node, Scene *scene);
        void build_particles(IDDepsNode *ob_node, Object *ob);
        void build_animdata(IDDepsNode *id_node);
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp 
b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index f766935..700a165 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -230,13 +230,13 @@ IDDepsNode *DepsgraphNodeBuilder::build_object(Scene 
*scene, Object *ob)
        /* object parent */
        if (ob->parent) {
                add_operation_node(trans_node, DEPSNODE_TYPE_OP_TRANSFORM, 
-                                  DEPSOP_TYPE_EXEC, BKE_object_eval_parent,
-                                  deg_op_name_object_parent, 
make_rna_id_pointer(ob));
+                                  DEPSOP_TYPE_EXEC, 
bind(BKE_object_eval_parent, ob),
+                                  deg_op_name_object_parent);
        }
        
        /* object constraints */
        if (ob->constraints.first) {
-               build_constraints(trans_node, DEPSNODE_TYPE_OP_TRANSFORM);
+               build_object_constraints(ob, ob_node);
        }
        
        /* object data */
@@ -289,35 +289,45 @@ ComponentDepsNode 
*DepsgraphNodeBuilder::build_object_transform(Object *ob, IDDe
        
        /* init operation */
        add_operation_node(trans_node, DEPSNODE_TYPE_OP_TRANSFORM,
-                          DEPSOP_TYPE_INIT, BKE_object_eval_local_transform,
-                          deg_op_name_object_local_transform, 
make_rna_id_pointer(ob));
+                          DEPSOP_TYPE_INIT, 
bind(BKE_object_eval_local_transform, ob),
+                          deg_op_name_object_local_transform);
        
        /* return component created */
        return trans_node;
 }
 
-void DepsgraphNodeBuilder::build_constraints(ComponentDepsNode *comp_node, 
eDepsNode_Type constraint_op_type)
+/* == Constraints Graph Notes ==
+ * For constraints, we currently only add a operation node to the Transform
+ * or Bone components (depending on whichever type of owner we have).
+ * This represents the entire constraints stack, which is for now just
+ * executed as a single monolithic block. At least initially, this should
+ * be sufficient for ensuring that the porting/refactoring process remains
+ * manageable. 
+ * 
+ * However, when the time comes for developing "node-based" constraints,
+ * we'll need to split this up into pre/post nodes for "constraint stack
+ * evaluation" + operation nodes for each constraint (i.e. the contents
+ * of the loop body used in the current "solve_constraints()" operation).
+ *
+ * -- Aligorith, August 2013 
+ */
+void DepsgraphNodeBuilder::build_object_constraints(Object *ob, IDDepsNode 
*ob_node)
 {
-       /* == Constraints Graph Notes ==
-        * For constraints, we currently only add a operation node to the 
Transform
-        * or Bone components (depending on whichever type of owner we have).
-        * This represents the entire constraints stack, which is for now just
-        * executed as a single monolithic block. At least initially, this 
should
-        * be sufficient for ensuring that the porting/refactoring process 
remains
-        * manageable. 
-        * 
-        * However, when the time comes for developing "node-based" constraints,
-        * we'll need to split this up into pre/post nodes for "constraint stack
-        * evaluation" + operation nodes for each constraint (i.e. the contents
-        * of the loop body used in the current "solve_constraints()" 
operation).
-        *
-        * -- Aligorith, August 2013 
-        */
+       /* component to hold all transform operations */
+       ComponentDepsNode *trans_node = add_component_node(ob_node, 
DEPSNODE_TYPE_TRANSFORM);
        
        /* create node for constraint stack */
-       add_operation_node(comp_node, constraint_op_type, 
-                          DEPSOP_TYPE_EXEC, BKE_constraints_evaluate,
-                          deg_op_name_constraint_stack, 
make_rna_id_pointer(comp_node->owner->id));
+       add_operation_node(trans_node, DEPSNODE_TYPE_OP_TRANSFORM,
+                          DEPSOP_TYPE_EXEC, 
bind(BKE_object_constraints_evaluate, ob),
+                          deg_op_name_constraint_stack);
+}
+
+void DepsgraphNodeBuilder::build_pose_constraints(Object *ob, bPoseChannel 
*pchan, BoneComponentDepsNode *bone_node)
+{
+       /* create node for constraint stack */
+       add_operation_node(bone_node, DEPSNODE_TYPE_OP_BONE, 
+                          DEPSOP_TYPE_EXEC, 
bind(BKE_pose_constraints_evaluate, ob, pchan),
+                          deg_op_name_constraint_stack);
 }
 
 /* Build graph nodes for AnimData block 
@@ -359,9 +369,8 @@ OperationDepsNode 
*DepsgraphNodeBuilder::build_driver(IDDepsNode *id_node, FCurv
        
        /* create data node for this driver 
..................................... */
        OperationDepsNode *driver_op = add_operation_node(id_node, 
DEPSNODE_TYPE_OP_DRIVER,
-                                                         DEPSOP_TYPE_EXEC, 
BKE_animsys_eval_driver,
-                                                         
deg_op_name_driver(driver),
-                                                         make_rna_pointer(id, 
&RNA_FCurve, fcurve));
+                                                         DEPSOP_TYPE_EXEC, 
bind(BKE_animsys_eval_driver, id, fcurve),
+                                                         
deg_op_name_driver(driver));
        
        /* tag "scripted expression" drivers as needing Python (due to GIL 
issues, etc.) */
        if (driver->type == DRIVER_TYPE_PYTHON) {
@@ -426,13 +435,13 @@ void DepsgraphNodeBuilder::build_

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to