Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/depsgraph_tag.cc
| Show First 20 Lines • Show All 441 Lines • ▼ Show 20 Lines | case DEG_UPDATE_SOURCE_RELATIONS: | ||||
| return "RELATIONS"; | return "RELATIONS"; | ||||
| case DEG_UPDATE_SOURCE_VISIBILITY: | case DEG_UPDATE_SOURCE_VISIBILITY: | ||||
| return "VISIBILITY"; | return "VISIBILITY"; | ||||
| } | } | ||||
| BLI_assert(!"Should never happen."); | BLI_assert(!"Should never happen."); | ||||
| return "UNKNOWN"; | return "UNKNOWN"; | ||||
| } | } | ||||
| int deg_recalc_flags_for_legacy_zero() | |||||
campbellbarton: Why not make this a static function? | |||||
Done Inline ActionsIt's in the anonymous namespace, which is effectively static function. sergey: It's in the anonymous namespace, which is effectively static function. | |||||
| { | |||||
| return ID_RECALC_ALL & ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION); | |||||
| } | |||||
| int deg_recalc_flags_effective(Depsgraph *graph, int flags) | |||||
| { | |||||
| if (graph != NULL) { | |||||
| if (!graph->is_active) { | |||||
| return 0; | |||||
Not Done Inline ActionsThis is not going into 2.80 I guess? So not sure why we need to be overly paranoid. brecht: This is not going into 2.80 I guess? So not sure why we need to be overly paranoid. | |||||
| } | |||||
| } | |||||
| if (flags == 0) { | |||||
| return deg_recalc_flags_for_legacy_zero(); | |||||
| } | |||||
| return flags; | |||||
| } | |||||
| /* Special tag function which tags all components which needs to be tagged | /* Special tag function which tags all components which needs to be tagged | ||||
| * for update flag=0. | * for update flag=0. | ||||
| * | * | ||||
| * TODO(sergey): This is something to be avoid in the future, make it more | * TODO(sergey): This is something to be avoid in the future, make it more | ||||
| * explicit and granular for users to tag what they really need. */ | * explicit and granular for users to tag what they really need. */ | ||||
| void deg_graph_node_tag_zero(Main *bmain, | void deg_graph_node_tag_zero(Main *bmain, | ||||
| Depsgraph *graph, | Depsgraph *graph, | ||||
| IDNode *id_node, | IDNode *id_node, | ||||
| eUpdateSource update_source) | eUpdateSource update_source) | ||||
| { | { | ||||
| if (id_node == NULL) { | if (id_node == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| ID *id = id_node->id_orig; | ID *id = id_node->id_orig; | ||||
| /* TODO(sergey): Which recalc flags to set here? */ | /* TODO(sergey): Which recalc flags to set here? */ | ||||
| id_node->id_cow->recalc |= ID_RECALC_ALL & ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION); | id_node->id_cow->recalc |= deg_recalc_flags_for_legacy_zero(); | ||||
| GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, id_node->components) { | GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, id_node->components) { | ||||
| if (comp_node->type == NodeType::ANIMATION) { | if (comp_node->type == NodeType::ANIMATION) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| comp_node->tag_update(graph, update_source); | comp_node->tag_update(graph, update_source); | ||||
| } | } | ||||
| GHASH_FOREACH_END(); | GHASH_FOREACH_END(); | ||||
| deg_graph_id_tag_legacy_compat(bmain, graph, id, (IDRecalcFlag)0, update_source); | deg_graph_id_tag_legacy_compat(bmain, graph, id, (IDRecalcFlag)0, update_source); | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | void graph_id_tag_update( | ||||
| if (flag == 0) { | if (flag == 0) { | ||||
| deg_graph_node_tag_zero(bmain, graph, id_node, update_source); | deg_graph_node_tag_zero(bmain, graph, id_node, update_source); | ||||
| } | } | ||||
| /* Store original flag in the ID. | /* Store original flag in the ID. | ||||
| * Allows to have more granularity than a node-factory based flags. */ | * Allows to have more granularity than a node-factory based flags. */ | ||||
| if (id_node != NULL) { | if (id_node != NULL) { | ||||
| id_node->id_cow->recalc |= flag; | id_node->id_cow->recalc |= flag; | ||||
| } | } | ||||
| /* When ID is tagged for update based on an user edits store the recalc flags in the original ID. | |||||
| * This way IDs in the undo steps will have this flag preserved, making it possible to restore | |||||
| * all needed tags when new dependency graph is created on redo. | |||||
| * This is the only way to ensure modifications to animation data (such as keyframes i.e.) | |||||
| * properly triggers animation update for the newely constructed dependency graph on redo (while | |||||
| * usually newly created dependency graph skips animation update to avoid loss of unkeyed | |||||
| * changes). */ | |||||
| if (update_source == DEG_UPDATE_SOURCE_USER_EDIT) { | |||||
| id->recalc |= deg_recalc_flags_effective(graph, flag); | |||||
| } | |||||
| int current_flag = flag; | int current_flag = flag; | ||||
| while (current_flag != 0) { | while (current_flag != 0) { | ||||
| IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_i(¤t_flag)); | IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_i(¤t_flag)); | ||||
| graph_id_tag_update_single_flag(bmain, graph, id, id_node, tag, update_source); | graph_id_tag_update_single_flag(bmain, graph, id, id_node, tag, update_source); | ||||
| } | } | ||||
| /* Special case for nested node tree datablocks. */ | /* Special case for nested node tree datablocks. */ | ||||
| id_tag_update_ntree_special(bmain, graph, id, flag, update_source); | id_tag_update_ntree_special(bmain, graph, id, flag, update_source); | ||||
| /* Direct update tags means that something outside of simulated/cached | /* Direct update tags means that something outside of simulated/cached | ||||
| ▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | void DEG_ids_check_recalc( | ||||
| DEGEditorUpdateContext update_ctx = {NULL}; | DEGEditorUpdateContext update_ctx = {NULL}; | ||||
| update_ctx.bmain = bmain; | update_ctx.bmain = bmain; | ||||
| update_ctx.depsgraph = depsgraph; | update_ctx.depsgraph = depsgraph; | ||||
| update_ctx.scene = scene; | update_ctx.scene = scene; | ||||
| update_ctx.view_layer = view_layer; | update_ctx.view_layer = view_layer; | ||||
| DEG::deg_editors_scene_update(&update_ctx, updated); | DEG::deg_editors_scene_update(&update_ctx, updated); | ||||
| } | } | ||||
| static void deg_graph_clear_id_recalc_flags(ID *id) | |||||
| { | |||||
| id->recalc &= ~ID_RECALC_ALL; | |||||
| bNodeTree *ntree = ntreeFromID(id); | |||||
| /* Clear embedded node trees too. */ | |||||
| if (ntree) { | |||||
| ntree->id.recalc &= ~ID_RECALC_ALL; | |||||
| } | |||||
| } | |||||
| static void deg_graph_clear_id_node_func(void *__restrict data_v, | static void deg_graph_clear_id_node_func(void *__restrict data_v, | ||||
| const int i, | const int i, | ||||
| const ParallelRangeTLS *__restrict /*tls*/) | const ParallelRangeTLS *__restrict /*tls*/) | ||||
| { | { | ||||
| /* TODO: we clear original ID recalc flags here, but this may not work | /* TODO: we clear original ID recalc flags here, but this may not work | ||||
| * correctly when there are multiple depsgraph with others still using | * correctly when there are multiple depsgraph with others still using | ||||
| * the recalc flag. */ | * the recalc flag. */ | ||||
| DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(data_v); | DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(data_v); | ||||
| DEG::IDNode *id_node = deg_graph->id_nodes[i]; | DEG::IDNode *id_node = deg_graph->id_nodes[i]; | ||||
| id_node->is_user_modified = false; | id_node->is_user_modified = false; | ||||
| id_node->id_cow->recalc &= ~ID_RECALC_ALL; | |||||
| /* Clear embedded node trees too. */ | deg_graph_clear_id_recalc_flags(id_node->id_cow); | ||||
| bNodeTree *ntree_cow = ntreeFromID(id_node->id_cow); | if (deg_graph->is_active) { | ||||
| if (ntree_cow) { | deg_graph_clear_id_recalc_flags(id_node->id_orig); | ||||
| ntree_cow->id.recalc &= ~ID_RECALC_ALL; | |||||
| } | } | ||||
| } | } | ||||
| void DEG_ids_clear_recalc(Main *UNUSED(bmain), Depsgraph *depsgraph) | void DEG_ids_clear_recalc(Main *UNUSED(bmain), Depsgraph *depsgraph) | ||||
| { | { | ||||
| DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); | DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); | ||||
| /* TODO(sergey): Re-implement POST_UPDATE_HANDLER_WORKAROUND using entry_tags | /* TODO(sergey): Re-implement POST_UPDATE_HANDLER_WORKAROUND using entry_tags | ||||
| * and id_tags storage from the new dependency graph. */ | * and id_tags storage from the new dependency graph. */ | ||||
| Show All 11 Lines | |||||
Why not make this a static function?