[Bf-blender-cvs] [5ec4ba8080d] master: Cleanup: Use lambda instead of function bind
Sergey Sharybin
noreply at git.blender.org
Fri Feb 5 16:43:43 CET 2021
Commit: 5ec4ba8080d1c6f27093b242603a7f8f2783deef
Author: Sergey Sharybin
Date: Fri Feb 5 11:41:32 2021 +0100
Branches: master
https://developer.blender.org/rB5ec4ba8080d1c6f27093b242603a7f8f2783deef
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
===================================================================
M .clang-tidy
M source/blender/blenlib/intern/task_graph.cc
M source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
M source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
===================================================================
diff --git a/.clang-tidy b/.clang-tidy
index b52d0f9ba46..0192a8b41ef 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -40,7 +40,6 @@ Checks: >
-modernize-loop-convert,
-modernize-pass-by-value,
-modernize-raw-string-literal,
- -modernize-avoid-bind,
WarningsAsErrors: '*'
CheckOptions:
diff --git a/source/blender/blenlib/intern/task_graph.cc b/source/blender/blenlib/intern/task_graph.cc
index 4f112c5b2c8..5b804cd1df8 100644
--- a/source/blender/blenlib/intern/task_graph.cc
+++ b/source/blender/blenlib/intern/task_graph.cc
@@ -70,7 +70,7 @@ struct TaskNode {
#ifdef WITH_TBB
tbb_node(task_graph->tbb_graph,
tbb::flow::unlimited,
- std::bind(&TaskNode::run, this, std::placeholders::_1)),
+ [&](const tbb::flow::continue_msg input) { run(input); }),
#endif
run_func(run_func),
task_data(task_data),
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index c3304cd80ff..d9df322776e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -178,7 +178,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
if (id_node->components.is_empty() && deg_copy_on_write_is_needed(id_type)) {
ComponentNode *comp_cow = id_node->add_component(NodeType::COPY_ON_WRITE);
OperationNode *op_cow = comp_cow->add_operation(
- function_bind(deg_evaluate_copy_on_write, _1, id_node),
+ [id_node](::Depsgraph *depsgraph) { deg_evaluate_copy_on_write(depsgraph, id_node); },
OperationCode::COPY_ON_WRITE,
"",
-1);
@@ -696,7 +696,9 @@ void DepsgraphNodeBuilder::build_object(int base_index,
add_operation_node(&object->id,
NodeType::SYNCHRONIZATION,
OperationCode::SYNCHRONIZE_TO_ORIGINAL,
- function_bind(BKE_object_sync_to_original, _1, object_cow));
+ [object_cow](::Depsgraph *depsgraph) {
+ BKE_object_sync_to_original(depsgraph, object_cow);
+ });
}
void DepsgraphNodeBuilder::build_object_from_layer(int base_index,
@@ -725,16 +727,15 @@ void DepsgraphNodeBuilder::build_object_flags(int base_index,
Object *object_cow = get_cow_datablock(object);
const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET);
/* TODO(sergey): Is this really best component to be used? */
- add_operation_node(&object->id,
- NodeType::OBJECT_FROM_LAYER,
- OperationCode::OBJECT_BASE_FLAGS,
- function_bind(BKE_object_eval_eval_base_flags,
- _1,
- scene_cow,
- view_layer_index_,
- object_cow,
- base_index,
- is_from_set));
+ add_operation_node(
+ &object->id,
+ NodeType::OBJECT_FROM_LAYER,
+ OperationCode::OBJECT_BASE_FLAGS,
+ [view_layer_index = view_layer_index_, scene_cow, object_cow, base_index, is_from_set](
+ ::Depsgraph *depsgraph) {
+ BKE_object_eval_eval_base_flags(
+ depsgraph, scene_cow, view_layer_index, object_cow, base_index, is_from_set);
+ });
}
void DepsgraphNodeBuilder::build_object_proxy_from(Object *object, bool is_object_visible)
@@ -853,34 +854,38 @@ void DepsgraphNodeBuilder::build_object_transform(Object *object)
op_node = add_operation_node(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_INIT);
op_node->set_as_entry();
/* Local transforms (from transform channels - loc/rot/scale + deltas). */
- add_operation_node(&object->id,
- NodeType::TRANSFORM,
- OperationCode::TRANSFORM_LOCAL,
- function_bind(BKE_object_eval_local_transform, _1, ob_cow));
+ add_operation_node(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_LOCAL,
+ [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_local_transform(depsgraph, ob_cow); });
/* Object parent. */
if (object->parent != nullptr) {
- add_operation_node(&object->id,
- NodeType::TRANSFORM,
- OperationCode::TRANSFORM_PARENT,
- function_bind(BKE_object_eval_parent, _1, ob_cow));
+ add_operation_node(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_PARENT,
+ [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_parent(depsgraph, ob_cow); });
}
/* Object constraints. */
if (object->constraints.first != nullptr) {
build_object_constraints(object);
}
/* Rest of transformation update. */
- add_operation_node(&object->id,
- NodeType::TRANSFORM,
- OperationCode::TRANSFORM_EVAL,
- function_bind(BKE_object_eval_uber_transform, _1, ob_cow));
+ add_operation_node(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_EVAL,
+ [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_uber_transform(depsgraph, ob_cow); });
/* Operation to take of rigid body simulation. soft bodies and other friends
* in the context of point cache invalidation. */
add_operation_node(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_SIMULATION_INIT);
/* Object transform is done. */
- op_node = add_operation_node(&object->id,
- NodeType::TRANSFORM,
- OperationCode::TRANSFORM_FINAL,
- function_bind(BKE_object_eval_transform_final, _1, ob_cow));
+ op_node = add_operation_node(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_FINAL,
+ [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_transform_final(depsgraph, ob_cow); });
op_node->set_as_exit();
}
@@ -904,12 +909,14 @@ void DepsgraphNodeBuilder::build_object_transform(Object *object)
void DepsgraphNodeBuilder::build_object_constraints(Object *object)
{
/* create node for constraint stack */
- add_operation_node(
- &object->id,
- NodeType::TRANSFORM,
- OperationCode::TRANSFORM_CONSTRAINTS,
- function_bind(
- BKE_object_eval_constraints, _1, get_cow_datablock(scene_), get_cow_datablock(object)));
+ Scene *scene_cow = get_cow_datablock(scene_);
+ Object *object_cow = get_cow_datablock(object);
+ add_operation_node(&object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_CONSTRAINTS,
+ [scene_cow, object_cow](::Depsgraph *depsgraph) {
+ BKE_object_eval_constraints(depsgraph, scene_cow, object_cow);
+ });
}
void DepsgraphNodeBuilder::build_object_pointcache(Object *object)
@@ -922,7 +929,9 @@ void DepsgraphNodeBuilder::build_object_pointcache(Object *object)
add_operation_node(&object->id,
NodeType::POINT_CACHE,
OperationCode::POINT_CACHE_RESET,
- function_bind(BKE_object_eval_ptcache_reset, _1, scene_cow, object_cow));
+ [scene_cow, object_cow](::Depsgraph *depsgraph) {
+ BKE_object_eval_ptcache_reset(depsgraph, scene_cow, object_cow);
+ });
}
/**
@@ -950,10 +959,10 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
operation_node = add_operation_node(id, NodeType::ANIMATION, OperationCode::ANIMATION_ENTRY);
operation_node->set_as_entry();
/* All the evaluation nodes. */
- add_operation_node(id,
- NodeType::ANIMATION,
- OperationCode::ANIMATION_EVAL,
- function_bind(BKE_animsys_eval_animdata, _1, id_cow));
+ add_operation_node(
+ id, NodeType::ANIMATION, OperationCode::ANIMATION_EVAL, [id_cow](::Depsgraph *depsgraph) {
+ BKE_animsys_eval_animdata(depsgraph, id_cow);
+ });
/* Explicit exit operation. */
operation_node = add_operation_node(id, NodeType::ANIMATION, OperationCode::ANIMATION_EXIT);
operation_node->set_as_exit();
@@ -989,10 +998,11 @@ void DepsgraphNodeBuilder::build_animation_images(ID *id)
{
if (BKE_image_user_id_has_animation(id)) {
ID *id_cow = get_cow_id(id);
- add_operation_node(id,
- NodeType::IMAGE_ANIMATION,
- OperationCode::IMAGE_ANIMATION,
- function_bind(BKE_image_user_id_eval_animation, _1, id_cow));
+ add_operation_node(
+ id,
+ NodeType::IMAGE_ANIMATION,
+ OperationCode::IMAGE_ANIMATION,
+ [id_cow](::Depsgraph *depsgraph) { BKE_image_user_id_eval_animation(depsgraph, id_cow); });
}
}
@@ -1020,12 +1030,15 @@ void DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcurve, int driver_index
* has not yet been allocated at this point we can't. As a workaround
* the animation systems allocates an array so we can do a fast lookup
* with the driver index. */
- ensure_operation_node(id,
- NodeType::PARAMETERS,
- OperationCode::DRIVER,
- function_bind(BKE_animsys_eval_driver, _1, id_cow, driver_index, fcurve),
- fcurve->rna_path ? fcurve->rna_path : "",
- fcurve->array_index);
+ ensure_operation_node(
+ id,
+ NodeType::PARAMETERS,
+ OperationCode::DRIVER,
+ [id_cow, driver_index, fcurve](::Depsgraph *depsgraph) {
+ BKE_animsys_eval_driver(depsgraph, id_cow, driver_index, fcurve);
+ },
+ fcurve->rna_path ? fcurve->rna_path : "",
+ fcurve->array_index);
build_driver_variables(id, fcurve);
}
@@ -1103,10 +1116,11 @@ void DepsgraphNodeBuilder::build_world(World *world)
add_id_node(&world->id);
World *world_cow = get_cow_datablock(world);
/* Shading update. */
- add_operation_node(&world->id,
- NodeType::SHADING,
- OperationCode::WORLD_UPD
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list