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
This commit is contained in:
Sergey Sharybin 2021-02-05 11:41:32 +01:00
parent a0867f05a4
commit 5ec4ba8080
5 changed files with 255 additions and 177 deletions

View File

@ -40,7 +40,6 @@ Checks: >
-modernize-loop-convert, -modernize-loop-convert,
-modernize-pass-by-value, -modernize-pass-by-value,
-modernize-raw-string-literal, -modernize-raw-string-literal,
-modernize-avoid-bind,
WarningsAsErrors: '*' WarningsAsErrors: '*'
CheckOptions: CheckOptions:

View File

@ -70,7 +70,7 @@ struct TaskNode {
#ifdef WITH_TBB #ifdef WITH_TBB
tbb_node(task_graph->tbb_graph, tbb_node(task_graph->tbb_graph,
tbb::flow::unlimited, tbb::flow::unlimited,
std::bind(&TaskNode::run, this, std::placeholders::_1)), [&](const tbb::flow::continue_msg input) { run(input); }),
#endif #endif
run_func(run_func), run_func(run_func),
task_data(task_data), task_data(task_data),

View File

@ -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)) { 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); ComponentNode *comp_cow = id_node->add_component(NodeType::COPY_ON_WRITE);
OperationNode *op_cow = comp_cow->add_operation( 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, OperationCode::COPY_ON_WRITE,
"", "",
-1); -1);
@ -696,7 +696,9 @@ void DepsgraphNodeBuilder::build_object(int base_index,
add_operation_node(&object->id, add_operation_node(&object->id,
NodeType::SYNCHRONIZATION, NodeType::SYNCHRONIZATION,
OperationCode::SYNCHRONIZE_TO_ORIGINAL, 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, 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); Object *object_cow = get_cow_datablock(object);
const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET); const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET);
/* TODO(sergey): Is this really best component to be used? */ /* TODO(sergey): Is this really best component to be used? */
add_operation_node(&object->id, add_operation_node(
&object->id,
NodeType::OBJECT_FROM_LAYER, NodeType::OBJECT_FROM_LAYER,
OperationCode::OBJECT_BASE_FLAGS, OperationCode::OBJECT_BASE_FLAGS,
function_bind(BKE_object_eval_eval_base_flags, [view_layer_index = view_layer_index_, scene_cow, object_cow, base_index, is_from_set](
_1, ::Depsgraph *depsgraph) {
scene_cow, BKE_object_eval_eval_base_flags(
view_layer_index_, depsgraph, scene_cow, view_layer_index, object_cow, base_index, is_from_set);
object_cow, });
base_index,
is_from_set));
} }
void DepsgraphNodeBuilder::build_object_proxy_from(Object *object, bool is_object_visible) 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 = add_operation_node(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_INIT);
op_node->set_as_entry(); op_node->set_as_entry();
/* Local transforms (from transform channels - loc/rot/scale + deltas). */ /* Local transforms (from transform channels - loc/rot/scale + deltas). */
add_operation_node(&object->id, add_operation_node(
&object->id,
NodeType::TRANSFORM, NodeType::TRANSFORM,
OperationCode::TRANSFORM_LOCAL, OperationCode::TRANSFORM_LOCAL,
function_bind(BKE_object_eval_local_transform, _1, ob_cow)); [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_local_transform(depsgraph, ob_cow); });
/* Object parent. */ /* Object parent. */
if (object->parent != nullptr) { if (object->parent != nullptr) {
add_operation_node(&object->id, add_operation_node(
&object->id,
NodeType::TRANSFORM, NodeType::TRANSFORM,
OperationCode::TRANSFORM_PARENT, OperationCode::TRANSFORM_PARENT,
function_bind(BKE_object_eval_parent, _1, ob_cow)); [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_parent(depsgraph, ob_cow); });
} }
/* Object constraints. */ /* Object constraints. */
if (object->constraints.first != nullptr) { if (object->constraints.first != nullptr) {
build_object_constraints(object); build_object_constraints(object);
} }
/* Rest of transformation update. */ /* Rest of transformation update. */
add_operation_node(&object->id, add_operation_node(
&object->id,
NodeType::TRANSFORM, NodeType::TRANSFORM,
OperationCode::TRANSFORM_EVAL, OperationCode::TRANSFORM_EVAL,
function_bind(BKE_object_eval_uber_transform, _1, ob_cow)); [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_uber_transform(depsgraph, ob_cow); });
/* Operation to take of rigid body simulation. soft bodies and other friends /* Operation to take of rigid body simulation. soft bodies and other friends
* in the context of point cache invalidation. */ * in the context of point cache invalidation. */
add_operation_node(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_SIMULATION_INIT); add_operation_node(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_SIMULATION_INIT);
/* Object transform is done. */ /* Object transform is done. */
op_node = add_operation_node(&object->id, op_node = add_operation_node(
&object->id,
NodeType::TRANSFORM, NodeType::TRANSFORM,
OperationCode::TRANSFORM_FINAL, OperationCode::TRANSFORM_FINAL,
function_bind(BKE_object_eval_transform_final, _1, ob_cow)); [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_transform_final(depsgraph, ob_cow); });
op_node->set_as_exit(); op_node->set_as_exit();
} }
@ -904,12 +909,14 @@ void DepsgraphNodeBuilder::build_object_transform(Object *object)
void DepsgraphNodeBuilder::build_object_constraints(Object *object) void DepsgraphNodeBuilder::build_object_constraints(Object *object)
{ {
/* create node for constraint stack */ /* create node for constraint stack */
add_operation_node( Scene *scene_cow = get_cow_datablock(scene_);
&object->id, Object *object_cow = get_cow_datablock(object);
add_operation_node(&object->id,
NodeType::TRANSFORM, NodeType::TRANSFORM,
OperationCode::TRANSFORM_CONSTRAINTS, OperationCode::TRANSFORM_CONSTRAINTS,
function_bind( [scene_cow, object_cow](::Depsgraph *depsgraph) {
BKE_object_eval_constraints, _1, get_cow_datablock(scene_), get_cow_datablock(object))); BKE_object_eval_constraints(depsgraph, scene_cow, object_cow);
});
} }
void DepsgraphNodeBuilder::build_object_pointcache(Object *object) void DepsgraphNodeBuilder::build_object_pointcache(Object *object)
@ -922,7 +929,9 @@ void DepsgraphNodeBuilder::build_object_pointcache(Object *object)
add_operation_node(&object->id, add_operation_node(&object->id,
NodeType::POINT_CACHE, NodeType::POINT_CACHE,
OperationCode::POINT_CACHE_RESET, 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 = add_operation_node(id, NodeType::ANIMATION, OperationCode::ANIMATION_ENTRY);
operation_node->set_as_entry(); operation_node->set_as_entry();
/* All the evaluation nodes. */ /* All the evaluation nodes. */
add_operation_node(id, add_operation_node(
NodeType::ANIMATION, id, NodeType::ANIMATION, OperationCode::ANIMATION_EVAL, [id_cow](::Depsgraph *depsgraph) {
OperationCode::ANIMATION_EVAL, BKE_animsys_eval_animdata(depsgraph, id_cow);
function_bind(BKE_animsys_eval_animdata, _1, id_cow)); });
/* Explicit exit operation. */ /* Explicit exit operation. */
operation_node = add_operation_node(id, NodeType::ANIMATION, OperationCode::ANIMATION_EXIT); operation_node = add_operation_node(id, NodeType::ANIMATION, OperationCode::ANIMATION_EXIT);
operation_node->set_as_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)) { if (BKE_image_user_id_has_animation(id)) {
ID *id_cow = get_cow_id(id); ID *id_cow = get_cow_id(id);
add_operation_node(id, add_operation_node(
id,
NodeType::IMAGE_ANIMATION, NodeType::IMAGE_ANIMATION,
OperationCode::IMAGE_ANIMATION, OperationCode::IMAGE_ANIMATION,
function_bind(BKE_image_user_id_eval_animation, _1, id_cow)); [id_cow](::Depsgraph *depsgraph) { BKE_image_user_id_eval_animation(depsgraph, id_cow); });
} }
} }
@ -1020,10 +1030,13 @@ 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 * 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 * the animation systems allocates an array so we can do a fast lookup
* with the driver index. */ * with the driver index. */
ensure_operation_node(id, ensure_operation_node(
id,
NodeType::PARAMETERS, NodeType::PARAMETERS,
OperationCode::DRIVER, OperationCode::DRIVER,
function_bind(BKE_animsys_eval_driver, _1, id_cow, driver_index, fcurve), [id_cow, driver_index, fcurve](::Depsgraph *depsgraph) {
BKE_animsys_eval_driver(depsgraph, id_cow, driver_index, fcurve);
},
fcurve->rna_path ? fcurve->rna_path : "", fcurve->rna_path ? fcurve->rna_path : "",
fcurve->array_index); fcurve->array_index);
build_driver_variables(id, fcurve); build_driver_variables(id, fcurve);
@ -1103,10 +1116,11 @@ void DepsgraphNodeBuilder::build_world(World *world)
add_id_node(&world->id); add_id_node(&world->id);
World *world_cow = get_cow_datablock(world); World *world_cow = get_cow_datablock(world);
/* Shading update. */ /* Shading update. */
add_operation_node(&world->id, add_operation_node(
&world->id,
NodeType::SHADING, NodeType::SHADING,
OperationCode::WORLD_UPDATE, OperationCode::WORLD_UPDATE,
function_bind(BKE_world_eval, _1, world_cow)); [world_cow](::Depsgraph *depsgraph) { BKE_world_eval(depsgraph, world_cow); });
build_idproperties(world->id.properties); build_idproperties(world->id.properties);
/* Animation. */ /* Animation. */
build_animdata(&world->id); build_animdata(&world->id);
@ -1142,16 +1156,19 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
* instead? */ * instead? */
/* Init/rebuild operation. */ /* Init/rebuild operation. */
add_operation_node(&scene->id, add_operation_node(
NodeType::TRANSFORM,
OperationCode::RIGIDBODY_REBUILD,
function_bind(BKE_rigidbody_rebuild_sim, _1, scene_cow));
/* Do-sim operation. */
OperationNode *sim_node = add_operation_node(
&scene->id, &scene->id,
NodeType::TRANSFORM,
OperationCode::RIGIDBODY_REBUILD,
[scene_cow](::Depsgraph *depsgraph) { BKE_rigidbody_rebuild_sim(depsgraph, scene_cow); });
/* Do-sim operation. */
OperationNode *sim_node = add_operation_node(&scene->id,
NodeType::TRANSFORM, NodeType::TRANSFORM,
OperationCode::RIGIDBODY_SIM, OperationCode::RIGIDBODY_SIM,
function_bind(BKE_rigidbody_eval_simulation, _1, scene_cow)); [scene_cow](::Depsgraph *depsgraph) {
BKE_rigidbody_eval_simulation(depsgraph,
scene_cow);
});
sim_node->set_as_entry(); sim_node->set_as_entry();
sim_node->set_as_exit(); sim_node->set_as_exit();
sim_node->owner->entry_operation = sim_node; sim_node->owner->entry_operation = sim_node;
@ -1173,12 +1190,13 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
/* Create operation for flushing results. */ /* Create operation for flushing results. */
/* Object's transform component - where the rigidbody operation /* Object's transform component - where the rigidbody operation
* lives. */ * lives. */
add_operation_node( Object *object_cow = get_cow_datablock(object);
&object->id, add_operation_node(&object->id,
NodeType::TRANSFORM, NodeType::TRANSFORM,
OperationCode::RIGIDBODY_TRANSFORM_COPY, OperationCode::RIGIDBODY_TRANSFORM_COPY,
function_bind( [scene_cow, object_cow](::Depsgraph *depsgraph) {
BKE_rigidbody_object_sync_transforms, _1, scene_cow, get_cow_datablock(object))); BKE_rigidbody_object_sync_transforms(depsgraph, scene_cow, object_cow);
});
} }
FOREACH_COLLECTION_OBJECT_RECURSIVE_END; FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
} }
@ -1219,9 +1237,10 @@ void DepsgraphNodeBuilder::build_particle_systems(Object *object, bool is_object
Object *ob_cow = get_cow_datablock(object); Object *ob_cow = get_cow_datablock(object);
OperationNode *op_node; OperationNode *op_node;
op_node = add_operation_node(psys_comp, op_node = add_operation_node(
OperationCode::PARTICLE_SYSTEM_INIT, psys_comp, OperationCode::PARTICLE_SYSTEM_INIT, [ob_cow](::Depsgraph *depsgraph) {
function_bind(BKE_particle_system_eval_init, _1, ob_cow)); BKE_particle_system_eval_init(depsgraph, ob_cow);
});
op_node->set_as_entry(); op_node->set_as_entry();
/* Build all particle systems. */ /* Build all particle systems. */
LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) { LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
@ -1278,7 +1297,9 @@ void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *particle_se
add_operation_node(&particle_settings->id, add_operation_node(&particle_settings->id,
NodeType::PARTICLE_SETTINGS, NodeType::PARTICLE_SETTINGS,
OperationCode::PARTICLE_SETTINGS_RESET, OperationCode::PARTICLE_SETTINGS_RESET,
function_bind(BKE_particle_settings_eval_reset, _1, particle_settings_cow)); [particle_settings_cow](::Depsgraph *depsgraph) {
BKE_particle_settings_eval_reset(depsgraph, particle_settings_cow);
});
op_node = add_operation_node( op_node = add_operation_node(
&particle_settings->id, NodeType::PARTICLE_SETTINGS, OperationCode::PARTICLE_SETTINGS_EVAL); &particle_settings->id, NodeType::PARTICLE_SETTINGS, OperationCode::PARTICLE_SETTINGS_EVAL);
op_node->set_as_exit(); op_node->set_as_exit();
@ -1323,11 +1344,12 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_ob
op_node = add_operation_node(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT); op_node = add_operation_node(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT);
op_node->set_as_entry(); op_node->set_as_entry();
/* Geometry evaluation. */ /* Geometry evaluation. */
op_node = add_operation_node( op_node = add_operation_node(&object->id,
&object->id,
NodeType::GEOMETRY, NodeType::GEOMETRY,
OperationCode::GEOMETRY_EVAL, OperationCode::GEOMETRY_EVAL,
function_bind(BKE_object_eval_uber_data, _1, scene_cow, object_cow)); [scene_cow, object_cow](::Depsgraph *depsgraph) {
BKE_object_eval_uber_data(depsgraph, scene_cow, object_cow);
});
op_node->set_as_exit(); op_node->set_as_exit();
/* Materials. */ /* Materials. */
build_materials(object->mat, object->totcol); build_materials(object->mat, object->totcol);
@ -1337,10 +1359,11 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_ob
build_object_data_geometry_datablock((ID *)object->data, is_object_visible); build_object_data_geometry_datablock((ID *)object->data, is_object_visible);
build_dimensions(object); build_dimensions(object);
/* Batch cache. */ /* Batch cache. */
add_operation_node(&object->id, add_operation_node(
&object->id,
NodeType::BATCH_CACHE, NodeType::BATCH_CACHE,
OperationCode::GEOMETRY_SELECT_UPDATE, OperationCode::GEOMETRY_SELECT_UPDATE,
function_bind(BKE_object_select_update, _1, object_cow)); [object_cow](::Depsgraph *depsgraph) { BKE_object_select_update(depsgraph, object_cow); });
} }
void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool is_object_visible) void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool is_object_visible)
@ -1368,7 +1391,9 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
op_node = add_operation_node(obdata, op_node = add_operation_node(obdata,
NodeType::GEOMETRY, NodeType::GEOMETRY,
OperationCode::GEOMETRY_EVAL, OperationCode::GEOMETRY_EVAL,
function_bind(BKE_mesh_eval_geometry, _1, (Mesh *)obdata_cow)); [obdata_cow](::Depsgraph *depsgraph) {
BKE_mesh_eval_geometry(depsgraph, (Mesh *)obdata_cow);
});
op_node->set_as_entry(); op_node->set_as_entry();
break; break;
} }
@ -1378,11 +1403,12 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
break; break;
} }
case ID_CU: { case ID_CU: {
op_node = add_operation_node( op_node = add_operation_node(obdata,
obdata,
NodeType::GEOMETRY, NodeType::GEOMETRY,
OperationCode::GEOMETRY_EVAL, OperationCode::GEOMETRY_EVAL,
function_bind(BKE_curve_eval_geometry, _1, (Curve *)obdata_cow)); [obdata_cow](::Depsgraph *depsgraph) {
BKE_curve_eval_geometry(depsgraph, (Curve *)obdata_cow);
});
op_node->set_as_entry(); op_node->set_as_entry();
/* Make sure objects used for bevel.taper are in the graph. /* Make sure objects used for bevel.taper are in the graph.
* NOTE: This objects might be not linked to the scene. */ * NOTE: This objects might be not linked to the scene. */
@ -1399,22 +1425,25 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
break; break;
} }
case ID_LT: { case ID_LT: {
op_node = add_operation_node( op_node = add_operation_node(obdata,
obdata,
NodeType::GEOMETRY, NodeType::GEOMETRY,
OperationCode::GEOMETRY_EVAL, OperationCode::GEOMETRY_EVAL,
function_bind(BKE_lattice_eval_geometry, _1, (Lattice *)obdata_cow)); [obdata_cow](::Depsgraph *depsgraph) {
BKE_lattice_eval_geometry(depsgraph, (Lattice *)obdata_cow);
});
op_node->set_as_entry(); op_node->set_as_entry();
break; break;
} }
case ID_GD: { case ID_GD: {
/* GPencil evaluation operations. */ /* GPencil evaluation operations. */
op_node = add_operation_node( op_node = add_operation_node(obdata,
obdata,
NodeType::GEOMETRY, NodeType::GEOMETRY,
OperationCode::GEOMETRY_EVAL, OperationCode::GEOMETRY_EVAL,
function_bind(BKE_gpencil_frame_active_set, _1, (bGPdata *)obdata_cow)); [obdata_cow](::Depsgraph *depsgraph) {
BKE_gpencil_frame_active_set(depsgraph,
(bGPdata *)obdata_cow);
});
op_node->set_as_entry(); op_node->set_as_entry();
break; break;
} }
@ -1430,11 +1459,12 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
} }
case ID_VO: { case ID_VO: {
/* Volume frame update. */ /* Volume frame update. */
op_node = add_operation_node( op_node = add_operation_node(obdata,
obdata,
NodeType::GEOMETRY, NodeType::GEOMETRY,
OperationCode::GEOMETRY_EVAL, OperationCode::GEOMETRY_EVAL,
function_bind(BKE_volume_eval_geometry, _1, (Volume *)obdata_cow)); [obdata_cow](::Depsgraph *depsgraph) {
BKE_volume_eval_geometry(depsgraph, (Volume *)obdata_cow);
});
op_node->set_as_entry(); op_node->set_as_entry();
break; break;
} }
@ -1450,7 +1480,9 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
add_operation_node(obdata, add_operation_node(obdata,
NodeType::BATCH_CACHE, NodeType::BATCH_CACHE,
OperationCode::GEOMETRY_SELECT_UPDATE, OperationCode::GEOMETRY_SELECT_UPDATE,
function_bind(BKE_object_data_select_update, _1, obdata_cow)); [obdata_cow](::Depsgraph *depsgraph) {
BKE_object_data_select_update(depsgraph, obdata_cow);
});
} }
void DepsgraphNodeBuilder::build_armature(bArmature *armature) void DepsgraphNodeBuilder::build_armature(bArmature *armature)
@ -1466,7 +1498,9 @@ void DepsgraphNodeBuilder::build_armature(bArmature *armature)
add_operation_node(&armature->id, add_operation_node(&armature->id,
NodeType::ARMATURE, NodeType::ARMATURE,
OperationCode::ARMATURE_EVAL, OperationCode::ARMATURE_EVAL,
function_bind(BKE_armature_refresh_layer_used, _1, armature_cow)); [armature_cow](::Depsgraph *depsgraph) {
BKE_armature_refresh_layer_used(depsgraph, armature_cow);
});
build_armature_bones(&armature->bonebase); build_armature_bones(&armature->bonebase);
} }
@ -1506,7 +1540,7 @@ void DepsgraphNodeBuilder::build_light(Light *lamp)
add_operation_node(&lamp->id, add_operation_node(&lamp->id,
NodeType::SHADING, NodeType::SHADING,
OperationCode::LIGHT_UPDATE, OperationCode::LIGHT_UPDATE,
function_bind(BKE_light_eval, _1, lamp_cow)); [lamp_cow](::Depsgraph *depsgraph) { BKE_light_eval(depsgraph, lamp_cow); });
} }
void DepsgraphNodeBuilder::build_nodetree_socket(bNodeSocket *socket) void DepsgraphNodeBuilder::build_nodetree_socket(bNodeSocket *socket)
@ -1543,11 +1577,15 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
/* Shading update. */ /* Shading update. */
add_operation_node(&ntree->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE); add_operation_node(&ntree->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE);
/* NOTE: We really pass original and CoW node trees here, this is how the /* NOTE: We really pass original and CoW node trees here, this is how the
* callback works. Ideally we need to find a better way for that. */ * callback works. Ideally we need to find a better way for that.
*
* TODO(sergey): The callback seems to be a no-op, so better to remove it. */
add_operation_node(&ntree->id, add_operation_node(&ntree->id,
NodeType::SHADING_PARAMETERS, NodeType::SHADING_PARAMETERS,
OperationCode::MATERIAL_UPDATE, OperationCode::MATERIAL_UPDATE,
function_bind(BKE_nodetree_shading_params_eval, _1, ntree_cow, ntree)); [ntree_cow, ntree](::Depsgraph *depsgraph) {
BKE_nodetree_shading_params_eval(depsgraph, ntree_cow, ntree);
});
/* nodetree's nodes... */ /* nodetree's nodes... */
LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) { LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) {
build_idproperties(bnode->prop); build_idproperties(bnode->prop);
@ -1626,10 +1664,11 @@ void DepsgraphNodeBuilder::build_material(Material *material)
add_id_node(&material->id); add_id_node(&material->id);
Material *material_cow = get_cow_datablock(material); Material *material_cow = get_cow_datablock(material);
/* Shading update. */ /* Shading update. */
add_operation_node(&material->id, add_operation_node(
&material->id,
NodeType::SHADING, NodeType::SHADING,
OperationCode::MATERIAL_UPDATE, OperationCode::MATERIAL_UPDATE,
function_bind(BKE_material_eval, _1, material_cow)); [material_cow](::Depsgraph *depsgraph) { BKE_material_eval(depsgraph, material_cow); });
build_idproperties(material->id.properties); build_idproperties(material->id.properties);
/* Material animation. */ /* Material animation. */
build_animdata(&material->id); build_animdata(&material->id);
@ -1714,7 +1753,9 @@ void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file)
add_operation_node(cache_file_id, add_operation_node(cache_file_id,
NodeType::CACHE, NodeType::CACHE,
OperationCode::FILE_CACHE_UPDATE, OperationCode::FILE_CACHE_UPDATE,
function_bind(BKE_cachefile_eval, bmain_, _1, cache_file_cow)); [bmain = bmain_, cache_file_cow](::Depsgraph *depsgraph) {
BKE_cachefile_eval(bmain, depsgraph, cache_file_cow);
});
} }
void DepsgraphNodeBuilder::build_mask(Mask *mask) void DepsgraphNodeBuilder::build_mask(Mask *mask)
@ -1729,15 +1770,16 @@ void DepsgraphNodeBuilder::build_mask(Mask *mask)
build_animdata(mask_id); build_animdata(mask_id);
build_parameters(mask_id); build_parameters(mask_id);
/* Animation based on mask's shapes. */ /* Animation based on mask's shapes. */
add_operation_node(mask_id, add_operation_node(
mask_id,
NodeType::ANIMATION, NodeType::ANIMATION,
OperationCode::MASK_ANIMATION, OperationCode::MASK_ANIMATION,
function_bind(BKE_mask_eval_animation, _1, mask_cow)); [mask_cow](::Depsgraph *depsgraph) { BKE_mask_eval_animation(depsgraph, mask_cow); });
/* Final mask evaluation. */ /* Final mask evaluation. */
add_operation_node(mask_id, add_operation_node(
NodeType::PARAMETERS, mask_id, NodeType::PARAMETERS, OperationCode::MASK_EVAL, [mask_cow](::Depsgraph *depsgraph) {
OperationCode::MASK_EVAL, BKE_mask_eval_update(depsgraph, mask_cow);
function_bind(BKE_mask_eval_update, _1, mask_cow)); });
/* Build parents. */ /* Build parents. */
LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
@ -1781,12 +1823,16 @@ void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)
add_operation_node(clip_id, add_operation_node(clip_id,
NodeType::PARAMETERS, NodeType::PARAMETERS,
OperationCode::MOVIECLIP_EVAL, OperationCode::MOVIECLIP_EVAL,
function_bind(BKE_movieclip_eval_update, _1, bmain_, clip_cow)); [bmain = bmain_, clip_cow](::Depsgraph *depsgraph) {
BKE_movieclip_eval_update(depsgraph, bmain, clip_cow);
});
add_operation_node(clip_id, add_operation_node(clip_id,
NodeType::BATCH_CACHE, NodeType::BATCH_CACHE,
OperationCode::MOVIECLIP_SELECT_UPDATE, OperationCode::MOVIECLIP_SELECT_UPDATE,
function_bind(BKE_movieclip_eval_selection_update, _1, clip_cow)); [clip_cow](::Depsgraph *depsgraph) {
BKE_movieclip_eval_selection_update(depsgraph, clip_cow);
});
} }
void DepsgraphNodeBuilder::build_lightprobe(LightProbe *probe) void DepsgraphNodeBuilder::build_lightprobe(LightProbe *probe)
@ -1826,7 +1872,9 @@ void DepsgraphNodeBuilder::build_sound(bSound *sound)
add_operation_node(&sound->id, add_operation_node(&sound->id,
NodeType::AUDIO, NodeType::AUDIO,
OperationCode::SOUND_EVAL, OperationCode::SOUND_EVAL,
function_bind(BKE_sound_evaluate, _1, bmain_, sound_cow)); [bmain = bmain_, sound_cow](::Depsgraph *depsgraph) {
BKE_sound_evaluate(depsgraph, bmain, sound_cow);
});
build_idproperties(sound->id.properties); build_idproperties(sound->id.properties);
build_animdata(&sound->id); build_animdata(&sound->id);
build_parameters(&sound->id); build_parameters(&sound->id);
@ -1849,7 +1897,9 @@ void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
add_operation_node(&simulation->id, add_operation_node(&simulation->id,
NodeType::SIMULATION, NodeType::SIMULATION,
OperationCode::SIMULATION_EVAL, OperationCode::SIMULATION_EVAL,
function_bind(BKE_simulation_data_update, _1, scene_cow, simulation_cow)); [scene_cow, simulation_cow](::Depsgraph *depsgraph) {
BKE_simulation_data_update(depsgraph, scene_cow, simulation_cow);
});
} }
void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene) void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
@ -1865,7 +1915,9 @@ void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
add_operation_node(&scene->id, add_operation_node(&scene->id,
NodeType::SEQUENCER, NodeType::SEQUENCER,
OperationCode::SEQUENCES_EVAL, OperationCode::SEQUENCES_EVAL,
function_bind(BKE_scene_eval_sequencer_sequences, _1, scene_cow)); [scene_cow](::Depsgraph *depsgraph) {
BKE_scene_eval_sequencer_sequences(depsgraph, scene_cow);
});
/* Make sure data for sequences is in the graph. */ /* Make sure data for sequences is in the graph. */
Sequence *seq; Sequence *seq;
SEQ_ALL_BEGIN (scene->ed, seq) { SEQ_ALL_BEGIN (scene->ed, seq) {
@ -1904,7 +1956,9 @@ void DepsgraphNodeBuilder::build_scene_audio(Scene *scene)
add_operation_node(&scene->id, add_operation_node(&scene->id,
NodeType::AUDIO, NodeType::AUDIO,
OperationCode::AUDIO_VOLUME, OperationCode::AUDIO_VOLUME,
function_bind(BKE_scene_update_tag_audio_volume, _1, scene_cow)); [scene_cow](::Depsgraph *depsgraph) {
BKE_scene_update_tag_audio_volume(depsgraph, scene_cow);
});
} }
void DepsgraphNodeBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer) void DepsgraphNodeBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer)

