Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/depsgraph_tag.cc
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| #include "intern/depsgraph_update.h" | #include "intern/depsgraph_update.h" | ||||
| #include "intern/eval/deg_eval_copy_on_write.h" | #include "intern/eval/deg_eval_copy_on_write.h" | ||||
| #include "intern/eval/deg_eval_flush.h" | #include "intern/eval/deg_eval_flush.h" | ||||
| #include "intern/node/deg_node.h" | #include "intern/node/deg_node.h" | ||||
| #include "intern/node/deg_node_component.h" | #include "intern/node/deg_node_component.h" | ||||
| #include "intern/node/deg_node_factory.h" | #include "intern/node/deg_node_factory.h" | ||||
| #include "intern/node/deg_node_id.h" | #include "intern/node/deg_node_id.h" | ||||
| #include "intern/node/deg_node_operation.h" | #include "intern/node/deg_node_operation.h" | ||||
| #include "intern/node/deg_node_time.h" | |||||
| namespace deg = blender::deg; | namespace deg = blender::deg; | ||||
| /* *********************** */ | /* *********************** */ | ||||
| /* Update Tagging/Flushing */ | /* Update Tagging/Flushing */ | ||||
| namespace blender { | namespace blender { | ||||
| namespace deg { | namespace deg { | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | case ID_RECALC_AUDIO: | ||||
| *component_type = NodeType::AUDIO; | *component_type = NodeType::AUDIO; | ||||
| break; | break; | ||||
| case ID_RECALC_PARAMETERS: | case ID_RECALC_PARAMETERS: | ||||
| *component_type = NodeType::PARAMETERS; | *component_type = NodeType::PARAMETERS; | ||||
| break; | break; | ||||
| case ID_RECALC_SOURCE: | case ID_RECALC_SOURCE: | ||||
| *component_type = NodeType::PARAMETERS; | *component_type = NodeType::PARAMETERS; | ||||
| break; | break; | ||||
| case ID_RECALC_TIME: | |||||
| BLI_assert(!"Should be handled outside of this function"); | |||||
| break; | |||||
| case ID_RECALC_ALL: | case ID_RECALC_ALL: | ||||
| case ID_RECALC_PSYS_ALL: | case ID_RECALC_PSYS_ALL: | ||||
| BLI_assert(!"Should not happen"); | BLI_assert(!"Should not happen"); | ||||
| break; | break; | ||||
| case ID_RECALC_TAG_FOR_UNDO: | case ID_RECALC_TAG_FOR_UNDO: | ||||
| break; /* Must be ignored by depsgraph. */ | break; /* Must be ignored by depsgraph. */ | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | void graph_id_tag_update_single_flag(Main *bmain, | ||||
| eUpdateSource update_source) | eUpdateSource update_source) | ||||
| { | { | ||||
| if (tag == ID_RECALC_EDITORS) { | if (tag == ID_RECALC_EDITORS) { | ||||
| if (graph != nullptr && graph->is_active) { | if (graph != nullptr && graph->is_active) { | ||||
| depsgraph_update_editors_tag(bmain, graph, id); | depsgraph_update_editors_tag(bmain, graph, id); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| if (tag == ID_RECALC_TIME) { | |||||
| if (graph != nullptr) { | |||||
| graph->need_update_time = true; | |||||
| } | |||||
| return; | |||||
| } | |||||
| /* Get description of what is to be tagged. */ | /* Get description of what is to be tagged. */ | ||||
| NodeType component_type; | NodeType component_type; | ||||
| OperationCode operation_code; | OperationCode operation_code; | ||||
| depsgraph_tag_to_component_opcode(id, tag, &component_type, &operation_code); | depsgraph_tag_to_component_opcode(id, tag, &component_type, &operation_code); | ||||
| /* Check whether we've got something to tag. */ | /* Check whether we've got something to tag. */ | ||||
| if (component_type == NodeType::UNDEFINED) { | if (component_type == NodeType::UNDEFINED) { | ||||
| /* Given ID does not support tag. */ | /* Given ID does not support tag. */ | ||||
| /* TODO(sergey): Shall we raise some panic here? */ | /* TODO(sergey): Shall we raise some panic here? */ | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | 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() | int deg_recalc_flags_for_legacy_zero() | ||||
| { | { | ||||
| return ID_RECALC_ALL & ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION | ID_RECALC_SOURCE | | return ID_RECALC_ALL & | ||||
| ID_RECALC_TIME | ID_RECALC_EDITORS); | ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION | ID_RECALC_SOURCE | ID_RECALC_EDITORS); | ||||
| } | } | ||||
| int deg_recalc_flags_effective(Depsgraph *graph, int flags) | int deg_recalc_flags_effective(Depsgraph *graph, int flags) | ||||
| { | { | ||||
| if (graph != nullptr) { | if (graph != nullptr) { | ||||
| if (!graph->is_active) { | if (!graph->is_active) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | switch (flag) { | ||||
| case ID_RECALC_AUDIO_MUTE: | case ID_RECALC_AUDIO_MUTE: | ||||
| return "AUDIO_MUTE"; | return "AUDIO_MUTE"; | ||||
| case ID_RECALC_AUDIO_LISTENER: | case ID_RECALC_AUDIO_LISTENER: | ||||
| return "AUDIO_LISTENER"; | return "AUDIO_LISTENER"; | ||||
| case ID_RECALC_AUDIO: | case ID_RECALC_AUDIO: | ||||
| return "AUDIO"; | return "AUDIO"; | ||||
| case ID_RECALC_PARAMETERS: | case ID_RECALC_PARAMETERS: | ||||
| return "PARAMETERS"; | return "PARAMETERS"; | ||||
| case ID_RECALC_TIME: | |||||
| return "TIME"; | |||||
| case ID_RECALC_SOURCE: | case ID_RECALC_SOURCE: | ||||
| return "SOURCE"; | return "SOURCE"; | ||||
| case ID_RECALC_ALL: | case ID_RECALC_ALL: | ||||
| return "ALL"; | return "ALL"; | ||||
| case ID_RECALC_TAG_FOR_UNDO: | case ID_RECALC_TAG_FOR_UNDO: | ||||
| return "TAG_FOR_UNDO"; | return "TAG_FOR_UNDO"; | ||||
| } | } | ||||
| return nullptr; | return nullptr; | ||||
| Show All 20 Lines | void DEG_graph_id_tag_update(struct Main *bmain, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| struct ID *id, | struct ID *id, | ||||
| int flag) | int flag) | ||||
| { | { | ||||
| deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; | deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; | ||||
| deg::graph_id_tag_update(bmain, graph, id, flag, deg::DEG_UPDATE_SOURCE_USER_EDIT); | deg::graph_id_tag_update(bmain, graph, id, flag, deg::DEG_UPDATE_SOURCE_USER_EDIT); | ||||
| } | } | ||||
| void DEG_time_tag_update(struct Main *bmain) | |||||
| { | |||||
| for (deg::Depsgraph *depsgraph : deg::get_all_registered_graphs(bmain)) { | |||||
| DEG_graph_time_tag_update(reinterpret_cast<::Depsgraph *>(depsgraph)); | |||||
| } | |||||
| } | |||||
| void DEG_graph_time_tag_update(struct Depsgraph *depsgraph) | |||||
| { | |||||
| deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); | |||||
| deg::TimeSourceNode *time_source = deg_graph->find_time_source(); | |||||
| time_source->tag_update(deg_graph, deg::DEG_UPDATE_SOURCE_TIME); | |||||
sybren: Why does this code need to know that a timesource needs tagging with `deg… | |||||
| } | |||||
| /* Mark a particular datablock type as having changing. */ | /* Mark a particular datablock type as having changing. */ | ||||
| void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type) | void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type) | ||||
| { | { | ||||
| if (id_type == ID_NT) { | if (id_type == ID_NT) { | ||||
| /* Stupid workaround so parent datablocks of nested nodetree get looped | /* Stupid workaround so parent datablocks of nested nodetree get looped | ||||
| * over when we loop over tagged datablock types. */ | * over when we loop over tagged datablock types. */ | ||||
| DEG_graph_id_type_tag(depsgraph, ID_MA); | DEG_graph_id_type_tag(depsgraph, ID_MA); | ||||
| DEG_graph_id_type_tag(depsgraph, ID_TE); | DEG_graph_id_type_tag(depsgraph, ID_TE); | ||||
| ▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines | |||||
Why does this code need to know that a timesource needs tagging with deg::DEG_UPDATE_SOURCE_TIME? Shouldn't this be a function Depsgraph::tag_time_source() instead? See the Law of Demeter.