Sequencer: Fix missing sound from nested scene strips

This commit is contained in:
Sergey Sharybin 2019-06-07 11:27:34 +02:00
parent d4a5691d0f
commit 7081935a30
8 changed files with 68 additions and 7 deletions

View File

@ -2454,8 +2454,16 @@ void BKE_scene_eval_sequencer_sequences(Depsgraph *depsgraph, Scene *scene)
BKE_sound_ensure_scene(scene);
Sequence *seq;
SEQ_BEGIN (scene->ed, seq) {
if (seq->sound != NULL && seq->scene_sound == NULL) {
seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq);
if (seq->scene_sound == NULL) {
if (seq->sound != NULL) {
seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq);
}
else if (seq->type == SEQ_TYPE_SCENE) {
if (seq->scene != NULL) {
BKE_sound_ensure_scene(seq->scene);
seq->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene, seq);
}
}
}
if (seq->scene_sound) {
BKE_sound_set_scene_sound_volume(

View File

@ -605,6 +605,7 @@ void *BKE_sound_add_scene_sound(
if (sequence->sound == NULL) {
return NULL;
}
sound_verify_evaluated_id(&sequence->sound->id);
const double fps = FPS;
void *handle = AUD_Sequence_add(scene->sound_scene,
sequence->sound->playback_handle,

View File

@ -40,10 +40,11 @@ class BuilderMap {
TAG_SCENE_COMPOSITOR = (1 << 4),
TAG_SCENE_SEQUENCER = (1 << 5),
TAG_SCENE_AUDIO = (1 << 5),
/* All ID components has been built. */
TAG_COMPLETE = (TAG_ANIMATION | TAG_PARAMETERS | TAG_TRANSFORM | TAG_GEOMETRY |
TAG_SCENE_COMPOSITOR | TAG_SCENE_SEQUENCER),
TAG_SCENE_COMPOSITOR | TAG_SCENE_SEQUENCER | TAG_SCENE_AUDIO),
};
BuilderMap();

View File

@ -1582,7 +1582,8 @@ void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
if (scene->ed == NULL) {
return;
}
Scene *scene_cow = get_cow_datablock(scene_);
build_scene_audio(scene);
Scene *scene_cow = get_cow_datablock(scene);
add_operation_node(&scene->id,
NodeType::SEQUENCER,
OperationCode::SEQUENCES_EVAL,
@ -1593,6 +1594,14 @@ void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
if (seq->sound != NULL) {
build_sound(seq->sound);
}
if (seq->scene != NULL) {
build_scene_parameters(seq->scene);
}
if (seq->type == SEQ_TYPE_SCENE && seq->flag & SEQ_SCENE_STRIPS) {
if (seq->scene != NULL) {
build_scene_sequencer(seq->scene);
}
}
/* TODO(sergey): Movie clip, scene, camera, mask. */
}
SEQ_END;
@ -1600,6 +1609,9 @@ void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
void DepsgraphNodeBuilder::build_scene_audio(Scene *scene)
{
if (built_map_.checkIsBuiltAndTag(scene, BuilderMap::TAG_SCENE_AUDIO)) {
return;
}
add_operation_node(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
}

View File

@ -2331,6 +2331,8 @@ void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
if (scene->ed == NULL) {
return;
}
build_scene_audio(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;
@ -2342,11 +2344,22 @@ void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
add_relation(sound_key, sequencer_key, "Sound -> Sequencer");
has_audio_strips = true;
}
/* TODO(sergey): Movie clip, scene, camera, mask. */
if (seq->scene != NULL) {
build_scene_parameters(seq->scene);
/* This is to support 3D audio. */
has_audio_strips = true;
}
if (seq->type == SEQ_TYPE_SCENE && seq->flag & SEQ_SCENE_STRIPS) {
if (seq->scene != NULL) {
build_scene_sequencer(seq->scene);
ComponentKey sequence_scene_audio_key(&seq->scene->id, NodeType::AUDIO);
add_relation(sequence_scene_audio_key, scene_audio_key, "Sequence Audio -> Scene Audio");
}
}
/* TODO(sergey): Movie clip, camera, mask. */
}
SEQ_END;
if (has_audio_strips) {
ComponentKey scene_audio_key(&scene->id, NodeType::AUDIO);
add_relation(sequencer_key, scene_audio_key, "Sequencer -> Audio");
}
}

View File

@ -65,6 +65,7 @@
#endif
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
/* own include */
#include "sequencer_intern.h"
@ -314,6 +315,7 @@ static void sequencer_add_apply_replace_sel(bContext *C, wmOperator *op, Sequenc
/* add scene operator */
static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
@ -352,6 +354,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
BKE_sequence_invalidate_cache_composite(scene, seq);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;

View File

@ -65,6 +65,7 @@
#include "UI_interface.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
/* own include */
#include "sequencer_intern.h"
@ -2320,6 +2321,7 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot)
/* delete operator */
static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
@ -2373,6 +2375,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;

View File

@ -76,6 +76,7 @@ const EnumPropertyItem rna_enum_sequence_modifier_type_items[] = {
# include "WM_api.h"
# include "DEG_depsgraph.h"
# include "DEG_depsgraph_build.h"
# include "IMB_imbuf.h"
@ -155,6 +156,25 @@ static void rna_Sequence_invalidate_composite_update(Main *UNUSED(bmain),
}
}
static void rna_Sequence_use_sequence(Main *bmain, Scene *scene, PointerRNA *ptr)
{
/* General update callback. */
rna_Sequence_invalidate_raw_update(bmain, scene, ptr);
/* Chaning recursion changes set of IDs which needs to be remapped by the copy-on-write.
* the only way for this currently is to tag the ID for ID_RECALC_COPY_ON_WRITE. */
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed) {
Sequence *seq = (Sequence *)ptr->data;
if (seq->scene != NULL) {
DEG_id_tag_update(&seq->scene->id, ID_RECALC_COPY_ON_WRITE);
}
}
/* The sequencer scene is to be updated as well, including new relations from the nested
* sequencer. */
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
DEG_relations_tag_update(bmain);
}
static void rna_SequenceEditor_sequences_all_begin(CollectionPropertyIterator *iter,
PointerRNA *ptr)
{
@ -2203,7 +2223,7 @@ static void rna_def_scene(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SCENE_STRIPS);
RNA_def_property_ui_text(
prop, "Use Sequence", "Use scenes sequence strips directly, instead of rendering");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_use_sequence");
prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_SCENE_NO_GPENCIL);