View File

@ -66,16 +66,18 @@ void DepsgraphNodeBuilder::build_pose_constraints(Object *object,
data.builder = this; data.builder = this;
data.is_parent_visible = is_object_visible; data.is_parent_visible = is_object_visible;
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data); BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data);
/* Create node for constraint stack. */ /* Create node for constraint stack. */
Scene *scene_cow = get_cow_datablock(scene_);
Object *object_cow = get_cow_datablock(object);
add_operation_node(&object->id, add_operation_node(&object->id,
NodeType::BONE, NodeType::BONE,
pchan->name, pchan->name,
OperationCode::BONE_CONSTRAINTS, OperationCode::BONE_CONSTRAINTS,
function_bind(BKE_pose_constraints_evaluate, [scene_cow, object_cow, pchan_index](::Depsgraph *depsgraph) {
_1, BKE_pose_constraints_evaluate(
get_cow_datablock(scene_), depsgraph, scene_cow, object_cow, pchan_index);
get_cow_datablock(object), });
pchan_index));
} }
/* IK Solver Eval Steps */ /* 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); int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan);
BLI_assert(rootchan_index != -1); BLI_assert(rootchan_index != -1);
/* Operation node for evaluating/running IK Solver. */ /* 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, add_operation_node(&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
rootchan->name, rootchan->name,
OperationCode::POSE_IK_SOLVER, OperationCode::POSE_IK_SOLVER,
function_bind(BKE_pose_iktree_evaluate, [scene_cow, object_cow, rootchan_index](::Depsgraph *depsgraph) {
_1, BKE_pose_iktree_evaluate(depsgraph, scene_cow, object_cow, rootchan_index);
get_cow_datablock(scene_), });
get_cow_datablock(object),
rootchan_index));
} }
/* Spline IK Eval Steps */ /* Spline IK Eval Steps */
@ -130,15 +133,17 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object,
* start. */ * start. */
int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan); int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan);
BLI_assert(rootchan_index != -1); BLI_assert(rootchan_index != -1);
Scene *scene_cow = get_cow_datablock(scene_);
Object *object_cow = get_cow_datablock(object);
add_operation_node(&object->id, add_operation_node(&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
rootchan->name, rootchan->name,
OperationCode::POSE_SPLINE_IK_SOLVER, OperationCode::POSE_SPLINE_IK_SOLVER,
function_bind(BKE_pose_splineik_evaluate, [scene_cow, object_cow, rootchan_index](::Depsgraph *depsgraph) {
_1, BKE_pose_splineik_evaluate(
get_cow_datablock(scene_), depsgraph, scene_cow, object_cow, rootchan_index);
get_cow_datablock(object), });
rootchan_index));
} }
/* Pose/Armature Bones Graph */ /* 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, op_node = add_operation_node(&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
OperationCode::POSE_INIT, 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->set_as_entry();
op_node = add_operation_node(&object->id, op_node = add_operation_node(&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
OperationCode::POSE_INIT_IK, 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, add_operation_node(&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
OperationCode::POSE_CLEANUP, OperationCode::POSE_CLEANUP,
function_bind(BKE_pose_eval_cleanup, _1, scene_cow, object_cow)); [scene_cow, object_cow](::Depsgraph *depsgraph) {
BKE_pose_eval_cleanup(depsgraph, scene_cow, object_cow);
});
op_node = add_operation_node(&object->id, op_node = add_operation_node(
&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
OperationCode::POSE_DONE, OperationCode::POSE_DONE,
function_bind(BKE_pose_eval_done, _1, object_cow)); [object_cow](::Depsgraph *depsgraph) { BKE_pose_eval_done(depsgraph, object_cow); });
op_node->set_as_exit(); op_node->set_as_exit();
/* Bones. */ /* Bones. */
int pchan_index = 0; int pchan_index = 0;
@ -223,7 +235,9 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible)
NodeType::BONE, NodeType::BONE,
pchan->name, pchan->name,
OperationCode::BONE_POSE_PARENT, 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. */ /* NOTE: Dedicated noop for easier relationship construction. */
add_operation_node(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_READY); 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, NodeType::BONE,
pchan->name, pchan->name,
OperationCode::BONE_DONE, 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. */ /* B-Bone shape computation - the real last step if present. */
if (check_pchan_has_bbone(object, pchan)) { if (check_pchan_has_bbone(object, pchan)) {
op_node = add_operation_node( op_node = add_operation_node(&object->id,
&object->id,
NodeType::BONE, NodeType::BONE,
pchan->name, pchan->name,
OperationCode::BONE_SEGMENTS, OperationCode::BONE_SEGMENTS,
function_bind(BKE_pose_eval_bbone_segments, _1, object_cow, pchan_index)); [object_cow, pchan_index](::Depsgraph *depsgraph) {
BKE_pose_eval_bbone_segments(
depsgraph, object_cow, pchan_index);
});
} }
op_node->set_as_exit(); 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) { if (object->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
BKE_pose_update_constraint_flags(object->pose); BKE_pose_update_constraint_flags(object->pose);
} }
op_node = add_operation_node(&object->id, op_node = add_operation_node(
&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
OperationCode::POSE_INIT, OperationCode::POSE_INIT,
function_bind(BKE_pose_eval_proxy_init, _1, object_cow)); [object_cow](::Depsgraph *depsgraph) { BKE_pose_eval_proxy_init(depsgraph, object_cow); });
op_node->set_as_entry(); op_node->set_as_entry();
int pchan_index = 0; int pchan_index = 0;
@ -318,12 +337,14 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visibl
/* Bone is ready for solvers. */ /* Bone is ready for solvers. */
add_operation_node(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_READY); add_operation_node(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_READY);
/* Bone is fully evaluated. */ /* Bone is fully evaluated. */
op_node = add_operation_node( op_node = add_operation_node(&object->id,
&object->id,
NodeType::BONE, NodeType::BONE,
pchan->name, pchan->name,
OperationCode::BONE_DONE, OperationCode::BONE_DONE,
function_bind(BKE_pose_eval_proxy_copy_bone, _1, object_cow, pchan_index)); [object_cow, pchan_index](::Depsgraph *depsgraph) {
BKE_pose_eval_proxy_copy_bone(
depsgraph, object_cow, pchan_index);
});
op_node->set_as_exit(); op_node->set_as_exit();
/* Custom properties. */ /* Custom properties. */
@ -343,11 +364,14 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visibl
op_node = add_operation_node(&object->id, op_node = add_operation_node(&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
OperationCode::POSE_CLEANUP, OperationCode::POSE_CLEANUP,
function_bind(BKE_pose_eval_proxy_cleanup, _1, object_cow)); [object_cow](::Depsgraph *depsgraph) {
op_node = add_operation_node(&object->id, BKE_pose_eval_proxy_cleanup(depsgraph, object_cow);
});
op_node = add_operation_node(
&object->id,
NodeType::EVAL_POSE, NodeType::EVAL_POSE,
OperationCode::POSE_DONE, OperationCode::POSE_DONE,
function_bind(BKE_pose_eval_proxy_done, _1, object_cow)); [object_cow](::Depsgraph *depsgraph) { BKE_pose_eval_proxy_done(depsgraph, object_cow); });
op_node->set_as_exit(); op_node->set_as_exit();
} }

View File

@ -160,11 +160,12 @@ void DepsgraphNodeBuilder::build_view_layer(Scene *scene,
build_scene_sequencer(scene); build_scene_sequencer(scene);
} }
/* Collections. */ /* Collections. */
add_operation_node( add_operation_node(&scene->id,
&scene->id,
NodeType::LAYER_COLLECTIONS, NodeType::LAYER_COLLECTIONS,
OperationCode::VIEW_LAYER_EVAL, OperationCode::VIEW_LAYER_EVAL,
function_bind(BKE_layer_eval_view_layer_indexed, _1, scene_cow, view_layer_index_)); [view_layer_index = view_layer_index_, scene_cow](::Depsgraph *depsgraph) {
BKE_layer_eval_view_layer_indexed(depsgraph, scene_cow, view_layer_index);
});
/* Parameters evaluation for scene relations mainly. */ /* Parameters evaluation for scene relations mainly. */
build_scene_compositor(scene); build_scene_compositor(scene);
build_scene_parameters(scene); build_scene_parameters(scene);