diff options
Diffstat (limited to 'source/blender/depsgraph')
25 files changed, 204 insertions, 119 deletions
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index 27441c9a7ae..749b1bba871 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -159,7 +159,7 @@ void DEG_ids_restore_recalc(Depsgraph *depsgraph); /* Graph Evaluation ----------------------------- */ /* Frame changed recalculation entry point. */ -void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime); +void DEG_evaluate_on_framechange(Depsgraph *graph, float frame); /* Data changed recalculation entry point. */ void DEG_evaluate_on_refresh(Depsgraph *graph); diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index 42c9cccceed..c029d203574 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -33,6 +33,7 @@ struct Depsgraph; /* ------------------------------------------------ */ struct CacheFile; +struct Collection; struct CustomData_MeshMasks; struct ID; struct Main; @@ -40,7 +41,6 @@ struct Object; struct Scene; struct Simulation; struct bNodeTree; -struct Collection; #include "BLI_sys_types.h" diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h index f877e99b16b..17f5ca0db79 100644 --- a/source/blender/depsgraph/DEG_depsgraph_query.h +++ b/source/blender/depsgraph/DEG_depsgraph_query.h @@ -95,7 +95,7 @@ struct ViewLayer *DEG_get_evaluated_view_layer(const struct Depsgraph *graph); /* Get evaluated version of object for given original one. */ struct Object *DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object); -/* Get evaluated version of given ID datablock. */ +/* Get evaluated version of given ID data-block. */ struct ID *DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id); /* Get evaluated version of data pointed to by RNA pointer */ @@ -106,7 +106,7 @@ void DEG_get_evaluated_rna_pointer(const struct Depsgraph *depsgraph, /* Get original version of object for given evaluated one. */ struct Object *DEG_get_original_object(struct Object *object); -/* Get original version of given evaluated ID datablock. */ +/* Get original version of given evaluated ID data-block. */ struct ID *DEG_get_original_id(struct ID *id); /* Check whether given ID is an original, @@ -122,7 +122,7 @@ bool DEG_is_original_object(const struct Object *object); bool DEG_is_evaluated_id(const struct ID *id); bool DEG_is_evaluated_object(const struct Object *object); -/* Check whether depsgraph os fully evaluated. This includes the following checks: +/* Check whether depsgraph is fully evaluated. This includes the following checks: * - Relations are up-to-date. * - Nothing is tagged for update. */ bool DEG_is_fully_evaluated(const struct Depsgraph *depsgraph); @@ -180,7 +180,7 @@ void DEG_iterator_objects_next(struct BLI_Iterator *iter); void DEG_iterator_objects_end(struct BLI_Iterator *iter); /** - * Note: Be careful with DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY objects. + * NOTE: Be careful with DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY objects. * Although they are available they have no overrides (collection_properties) * and will crash if you try to access it. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index f4d65698bee..41512168f57 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -97,7 +97,7 @@ bool DepsgraphBuilder::need_pull_base_into_graph(Base *base) property_id = AnimatedPropertyID(&object->id, &RNA_Object, "hide_render"); } else { - BLI_assert(!"Unknown evaluation mode."); + BLI_assert_msg(0, "Unknown evaluation mode."); return false; } return cache_->isPropertyAnimated(&object->id, property_id); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 56168739fae..e561d0b653c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -114,6 +114,7 @@ #include "SEQ_iterator.h" #include "intern/builder/deg_builder.h" +#include "intern/builder/deg_builder_rna.h" #include "intern/depsgraph.h" #include "intern/depsgraph_tag.h" #include "intern/depsgraph_type.h" @@ -226,7 +227,7 @@ OperationNode *DepsgraphNodeBuilder::add_operation_node(ComponentNode *comp_node comp_node->identifier().c_str(), op_node->identifier().c_str(), op_node); - BLI_assert(!"Should not happen!"); + BLI_assert_msg(0, "Should not happen!"); } return op_node; } @@ -1199,7 +1200,7 @@ void DepsgraphNodeBuilder::build_driver_id_property(ID *id, const char *rna_path if (prop == nullptr) { return; } - if (!RNA_property_is_idprop(prop)) { + if (!rna_prop_affects_parameters_node(&ptr, prop)) { return; } const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop); @@ -1495,7 +1496,7 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_ob add_operation_node( &object->id, NodeType::BATCH_CACHE, - OperationCode::GEOMETRY_SELECT_UPDATE, + OperationCode::BATCH_UPDATE_SELECT, [object_cow](::Depsgraph *depsgraph) { BKE_object_select_update(depsgraph, object_cow); }); } @@ -1516,33 +1517,37 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool if (key) { build_shapekeys(key); } - /* Nodes for result of obdata's evaluation, and geometry - * evaluation on object. */ + + /* Geometry evaluation. */ + /* Entry operation, takes care of initialization, and some other + * relations which needs to be run prior to actual geometry evaluation. */ + op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT); + op_node->set_as_entry(); + + add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_DEFORM); + const ID_Type id_type = GS(obdata->name); switch (id_type) { case ID_ME: { - op_node = add_operation_node(obdata, - NodeType::GEOMETRY, - OperationCode::GEOMETRY_EVAL, - [obdata_cow](::Depsgraph *depsgraph) { - BKE_mesh_eval_geometry(depsgraph, (Mesh *)obdata_cow); - }); - op_node->set_as_entry(); + add_operation_node(obdata, + NodeType::GEOMETRY, + OperationCode::GEOMETRY_EVAL, + [obdata_cow](::Depsgraph *depsgraph) { + BKE_mesh_eval_geometry(depsgraph, (Mesh *)obdata_cow); + }); break; } case ID_MB: { - op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); - op_node->set_as_entry(); + add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); break; } case ID_CU: { - op_node = add_operation_node(obdata, - NodeType::GEOMETRY, - OperationCode::GEOMETRY_EVAL, - [obdata_cow](::Depsgraph *depsgraph) { - BKE_curve_eval_geometry(depsgraph, (Curve *)obdata_cow); - }); - op_node->set_as_entry(); + add_operation_node(obdata, + NodeType::GEOMETRY, + OperationCode::GEOMETRY_EVAL, + [obdata_cow](::Depsgraph *depsgraph) { + BKE_curve_eval_geometry(depsgraph, (Curve *)obdata_cow); + }); /* Make sure objects used for bevel.taper are in the graph. * NOTE: This objects might be not linked to the scene. */ Curve *cu = (Curve *)obdata; @@ -1558,51 +1563,45 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool break; } case ID_LT: { - op_node = add_operation_node(obdata, - NodeType::GEOMETRY, - OperationCode::GEOMETRY_EVAL, - [obdata_cow](::Depsgraph *depsgraph) { - BKE_lattice_eval_geometry(depsgraph, (Lattice *)obdata_cow); - }); - op_node->set_as_entry(); + add_operation_node(obdata, + NodeType::GEOMETRY, + OperationCode::GEOMETRY_EVAL, + [obdata_cow](::Depsgraph *depsgraph) { + BKE_lattice_eval_geometry(depsgraph, (Lattice *)obdata_cow); + }); break; } case ID_GD: { /* GPencil evaluation operations. */ - op_node = add_operation_node(obdata, - NodeType::GEOMETRY, - OperationCode::GEOMETRY_EVAL, - [obdata_cow](::Depsgraph *depsgraph) { - BKE_gpencil_frame_active_set(depsgraph, - (bGPdata *)obdata_cow); - }); - op_node->set_as_entry(); + add_operation_node(obdata, + NodeType::GEOMETRY, + OperationCode::GEOMETRY_EVAL, + [obdata_cow](::Depsgraph *depsgraph) { + BKE_gpencil_frame_active_set(depsgraph, (bGPdata *)obdata_cow); + }); break; } case ID_HA: { - op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); - op_node->set_as_entry(); + add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); break; } case ID_PT: { - op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); - op_node->set_as_entry(); + add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); break; } case ID_VO: { /* Volume frame update. */ - op_node = add_operation_node(obdata, - NodeType::GEOMETRY, - OperationCode::GEOMETRY_EVAL, - [obdata_cow](::Depsgraph *depsgraph) { - BKE_volume_eval_geometry(depsgraph, (Volume *)obdata_cow); - }); - op_node->set_as_entry(); + add_operation_node(obdata, + NodeType::GEOMETRY, + OperationCode::GEOMETRY_EVAL, + [obdata_cow](::Depsgraph *depsgraph) { + BKE_volume_eval_geometry(depsgraph, (Volume *)obdata_cow); + }); break; } default: - BLI_assert(!"Should not happen"); + BLI_assert_msg(0, "Should not happen"); break; } op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_DONE); @@ -1612,10 +1611,22 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool /* Batch cache. */ add_operation_node(obdata, NodeType::BATCH_CACHE, - OperationCode::GEOMETRY_SELECT_UPDATE, + OperationCode::BATCH_UPDATE_SELECT, [obdata_cow](::Depsgraph *depsgraph) { BKE_object_data_select_update(depsgraph, obdata_cow); }); + add_operation_node(obdata, + NodeType::BATCH_CACHE, + OperationCode::BATCH_UPDATE_DEFORM, + [obdata_cow](::Depsgraph *depsgraph) { + BKE_object_data_eval_batch_cache_deform_tag(depsgraph, obdata_cow); + }); + add_operation_node(obdata, + NodeType::BATCH_CACHE, + OperationCode::BATCH_UPDATE_ALL, + [obdata_cow](::Depsgraph *depsgraph) { + BKE_object_data_eval_batch_cache_dirty_tag(depsgraph, obdata_cow); + }); } void DepsgraphNodeBuilder::build_armature(bArmature *armature) @@ -1769,7 +1780,7 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree) build_nodetree(group_ntree); } else { - BLI_assert(!"Unknown ID type used for node"); + BLI_assert_msg(0, "Unknown ID type used for node"); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 151e0d844b6..3b2dd44af0d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -289,7 +289,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { * setting the current state. */ Collection *collection_; /* Accumulated flag over the hierarchy of currently building collections. - * Denotes whether all the hierarchy from parent of collection_ to the + * Denotes whether all the hierarchy from parent of `collection_` to the * very root is visible (aka not restricted.). */ bool is_parent_collection_visible_; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index c269ad16824..c63b3d825a0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -326,7 +326,7 @@ void DepsgraphRelationBuilder::add_customdata_mask(Object *object, IDNode *id_node = graph_->find_id_node(&object->id); if (id_node == nullptr) { - BLI_assert(!"ID should always be valid"); + BLI_assert_msg(0, "ID should always be valid"); } else { id_node->customdata_masks |= customdata_masks; @@ -338,7 +338,7 @@ void DepsgraphRelationBuilder::add_special_eval_flag(ID *id, uint32_t flag) { IDNode *id_node = graph_->find_id_node(id); if (id_node == nullptr) { - BLI_assert(!"ID should always be valid"); + BLI_assert_msg(0, "ID should always be valid"); } else { id_node->eval_flags |= flag; @@ -647,7 +647,7 @@ void DepsgraphRelationBuilder::build_collection(LayerCollection *from_layer_coll /* Only create geometry relations to child objects, if they have a geometry component. */ OperationKey object_geometry_key{ - &cob->ob->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL}; + &cob->ob->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT}; if (find_node(object_geometry_key) != nullptr) { add_relation(object_geometry_key, collection_geometry_key, "Collection Geometry"); } @@ -1099,7 +1099,14 @@ void DepsgraphRelationBuilder::build_object_pointcache(Object *object) else { flag = FLAG_GEOMETRY; OperationKey geometry_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); - add_relation(point_cache_key, geometry_key, "Point Cache -> Geometry"); + add_relation(point_cache_key, geometry_key, "Point Cache -> Geometry Eval"); + if (object->data) { + /* Geometry may change, so rebuild the Drawing Cache. */ + OperationKey object_data_batch_all_key( + (ID *)object->data, NodeType::BATCH_CACHE, OperationCode::BATCH_UPDATE_ALL); + add_relation( + point_cache_key, object_data_batch_all_key, "Point Cache -> Batch Update All"); + } } BLI_assert(flag != -1); /* Tag that we did handle that component. */ @@ -1610,7 +1617,7 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) } } } - if (property_entry_key.prop != nullptr && RNA_property_is_idprop(property_entry_key.prop)) { + if (rna_prop_affects_parameters_node(&property_entry_key.ptr, property_entry_key.prop)) { RNAPathKey property_exit_key(property_entry_key.id, property_entry_key.ptr, property_entry_key.prop, @@ -1713,7 +1720,7 @@ void DepsgraphRelationBuilder::build_driver_id_property(ID *id, const char *rna_ if (prop == nullptr) { return; } - if (!RNA_property_is_idprop(prop)) { + if (!rna_prop_affects_parameters_node(&ptr, prop)) { return; } const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop); @@ -1868,7 +1875,8 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) void DepsgraphRelationBuilder::build_particle_systems(Object *object) { TimeSourceKey time_src_key; - OperationKey obdata_ubereval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); + OperationKey obdata_ubereval_key( + &object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT); OperationKey eval_init_key( &object->id, NodeType::PARTICLE_SYSTEM, OperationCode::PARTICLE_SYSTEM_INIT); OperationKey eval_done_key( @@ -2016,7 +2024,8 @@ void DepsgraphRelationBuilder::build_particle_system_visualization_object(Object { OperationKey psys_key( &object->id, NodeType::PARTICLE_SYSTEM, OperationCode::PARTICLE_SYSTEM_EVAL, psys->name); - OperationKey obdata_ubereval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); + OperationKey obdata_ubereval_key( + &object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT); ComponentKey dup_ob_key(&draw_object->id, NodeType::TRANSFORM); add_relation(dup_ob_key, psys_key, "Particle Object Visualization"); if (draw_object->type == OB_MBALL) { @@ -2073,15 +2082,15 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) /* Get nodes for result of obdata's evaluation, and geometry evaluation * on object. */ ComponentKey obdata_geom_key(obdata, NodeType::GEOMETRY); - ComponentKey geom_key(&object->id, NodeType::GEOMETRY); - /* Link components to each other. */ - add_relation(obdata_geom_key, geom_key, "Object Geometry Base Data"); OperationKey obdata_ubereval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); + /* Link components to each other. */ + add_relation(obdata_geom_key, obdata_ubereval_key, "Object Geometry Base Data"); + /* Special case: modifiers evaluation queries scene for various things like * data mask to be used. We add relation here to ensure object is never * evaluated prior to Scene's CoW is ready. */ OperationKey scene_key(&scene_->id, NodeType::PARAMETERS, OperationCode::SCENE_EVAL); - Relation *rel = add_relation(scene_key, obdata_ubereval_key, "CoW Relation"); + Relation *rel = add_relation(scene_key, geom_init_key, "CoW Relation"); rel->flag |= RELATION_FLAG_NO_FLUSH; /* Modifiers */ if (object->modifiers.first != nullptr) { @@ -2091,13 +2100,13 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type); if (mti->updateDepsgraph) { - DepsNodeHandle handle = create_node_handle(obdata_ubereval_key); + DepsNodeHandle handle = create_node_handle(geom_init_key); ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle); mti->updateDepsgraph(md, &ctx); } if (BKE_object_modifier_use_time(object, md)) { TimeSourceKey time_src_key; - add_relation(time_src_key, obdata_ubereval_key, "Time Source"); + add_relation(time_src_key, geom_init_key, "Time Source"); } } } @@ -2110,13 +2119,13 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info( (GpencilModifierType)md->type); if (mti->updateDepsgraph) { - DepsNodeHandle handle = create_node_handle(obdata_ubereval_key); + DepsNodeHandle handle = create_node_handle(geom_init_key); ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle); mti->updateDepsgraph(md, &ctx, graph_->mode); } if (BKE_object_modifier_gpencil_use_time(object, md)) { TimeSourceKey time_src_key; - add_relation(time_src_key, obdata_ubereval_key, "Time Source"); + add_relation(time_src_key, geom_init_key, "Time Source"); } } } @@ -2128,13 +2137,13 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) LISTBASE_FOREACH (ShaderFxData *, fx, &object->shader_fx) { const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info((ShaderFxType)fx->type); if (fxi->updateDepsgraph) { - DepsNodeHandle handle = create_node_handle(obdata_ubereval_key); + DepsNodeHandle handle = create_node_handle(geom_init_key); ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle); fxi->updateDepsgraph(fx, &ctx); } if (BKE_object_shaderfx_use_time(object, fx)) { TimeSourceKey time_src_key; - add_relation(time_src_key, obdata_ubereval_key, "Time Source"); + add_relation(time_src_key, geom_init_key, "Time Source"); } } } @@ -2160,6 +2169,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) add_relation(mom_transform_key, mom_geom_key, "Metaball Motherball Transform -> Geometry"); } else { + ComponentKey geom_key(&object->id, NodeType::GEOMETRY); ComponentKey transform_key(&object->id, NodeType::TRANSFORM); add_relation(geom_key, mom_geom_key, "Metaball Motherball"); add_relation(transform_key, mom_geom_key, "Metaball Motherball"); @@ -2174,9 +2184,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) * Ideally we need to get rid of this relation. */ if (object_particles_depends_on_time(object)) { TimeSourceKey time_key; - OperationKey obdata_ubereval_key( - &object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); - add_relation(time_key, obdata_ubereval_key, "Legacy particle time"); + add_relation(time_key, geom_init_key, "Legacy particle time"); } /* Object data data-block. */ build_object_data_geometry_datablock((ID *)object->data); @@ -2198,12 +2206,33 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) add_relation(final_geometry_key, synchronize_key, "Synchronize to Original"); /* Batch cache. */ OperationKey object_data_select_key( - obdata, NodeType::BATCH_CACHE, OperationCode::GEOMETRY_SELECT_UPDATE); + obdata, NodeType::BATCH_CACHE, OperationCode::BATCH_UPDATE_SELECT); OperationKey object_select_key( - &object->id, NodeType::BATCH_CACHE, OperationCode::GEOMETRY_SELECT_UPDATE); + &object->id, NodeType::BATCH_CACHE, OperationCode::BATCH_UPDATE_SELECT); + add_relation(object_data_select_key, object_select_key, "Data Selection -> Object Selection"); + add_relation(final_geometry_key, + object_select_key, + "Object Geometry -> Select Update", + RELATION_FLAG_NO_FLUSH); + + OperationKey object_data_geom_deform_key( + obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_DEFORM); + OperationKey object_data_geom_init_key( + obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT); + + OperationKey object_data_batch_deform_key( + obdata, NodeType::BATCH_CACHE, OperationCode::BATCH_UPDATE_DEFORM); + OperationKey object_data_batch_all_key( + obdata, NodeType::BATCH_CACHE, OperationCode::BATCH_UPDATE_ALL); + + add_relation(geom_init_key, object_data_batch_all_key, "Object Geometry -> Batch Update All"); + add_relation( - geom_key, object_select_key, "Object Geometry -> Select Update", RELATION_FLAG_NO_FLUSH); + object_data_geom_init_key, object_data_batch_all_key, "Data Init -> Batch Update All"); + add_relation(object_data_geom_deform_key, + object_data_batch_deform_key, + "Data Deform -> Batch Update Deform"); } void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) @@ -2221,8 +2250,13 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) build_shapekeys(key); } /* Link object data evaluation node to exit operation. */ + OperationKey obdata_geom_deform_key( + obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_DEFORM); + OperationKey obdata_geom_init_key(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT); OperationKey obdata_geom_eval_key(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); OperationKey obdata_geom_done_key(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_DONE); + add_relation(obdata_geom_init_key, obdata_geom_eval_key, "ObData Init -> Geom Eval"); + add_relation(obdata_geom_deform_key, obdata_geom_eval_key, "ObData Deform -> Geom Eval"); add_relation(obdata_geom_eval_key, obdata_geom_done_key, "ObData Geom Eval Done"); /* Type-specific links. */ const ID_Type id_type = GS(obdata->name); @@ -2314,7 +2348,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) break; } default: - BLI_assert(!"Should not happen"); + BLI_assert_msg(0, "Should not happen"); break; } } @@ -2497,7 +2531,7 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree) add_relation(group_shading_key, shading_key, "Group Node"); } else { - BLI_assert(!"Unknown ID type used for node"); + BLI_assert_msg(0, "Unknown ID type used for node"); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h index 035d636b977..14ed153832d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h @@ -54,7 +54,7 @@ Relation *DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, } else { if (!op_from) { - /* XXX TODO handle as error or report if needed */ + /* XXX TODO: handle as error or report if needed. */ fprintf(stderr, "add_relation(%s) - Could not find op_from (%s)\n", description, @@ -67,7 +67,7 @@ Relation *DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, key_from.identifier().c_str()); } if (!op_to) { - /* XXX TODO handle as error or report if needed */ + /* XXX TODO: handle as error or report if needed. */ fprintf(stderr, "add_relation(%s) - Could not find op_to (%s)\n", description, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index 54c51adec66..8e3960e1a15 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -180,7 +180,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, node_identifier.operation_name = ""; node_identifier.operation_name_tag = -1; /* Handling of commonly known scenarios. */ - if (prop != nullptr && RNA_property_is_idprop(prop)) { + if (rna_prop_affects_parameters_node(ptr, prop)) { node_identifier.type = NodeType::PARAMETERS; node_identifier.operation_code = OperationCode::ID_PROPERTY; node_identifier.operation_name = RNA_property_identifier( @@ -397,4 +397,12 @@ RNANodeQueryIDData *RNANodeQuery::ensure_id_data(const ID *id) return id_data.get(); } +bool rna_prop_affects_parameters_node(const PointerRNA *ptr, const PropertyRNA *prop) +{ + return prop != nullptr && RNA_property_is_idprop(prop) && + /* ID properties in the geometry nodes modifier don't affect that parameters node. Instead + they affect the modifier and therefore the geometry node directly. */ + !RNA_struct_is_a(ptr->type, &RNA_NodesModifier); +} + } // namespace blender::deg diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.h b/source/blender/depsgraph/intern/builder/deg_builder_rna.h index d03903d508c..24d7f5f3a30 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.h @@ -108,5 +108,7 @@ class RNANodeQuery { static bool contains(const char *prop_identifier, const char *rna_path_component); }; +bool rna_prop_affects_parameters_node(const PointerRNA *ptr, const PropertyRNA *prop); + } // namespace deg } // namespace blender diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc index 9afae0f2c22..57c6f062611 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc @@ -461,7 +461,7 @@ static void deg_debug_graphviz_node_relations(DotExportContext &ctx, const Node dot::DirectedEdge &edge = ctx.digraph.new_edge(dot_tail, dot_head); - /* Note: without label an id seem necessary to avoid bugs in graphviz/dot */ + /* NOTE: without label an id seem necessary to avoid bugs in graphviz/dot. */ edge.attributes.set("id", rel->name); deg_debug_graphviz_relation_color(rel, edge); deg_debug_graphviz_relation_style(rel, edge); diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 6fe7d5f5d8b..4c036417ba0 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -68,7 +68,8 @@ Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluati scene(scene), view_layer(view_layer), mode(mode), - ctime(BKE_scene_frame_get(scene)), + frame(BKE_scene_frame_get(scene)), + ctime(BKE_scene_ctime_get(scene)), scene_cow(nullptr), is_active(false), is_evaluating(false), @@ -267,7 +268,7 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const * - Object or mesh has material at a slot which is not used (for * example, object has material slot by materials are set to * object data). */ - // BLI_assert(!"Request for non-existing copy-on-write ID"); + // BLI_assert_msg(0, "Request for non-existing copy-on-write ID"); } return (ID *)id_orig; } diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index ff536c19c05..913b61ca563 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -140,7 +140,9 @@ struct Depsgraph { ViewLayer *view_layer; eEvaluationMode mode; - /* Time at which dependency graph is being or was last evaluated. */ + /* Time at which dependency graph is being or was last evaluated. + * frame is the value before, and ctime the value after time remapping. */ + float frame; float ctime; /* Evaluated version of datablocks we access a lot. diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index c5e306f3148..3677f80469c 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -96,7 +96,7 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph, DEG_graph_build_from_view_layer(temp_depsgraph); if (!DEG_debug_compare(temp_depsgraph, graph)) { fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n"); - BLI_assert(!"This should not happen!"); + BLI_assert_msg(0, "This should not happen!"); valid = false; } DEG_graph_free(temp_depsgraph); diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc index 1ad3fdbc9da..cc7ce871419 100644 --- a/source/blender/depsgraph/intern/depsgraph_eval.cc +++ b/source/blender/depsgraph/intern/depsgraph_eval.cc @@ -51,7 +51,7 @@ static void deg_flush_updates_and_refresh(deg::Depsgraph *deg_graph) { /* Update the time on the cow scene. */ if (deg_graph->scene_cow) { - BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->ctime); + BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->frame); } deg::deg_graph_flush_updates(deg_graph); @@ -63,10 +63,12 @@ void DEG_evaluate_on_refresh(Depsgraph *graph) { deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); const Scene *scene = DEG_get_input_scene(graph); - const float ctime = BKE_scene_frame_get(scene); + const float frame = BKE_scene_frame_get(scene); + const float ctime = BKE_scene_ctime_get(scene); - if (ctime != deg_graph->ctime) { + if (deg_graph->frame != frame || ctime != deg_graph->ctime) { deg_graph->tag_time_source(); + deg_graph->frame = frame; deg_graph->ctime = ctime; } @@ -74,10 +76,13 @@ void DEG_evaluate_on_refresh(Depsgraph *graph) } /* Frame-change happened for root scene that graph belongs to. */ -void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime) +void DEG_evaluate_on_framechange(Depsgraph *graph, float frame) { deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); + const Scene *scene = DEG_get_input_scene(graph); + deg_graph->tag_time_source(); - deg_graph->ctime = ctime; + deg_graph->frame = frame; + deg_graph->ctime = BKE_scene_frame_to_ctime(scene, frame); deg_flush_updates_and_refresh(deg_graph); } diff --git a/source/blender/depsgraph/intern/depsgraph_physics.cc b/source/blender/depsgraph/intern/depsgraph_physics.cc index 8f3aab19e37..a70c0c10de0 100644 --- a/source/blender/depsgraph/intern/depsgraph_physics.cc +++ b/source/blender/depsgraph/intern/depsgraph_physics.cc @@ -59,7 +59,7 @@ static ePhysicsRelationType modifier_to_relation_type(unsigned int modifier_type return DEG_PHYSICS_DYNAMIC_BRUSH; } - BLI_assert(!"Unknown collision modifier type"); + BLI_assert_msg(0, "Unknown collision modifier type"); return DEG_PHYSICS_RELATIONS_NUM; } /* Get ID from an ID type object, in a safe manner. This means that object can be nullptr, @@ -80,7 +80,7 @@ ListBase *DEG_get_effector_relations(const Depsgraph *graph, Collection *collect if (hash == nullptr) { return nullptr; } - /* Note: nullptr is a valid lookup key here as it means that the relation is not bound to a + /* NOTE: nullptr is a valid lookup key here as it means that the relation is not bound to a * specific collection. */ ID *collection_orig = DEG_get_original_id(object_id_safe(collection)); return hash->lookup_default(collection_orig, nullptr); @@ -96,7 +96,7 @@ ListBase *DEG_get_collision_relations(const Depsgraph *graph, if (hash == nullptr) { return nullptr; } - /* Note: nullptr is a valid lookup key here as it means that the relation is not bound to a + /* NOTE: nullptr is a valid lookup key here as it means that the relation is not bound to a * specific collection. */ ID *collection_orig = DEG_get_original_id(object_id_safe(collection)); return hash->lookup_default(collection_orig, nullptr); diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index b00cae87311..34b33e9a6c0 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -117,7 +117,7 @@ void depsgraph_select_tag_to_component_opcode(const ID *id, } else if (is_selectable_data_id_type(id_type)) { *component_type = NodeType::BATCH_CACHE; - *operation_code = OperationCode::GEOMETRY_SELECT_UPDATE; + *operation_code = OperationCode::BATCH_UPDATE_SELECT; } else { *component_type = NodeType::COPY_ON_WRITE; @@ -168,6 +168,11 @@ void depsgraph_tag_to_component_opcode(const ID *id, break; case ID_RECALC_GEOMETRY: depsgraph_geometry_tag_to_component(id, component_type); + *operation_code = OperationCode::GEOMETRY_EVAL_INIT; + break; + case ID_RECALC_GEOMETRY_DEFORM: + depsgraph_geometry_tag_to_component(id, component_type); + *operation_code = OperationCode::GEOMETRY_EVAL_DEFORM; break; case ID_RECALC_ANIMATION: *component_type = NodeType::ANIMATION; @@ -233,7 +238,7 @@ void depsgraph_tag_to_component_opcode(const ID *id, case ID_RECALC_GEOMETRY_ALL_MODES: case ID_RECALC_ALL: case ID_RECALC_PSYS_ALL: - BLI_assert(!"Should not happen"); + BLI_assert_msg(0, "Should not happen"); break; case ID_RECALC_TAG_FOR_UNDO: break; /* Must be ignored by depsgraph. */ @@ -452,7 +457,7 @@ const char *update_source_as_string(eUpdateSource source) case DEG_UPDATE_SOURCE_VISIBILITY: return "VISIBILITY"; } - BLI_assert(!"Should never happen."); + BLI_assert_msg(0, "Should never happen."); return "UNKNOWN"; } @@ -708,6 +713,8 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag) return "GEOMETRY"; case ID_RECALC_GEOMETRY_ALL_MODES: return "GEOMETRY_ALL_MODES"; + case ID_RECALC_GEOMETRY_DEFORM: + return "GEOMETRY_DEFORM"; case ID_RECALC_ANIMATION: return "ANIMATION"; case ID_RECALC_PSYS_REDO: diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc index 6f35143e28f..915b9fedcec 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval.cc @@ -223,7 +223,7 @@ bool need_evaluate_operation_at_stage(DepsgraphEvalState *state, case EvaluationStage::SINGLE_THREADED_WORKAROUND: return true; } - BLI_assert(!"Unhandled evaluation stage, should never happen."); + BLI_assert_msg(0, "Unhandled evaluation stage, should never happen."); return false; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 0d367762b00..346eba5bbc2 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -899,7 +899,7 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph, done = id_copy_inplace_no_main(id_orig, id_cow); } if (!done) { - BLI_assert(!"No idea how to perform CoW on datablock"); + BLI_assert_msg(0, "No idea how to perform CoW on datablock"); } /* Update pointers to nested ID datablocks. */ DEG_COW_PRINT( diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 1b24e2b7ad2..2cbb0b52e34 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -144,7 +144,10 @@ inline void flush_handle_component_node(IDNode *id_node, * special component where we don't want all operations to be tagged. * * TODO(sergey): Make this a more generic solution. */ - if (!ELEM(comp_node->type, NodeType::PARTICLE_SETTINGS, NodeType::PARTICLE_SYSTEM)) { + if (!ELEM(comp_node->type, + NodeType::PARTICLE_SETTINGS, + NodeType::PARTICLE_SYSTEM, + NodeType::BATCH_CACHE)) { for (OperationNode *op : comp_node->operations) { op->flag |= DEPSOP_FLAG_NEEDS_UPDATE; } diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc index 0d3563ee3de..fee5342df59 100644 --- a/source/blender/depsgraph/intern/node/deg_node.cc +++ b/source/blender/depsgraph/intern/node/deg_node.cc @@ -48,7 +48,7 @@ const char *nodeClassAsString(NodeClass node_class) case NodeClass::OPERATION: return "OPERATION"; } - BLI_assert(!"Unhandled node class, should never happen."); + BLI_assert_msg(0, "Unhandled node class, should never happen."); return "UNKNOWN"; } @@ -121,7 +121,7 @@ const char *nodeTypeAsString(NodeType type) case NodeType::NUM_TYPES: return "SpecialCase"; } - BLI_assert(!"Unhandled node type, should never happen."); + BLI_assert_msg(0, "Unhandled node type, should never happen."); return "UNKNOWN"; } @@ -177,7 +177,7 @@ eDepsSceneComponentType nodeTypeToSceneComponent(NodeType type) case NodeType::SIMULATION: return DEG_SCENE_COMP_PARAMETERS; } - BLI_assert(!"Unhandled node type, not suppsed to happen."); + BLI_assert_msg(0, "Unhandled node type, not suppsed to happen."); return DEG_SCENE_COMP_PARAMETERS; } @@ -253,7 +253,7 @@ eDepsObjectComponentType nodeTypeToObjectComponent(NodeType type) case NodeType::NUM_TYPES: return DEG_OB_COMP_PARAMETERS; } - BLI_assert(!"Unhandled node type, not suppsed to happen."); + BLI_assert_msg(0, "Unhandled node type, not suppsed to happen."); return DEG_OB_COMP_PARAMETERS; } diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc index d824fb14718..431bf536b65 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.cc +++ b/source/blender/depsgraph/intern/node/deg_node_component.cc @@ -142,7 +142,7 @@ OperationNode *ComponentNode::get_operation(OperationIDKey key) const "%s: find_operation(%s) failed\n", this->identifier().c_str(), key.identifier().c_str()); - BLI_assert(!"Request for non-existing operation, should not happen"); + BLI_assert_msg(0, "Request for non-existing operation, should not happen"); return nullptr; } return node; @@ -181,7 +181,7 @@ OperationNode *ComponentNode::add_operation(const DepsEvalOperationCb &op, OperationIDKey key(opcode, name, name_tag); operations_map->add(key, op_node); - /* set backlink */ + /* Set back-link. */ op_node->owner = this; } else { @@ -190,7 +190,7 @@ OperationNode *ComponentNode::add_operation(const DepsEvalOperationCb &op, this->identifier().c_str(), op_node->identifier().c_str(), op_node); - BLI_assert(!"Should not happen!"); + BLI_assert_msg(0, "Should not happen!"); } /* attach extra data */ diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 688afe141e9..2b1ebc663fe 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -53,7 +53,7 @@ const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state) case DEG_ID_LINKED_DIRECTLY: return "DIRECTLY"; } - BLI_assert(!"Unhandled linked state, should never happen."); + BLI_assert_msg(0, "Unhandled linked state, should never happen."); return "UNKNOWN"; } diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc index 7e57467f905..d98486b83a8 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.cc +++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc @@ -98,6 +98,8 @@ const char *operationCodeAsString(OperationCode opcode) /* Geometry. */ case OperationCode::GEOMETRY_EVAL_INIT: return "GEOMETRY_EVAL_INIT"; + case OperationCode::GEOMETRY_EVAL_DEFORM: + return "GEOMETRY_EVAL_DEFORM"; case OperationCode::GEOMETRY_EVAL: return "GEOMETRY_EVAL"; case OperationCode::GEOMETRY_EVAL_DONE: @@ -160,8 +162,12 @@ const char *operationCodeAsString(OperationCode opcode) case OperationCode::FILE_CACHE_UPDATE: return "FILE_CACHE_UPDATE"; /* Batch cache. */ - case OperationCode::GEOMETRY_SELECT_UPDATE: - return "GEOMETRY_SELECT_UPDATE"; + case OperationCode::BATCH_UPDATE_SELECT: + return "BATCH_UPDATE_SELECT"; + case OperationCode::BATCH_UPDATE_DEFORM: + return "BATCH_UPDATE_DEFORM"; + case OperationCode::BATCH_UPDATE_ALL: + return "BATCH_UPDATE_ALL"; /* Masks. */ case OperationCode::MASK_ANIMATION: return "MASK_ANIMATION"; @@ -205,7 +211,7 @@ const char *operationCodeAsString(OperationCode opcode) case OperationCode::SIMULATION_EVAL: return "SIMULATION_EVAL"; } - BLI_assert(!"Unhandled operation code, should never happen."); + BLI_assert_msg(0, "Unhandled operation code, should never happen."); return "UNKNOWN"; } diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h index a17186da941..b0130d03c69 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.h +++ b/source/blender/depsgraph/intern/node/deg_node_operation.h @@ -100,7 +100,11 @@ enum class OperationCode { /* Initialize evaluation of the geometry. Is an entry operation of geometry * component. */ GEOMETRY_EVAL_INIT, - /* Evaluate the whole geometry, including modifiers. */ + /* Evaluate the geometry, including modifiers, and update only batches that + * are affected by deform operations. */ + GEOMETRY_EVAL_DEFORM, + /* Evaluate the geometry, including modifiers, but don't update the batch + * cache. */ GEOMETRY_EVAL, /* Evaluation of geometry is completely done. */ GEOMETRY_EVAL_DONE, @@ -178,7 +182,9 @@ enum class OperationCode { WORLD_UPDATE, /* Batch caches. -------------------------------------------------------- */ - GEOMETRY_SELECT_UPDATE, + BATCH_UPDATE_SELECT, + BATCH_UPDATE_DEFORM, + BATCH_UPDATE_ALL, /* Masks. --------------------------------------------------------------- */ MASK_ANIMATION, |