diff options
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
4 files changed, 91 insertions, 73 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 22bce10937d..a739a0fe337 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -112,6 +112,7 @@ #include "DEG_depsgraph_build.h" #include "SEQ_iterator.h" +#include "SEQ_sequencer.h" #include "intern/builder/deg_builder.h" #include "intern/builder/deg_builder_rna.h" @@ -2032,6 +2033,27 @@ void DepsgraphNodeBuilder::build_simulation(Simulation *simulation) }); } +static bool seq_node_build_cb(Sequence *seq, void *user_data) +{ + DepsgraphNodeBuilder *nb = (DepsgraphNodeBuilder *)user_data; + nb->build_idproperties(seq->prop); + if (seq->sound != nullptr) { + nb->build_sound(seq->sound); + } + if (seq->scene != nullptr) { + nb->build_scene_parameters(seq->scene); + } + if (seq->type == SEQ_TYPE_SCENE && seq->scene != nullptr) { + if (seq->flag & SEQ_SCENE_STRIPS) { + nb->build_scene_sequencer(seq->scene); + } + ViewLayer *sequence_view_layer = BKE_view_layer_default_render(seq->scene); + nb->build_scene_speakers(seq->scene, sequence_view_layer); + } + /* TODO(sergey): Movie clip, scene, camera, mask. */ + return true; +} + void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene) { if (scene->ed == nullptr) { @@ -2046,28 +2068,10 @@ void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene) NodeType::SEQUENCER, OperationCode::SEQUENCES_EVAL, [scene_cow](::Depsgraph *depsgraph) { - BKE_scene_eval_sequencer_sequences(depsgraph, scene_cow); + SEQ_eval_sequences(depsgraph, scene_cow, &scene_cow->ed->seqbase); }); /* Make sure data for sequences is in the graph. */ - Sequence *seq; - SEQ_ALL_BEGIN (scene->ed, seq) { - build_idproperties(seq->prop); - if (seq->sound != nullptr) { - build_sound(seq->sound); - } - if (seq->scene != nullptr) { - build_scene_parameters(seq->scene); - } - if (seq->type == SEQ_TYPE_SCENE && seq->scene != nullptr) { - if (seq->flag & SEQ_SCENE_STRIPS) { - build_scene_sequencer(seq->scene); - } - ViewLayer *sequence_view_layer = BKE_view_layer_default_render(seq->scene); - build_scene_speakers(seq->scene, sequence_view_layer); - } - /* TODO(sergey): Movie clip, scene, camera, mask. */ - } - SEQ_ALL_END; + SEQ_for_each_callback(&scene->ed->seqbase, seq_node_build_cb, this); } void DepsgraphNodeBuilder::build_scene_audio(Scene *scene) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index d88e9bc9c04..ab3081cb1ae 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2769,6 +2769,45 @@ void DepsgraphRelationBuilder::build_simulation(Simulation *simulation) add_relation(nodetree_key, simulation_eval_key, "NodeTree -> Simulation", 0); } +using Seq_build_prop_cb_data = struct Seq_build_prop_cb_data { + DepsgraphRelationBuilder *builder; + ComponentKey sequencer_key; + bool has_audio_strips; +}; + +static bool seq_build_prop_cb(Sequence *seq, void *user_data) +{ + Seq_build_prop_cb_data *cd = (Seq_build_prop_cb_data *)user_data; + + cd->builder->build_idproperties(seq->prop); + if (seq->sound != nullptr) { + cd->builder->build_sound(seq->sound); + ComponentKey sound_key(&seq->sound->id, NodeType::AUDIO); + cd->builder->add_relation(sound_key, cd->sequencer_key, "Sound -> Sequencer"); + cd->has_audio_strips = true; + } + if (seq->scene != nullptr) { + cd->builder->build_scene_parameters(seq->scene); + /* This is to support 3D audio. */ + cd->has_audio_strips = true; + } + if (seq->type == SEQ_TYPE_SCENE && seq->scene != nullptr) { + if (seq->flag & SEQ_SCENE_STRIPS) { + cd->builder->build_scene_sequencer(seq->scene); + ComponentKey sequence_scene_audio_key(&seq->scene->id, NodeType::AUDIO); + cd->builder->add_relation( + sequence_scene_audio_key, cd->sequencer_key, "Sequence Scene Audio -> Sequencer"); + ComponentKey sequence_scene_key(&seq->scene->id, NodeType::SEQUENCER); + cd->builder->add_relation( + sequence_scene_key, cd->sequencer_key, "Sequence Scene -> Sequencer"); + } + ViewLayer *sequence_view_layer = BKE_view_layer_default_render(seq->scene); + cd->builder->build_scene_speakers(seq->scene, sequence_view_layer); + } + /* TODO(sergey): Movie clip, camera, mask. */ + return true; +} + void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene) { if (scene->ed == nullptr) { @@ -2781,36 +2820,11 @@ void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene) ComponentKey scene_audio_key(&scene->id, NodeType::AUDIO); /* Make sure dependencies from sequences data goes to the sequencer evaluation. */ ComponentKey sequencer_key(&scene->id, NodeType::SEQUENCER); - Sequence *seq; - bool has_audio_strips = false; - SEQ_ALL_BEGIN (scene->ed, seq) { - build_idproperties(seq->prop); - if (seq->sound != nullptr) { - build_sound(seq->sound); - ComponentKey sound_key(&seq->sound->id, NodeType::AUDIO); - add_relation(sound_key, sequencer_key, "Sound -> Sequencer"); - has_audio_strips = true; - } - if (seq->scene != nullptr) { - build_scene_parameters(seq->scene); - /* This is to support 3D audio. */ - has_audio_strips = true; - } - if (seq->type == SEQ_TYPE_SCENE && seq->scene != nullptr) { - if (seq->flag & SEQ_SCENE_STRIPS) { - build_scene_sequencer(seq->scene); - ComponentKey sequence_scene_audio_key(&seq->scene->id, NodeType::AUDIO); - add_relation(sequence_scene_audio_key, sequencer_key, "Sequence Scene Audio -> Sequencer"); - ComponentKey sequence_scene_key(&seq->scene->id, NodeType::SEQUENCER); - add_relation(sequence_scene_key, sequencer_key, "Sequence Scene -> Sequencer"); - } - ViewLayer *sequence_view_layer = BKE_view_layer_default_render(seq->scene); - build_scene_speakers(seq->scene, sequence_view_layer); - } - /* TODO(sergey): Movie clip, camera, mask. */ - } - SEQ_ALL_END; - if (has_audio_strips) { + + Seq_build_prop_cb_data cb_data = {this, sequencer_key, false}; + + SEQ_for_each_callback(&scene->ed->seqbase, seq_build_prop_cb, &cb_data); + if (cb_data.has_audio_strips) { add_relation(sequencer_key, scene_audio_key, "Sequencer -> Audio"); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc index b9ce29ce8d2..bf3af571f0b 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc @@ -125,13 +125,13 @@ static bool is_reachable(const Node *const from, const Node *const to) return true; } - // Perform a graph walk from 'to' towards its incoming connections. - // Walking from 'from' towards its outgoing connections is 10x slower on the Spring rig. + /* Perform a graph walk from 'to' towards its incoming connections. + * Walking from 'from' towards its outgoing connections is 10x slower on the Spring rig. */ deque<const Node *> queue; Set<const Node *> seen; queue.push_back(to); while (!queue.empty()) { - // Visit the next node to inspect. + /* Visit the next node to inspect. */ const Node *visit = queue.back(); queue.pop_back(); @@ -139,7 +139,7 @@ static bool is_reachable(const Node *const from, const Node *const to) return true; } - // Queue all incoming relations that we haven't seen before. + /* Queue all incoming relations that we haven't seen before. */ for (Relation *relation : visit->inlinks) { const Node *prev_node = relation->from; if (seen.add(prev_node)) { @@ -177,7 +177,7 @@ void DepsgraphRelationBuilder::build_driver_relations(IDNode *id_node) return; } - // Mapping from RNA prefix -> set of driver descriptors: + /* Mapping from RNA prefix -> set of driver descriptors: */ Map<string, Vector<DriverDescriptor>> driver_groups; PointerRNA id_ptr; @@ -197,47 +197,47 @@ void DepsgraphRelationBuilder::build_driver_relations(IDNode *id_node) } for (Span<DriverDescriptor> prefix_group : driver_groups.values()) { - // For each node in the driver group, try to connect it to another node - // in the same group without creating any cycles. + /* For each node in the driver group, try to connect it to another node + * in the same group without creating any cycles. */ int num_drivers = prefix_group.size(); if (num_drivers < 2) { - // A relation requires two drivers. + /* A relation requires two drivers. */ continue; } for (int from_index = 0; from_index < num_drivers; ++from_index) { const DriverDescriptor &driver_from = prefix_group[from_index]; Node *op_from = get_node(driver_from.depsgraph_key()); - // Start by trying the next node in the group. + /* Start by trying the next node in the group. */ for (int to_offset = 1; to_offset < num_drivers; ++to_offset) { const int to_index = (from_index + to_offset) % num_drivers; const DriverDescriptor &driver_to = prefix_group[to_index]; Node *op_to = get_node(driver_to.depsgraph_key()); - // Duplicate drivers can exist (see T78615), but cannot be distinguished by OperationKey - // and thus have the same depsgraph node. Relations between those drivers should not be - // created. This not something that is expected to happen (both the UI and the Python API - // prevent duplicate drivers), it did happen in a file and it is easy to deal with here. + /* Duplicate drivers can exist (see T78615), but cannot be distinguished by OperationKey + * and thus have the same depsgraph node. Relations between those drivers should not be + * created. This not something that is expected to happen (both the UI and the Python API + * prevent duplicate drivers), it did happen in a file and it is easy to deal with here. */ if (op_from == op_to) { continue; } if (from_index < to_index && driver_from.is_same_array_as(driver_to)) { - // This is for adding a relation like `color[0]` -> `color[1]`. - // When the search for another driver wraps around, we cannot blindly add relations any - // more. + /* This is for adding a relation like `color[0]` -> `color[1]`. + * When the search for another driver wraps around, + * we cannot blindly add relations any more. */ } else { - // Investigate whether this relation would create a dependency cycle. - // Example graph: - // A -> B -> C - // and investigating a potential connection C->A. Because A->C is an - // existing transitive connection, adding C->A would create a cycle. + /* Investigate whether this relation would create a dependency cycle. + * Example graph: + * A -> B -> C + * and investigating a potential connection C->A. Because A->C is an + * existing transitive connection, adding C->A would create a cycle. */ if (is_reachable(op_to, op_from)) { continue; } - // No need to directly connect this node if there is already a transitive connection. + /* No need to directly connect this node if there is already a transitive connection. */ if (is_reachable(op_from, op_to)) { break; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc index e0a7a42ea4a..bad4e96c60b 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc @@ -28,7 +28,7 @@ namespace blender::deg { //////////////////////////////////////////////////////////////////////////////// -// Time source. +/* Time source. */ TimeSourceKey::TimeSourceKey() : id(nullptr) { |