diff options
author | Sergey Sharybin <sergey@blender.org> | 2021-02-05 13:41:32 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2021-02-05 18:43:23 +0300 |
commit | 5ec4ba8080d1c6f27093b242603a7f8f2783deef (patch) | |
tree | 30f2800615e8e21f8a141f25a32b76b8a29fde96 /source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc | |
parent | a0867f05a48e2017a3b634cda5471c015af5bf35 (diff) |
Cleanup: Use lambda instead of function bind
More detailed explanation why it is a preferred way of coding
nowadays can be found at
https://clang.llvm.org/extra/clang-tidy/checks/modernize-avoid-bind.html
Resolves modernize-avoid-bind Clang-Tidy warning.
Differential Revision: https://developer.blender.org/D10320
Diffstat (limited to 'source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc')
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc | 116 |
1 files changed, 70 insertions, 46 deletions
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 8ba4b4a427f..13caba67713 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -66,16 +66,18 @@ void DepsgraphNodeBuilder::build_pose_constraints(Object *object, data.builder = this; data.is_parent_visible = is_object_visible; BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data); + /* Create node for constraint stack. */ + Scene *scene_cow = get_cow_datablock(scene_); + Object *object_cow = get_cow_datablock(object); add_operation_node(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_CONSTRAINTS, - function_bind(BKE_pose_constraints_evaluate, - _1, - get_cow_datablock(scene_), - get_cow_datablock(object), - pchan_index)); + [scene_cow, object_cow, pchan_index](::Depsgraph *depsgraph) { + BKE_pose_constraints_evaluate( + depsgraph, scene_cow, object_cow, pchan_index); + }); } /* IK Solver Eval Steps */ @@ -96,16 +98,17 @@ void DepsgraphNodeBuilder::build_ik_pose(Object *object, bPoseChannel *pchan, bC int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan); BLI_assert(rootchan_index != -1); + /* Operation node for evaluating/running IK Solver. */ + Scene *scene_cow = get_cow_datablock(scene_); + Object *object_cow = get_cow_datablock(object); add_operation_node(&object->id, NodeType::EVAL_POSE, rootchan->name, OperationCode::POSE_IK_SOLVER, - function_bind(BKE_pose_iktree_evaluate, - _1, - get_cow_datablock(scene_), - get_cow_datablock(object), - rootchan_index)); + [scene_cow, object_cow, rootchan_index](::Depsgraph *depsgraph) { + BKE_pose_iktree_evaluate(depsgraph, scene_cow, object_cow, rootchan_index); + }); } /* Spline IK Eval Steps */ @@ -130,15 +133,17 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object, * start. */ int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan); BLI_assert(rootchan_index != -1); + + Scene *scene_cow = get_cow_datablock(scene_); + Object *object_cow = get_cow_datablock(object); add_operation_node(&object->id, NodeType::EVAL_POSE, rootchan->name, OperationCode::POSE_SPLINE_IK_SOLVER, - function_bind(BKE_pose_splineik_evaluate, - _1, - get_cow_datablock(scene_), - get_cow_datablock(object), - rootchan_index)); + [scene_cow, object_cow, rootchan_index](::Depsgraph *depsgraph) { + BKE_pose_splineik_evaluate( + depsgraph, scene_cow, object_cow, rootchan_index); + }); } /* Pose/Armature Bones Graph */ @@ -193,23 +198,30 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible) op_node = add_operation_node(&object->id, NodeType::EVAL_POSE, OperationCode::POSE_INIT, - function_bind(BKE_pose_eval_init, _1, scene_cow, object_cow)); + [scene_cow, object_cow](::Depsgraph *depsgraph) { + BKE_pose_eval_init(depsgraph, scene_cow, object_cow); + }); op_node->set_as_entry(); op_node = add_operation_node(&object->id, NodeType::EVAL_POSE, OperationCode::POSE_INIT_IK, - function_bind(BKE_pose_eval_init_ik, _1, scene_cow, object_cow)); + [scene_cow, object_cow](::Depsgraph *depsgraph) { + BKE_pose_eval_init_ik(depsgraph, scene_cow, object_cow); + }); add_operation_node(&object->id, NodeType::EVAL_POSE, OperationCode::POSE_CLEANUP, - function_bind(BKE_pose_eval_cleanup, _1, scene_cow, object_cow)); - - op_node = add_operation_node(&object->id, - NodeType::EVAL_POSE, - OperationCode::POSE_DONE, - function_bind(BKE_pose_eval_done, _1, object_cow)); + [scene_cow, object_cow](::Depsgraph *depsgraph) { + BKE_pose_eval_cleanup(depsgraph, scene_cow, object_cow); + }); + + op_node = add_operation_node( + &object->id, + NodeType::EVAL_POSE, + OperationCode::POSE_DONE, + [object_cow](::Depsgraph *depsgraph) { BKE_pose_eval_done(depsgraph, object_cow); }); op_node->set_as_exit(); /* Bones. */ int pchan_index = 0; @@ -223,7 +235,9 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible) NodeType::BONE, pchan->name, OperationCode::BONE_POSE_PARENT, - function_bind(BKE_pose_eval_bone, _1, scene_cow, object_cow, pchan_index)); + [scene_cow, object_cow, pchan_index](::Depsgraph *depsgraph) { + BKE_pose_eval_bone(depsgraph, scene_cow, object_cow, pchan_index); + }); /* NOTE: Dedicated noop for easier relationship construction. */ add_operation_node(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_READY); @@ -232,16 +246,20 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible) NodeType::BONE, pchan->name, OperationCode::BONE_DONE, - function_bind(BKE_pose_bone_done, _1, object_cow, pchan_index)); + [object_cow, pchan_index](::Depsgraph *depsgraph) { + BKE_pose_bone_done(depsgraph, object_cow, pchan_index); + }); /* B-Bone shape computation - the real last step if present. */ if (check_pchan_has_bbone(object, pchan)) { - op_node = add_operation_node( - &object->id, - NodeType::BONE, - pchan->name, - OperationCode::BONE_SEGMENTS, - function_bind(BKE_pose_eval_bbone_segments, _1, object_cow, pchan_index)); + op_node = add_operation_node(&object->id, + NodeType::BONE, + pchan->name, + OperationCode::BONE_SEGMENTS, + [object_cow, pchan_index](::Depsgraph *depsgraph) { + BKE_pose_eval_bbone_segments( + depsgraph, object_cow, pchan_index); + }); } op_node->set_as_exit(); @@ -304,10 +322,11 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visibl if (object->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) { BKE_pose_update_constraint_flags(object->pose); } - op_node = add_operation_node(&object->id, - NodeType::EVAL_POSE, - OperationCode::POSE_INIT, - function_bind(BKE_pose_eval_proxy_init, _1, object_cow)); + op_node = add_operation_node( + &object->id, + NodeType::EVAL_POSE, + OperationCode::POSE_INIT, + [object_cow](::Depsgraph *depsgraph) { BKE_pose_eval_proxy_init(depsgraph, object_cow); }); op_node->set_as_entry(); int pchan_index = 0; @@ -318,12 +337,14 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visibl /* Bone is ready for solvers. */ add_operation_node(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_READY); /* Bone is fully evaluated. */ - op_node = add_operation_node( - &object->id, - NodeType::BONE, - pchan->name, - OperationCode::BONE_DONE, - function_bind(BKE_pose_eval_proxy_copy_bone, _1, object_cow, pchan_index)); + op_node = add_operation_node(&object->id, + NodeType::BONE, + pchan->name, + OperationCode::BONE_DONE, + [object_cow, pchan_index](::Depsgraph *depsgraph) { + BKE_pose_eval_proxy_copy_bone( + depsgraph, object_cow, pchan_index); + }); op_node->set_as_exit(); /* Custom properties. */ @@ -343,11 +364,14 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visibl op_node = add_operation_node(&object->id, NodeType::EVAL_POSE, OperationCode::POSE_CLEANUP, - function_bind(BKE_pose_eval_proxy_cleanup, _1, object_cow)); - op_node = add_operation_node(&object->id, - NodeType::EVAL_POSE, - OperationCode::POSE_DONE, - function_bind(BKE_pose_eval_proxy_done, _1, object_cow)); + [object_cow](::Depsgraph *depsgraph) { + BKE_pose_eval_proxy_cleanup(depsgraph, object_cow); + }); + op_node = add_operation_node( + &object->id, + NodeType::EVAL_POSE, + OperationCode::POSE_DONE, + [object_cow](::Depsgraph *depsgraph) { BKE_pose_eval_proxy_done(depsgraph, object_cow); }); op_node->set_as_exit(); } |