diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-03 18:23:43 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-04 10:48:41 +0300 |
commit | 4674e02562637f36a9900bff5f5f4acc9aff482d (patch) | |
tree | 4fca4fb97dad7c2e34533950d44faeb5ce94e2c0 /source/blender/depsgraph | |
parent | fa01a1738bd1e3a6750ffbe523a282bc22de3991 (diff) |
Depsgraph: Only bind ID-data and indices to depsgraph callbacks
This is a part of copy-on-write sanitization, to avoid all the checks
which were attempting to keep sub-data pointers intact.
Point is: ID pointers never change for CoW datablocks, but nested
data pointers might change when updating existing copy.
Solution: Only bind ID data pointers and index of sub-data.
This will make CoW datablock 7update function was easier in 2.8.
In master we were only using pose channel pointers in callbacks,
this is exactly what this commit addresses. A linear lookup array
is created on pose evaluation init and is thrown away afterwards.
One thing we might consider doing is to keep indexed array of
poses, similar to chanhash.
Reviewers: campbellbarton
Reviewed By: campbellbarton
Subscribers: dfelinto
Differential Revision: https://developer.blender.org/D3124
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes.h | 2 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc | 62 |
2 files changed, 50 insertions, 14 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 9d47dc6bced..17d2a4ad558 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -132,7 +132,7 @@ struct DepsgraphNodeBuilder { void build_object_data(Object *object); void build_object_transform(Object *object); void build_object_constraints(Object *object); - void build_pose_constraints(Object *object, bPoseChannel *pchan); + void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index); void build_rigidbody(Scene *scene); void build_particles(Object *object); void build_cloth(Object *object); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index 73bbbcfa0b3..0c7c3d13d93 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -64,16 +64,24 @@ extern "C" { namespace DEG { -void DepsgraphNodeBuilder::build_pose_constraints(Object *object, bPoseChannel *pchan) +void DepsgraphNodeBuilder::build_pose_constraints(Object *object, + bPoseChannel *pchan, + int pchan_index) { /* create node for constraint stack */ add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, - function_bind(BKE_pose_constraints_evaluate, _1, scene_, object, pchan), + function_bind(BKE_pose_constraints_evaluate, + _1, + scene_, + object, + pchan_index), DEG_OPCODE_BONE_CONSTRAINTS); } /* IK Solver Eval Steps */ -void DepsgraphNodeBuilder::build_ik_pose(Object *object, bPoseChannel *pchan, bConstraint *con) +void DepsgraphNodeBuilder::build_ik_pose(Object *object, + bPoseChannel *pchan, + bConstraint *con) { bKinematicConstraint *data = (bKinematicConstraint *)con->data; @@ -89,14 +97,21 @@ void DepsgraphNodeBuilder::build_ik_pose(Object *object, bPoseChannel *pchan, bC return; } + int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan); /* Operation node for evaluating/running IK Solver. */ add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, - function_bind(BKE_pose_iktree_evaluate, _1, scene_, object, rootchan), + function_bind(BKE_pose_iktree_evaluate, + _1, + scene_, + object, + rootchan_index), DEG_OPCODE_POSE_IK_SOLVER); } /* Spline IK Eval Steps */ -void DepsgraphNodeBuilder::build_splineik_pose(Object *object, bPoseChannel *pchan, bConstraint *con) +void DepsgraphNodeBuilder::build_splineik_pose(Object *object, + bPoseChannel *pchan, + bConstraint *con) { bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; @@ -106,8 +121,13 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object, bPoseChannel *pch /* Operation node for evaluating/running Spline IK Solver. * Store the "root bone" of this chain in the solver, so it knows where to start. */ + int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan); add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, - function_bind(BKE_pose_splineik_evaluate, _1, scene_, object, rootchan), + function_bind(BKE_pose_splineik_evaluate, + _1, + scene_, + object, + rootchan_index), DEG_OPCODE_POSE_SPLINE_IK_SOLVER); } @@ -178,22 +198,32 @@ void DepsgraphNodeBuilder::build_rig(Object *object) /* pose eval context */ op_node = add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, - function_bind(BKE_pose_eval_init, _1, scene_, object, object->pose), + function_bind(BKE_pose_eval_init, + _1, + scene_, + object), DEG_OPCODE_POSE_INIT); op_node->set_as_entry(); op_node = add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, - function_bind(BKE_pose_eval_init_ik, _1, scene_, object, object->pose), + function_bind(BKE_pose_eval_init_ik, + _1, + scene_, + object), DEG_OPCODE_POSE_INIT_IK); op_node = add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, - function_bind(BKE_pose_eval_flush, _1, scene_, object, object->pose), + function_bind(BKE_pose_eval_flush, + _1, + scene_, + object), DEG_OPCODE_POSE_DONE); op_node->set_as_exit(); /* bones */ + int pchan_index = 0; LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) { /* Node for bone evaluation. */ op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, NULL, @@ -201,7 +231,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object) op_node->set_as_entry(); add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, - function_bind(BKE_pose_eval_bone, _1, scene_, object, pchan), + function_bind(BKE_pose_eval_bone, _1, scene_, object, pchan_index), DEG_OPCODE_BONE_POSE_PARENT); add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, @@ -209,7 +239,10 @@ void DepsgraphNodeBuilder::build_rig(Object *object) DEG_OPCODE_BONE_READY); op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, - function_bind(BKE_pose_bone_done, _1, pchan), + function_bind(BKE_pose_bone_done, + _1, + object, + pchan_index), DEG_OPCODE_BONE_DONE); op_node->set_as_exit(); /* Custom properties. */ @@ -222,7 +255,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object) } /* Constraints. */ if (pchan->constraints.first != NULL) { - build_pose_constraints(object, pchan); + build_pose_constraints(object, pchan, pchan_index); } /** * IK Solvers. @@ -232,7 +265,8 @@ void DepsgraphNodeBuilder::build_rig(Object *object) * base transforms of a bunch of bones is done) * * Unsolved Issues: - * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building + * - Care is needed to ensure that multi-headed trees work out the same + * as in ik-tree building. * - Animated chain-lengths are a problem... */ LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) { @@ -249,6 +283,8 @@ void DepsgraphNodeBuilder::build_rig(Object *object) break; } } + + pchan_index++; } } |