diff options
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 72 |
1 files changed, 61 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d17990d4bee..9fcbf209cba 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -37,6 +37,7 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_sequence_types.h" +#include "DNA_sound_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" @@ -308,8 +309,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons flag_subdata); } - /* before scene copy */ - BKE_sound_create_scene(sce_dst); + BKE_sound_reset_scene_runtime(sce_dst); /* Copy sequencer, this is local data! */ if (sce_src->ed) { @@ -399,8 +399,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) sce_copy->r.ffcodecdata.properties = IDP_CopyProperty(sce->r.ffcodecdata.properties); } - /* before scene copy */ - BKE_sound_create_scene(sce_copy); + BKE_sound_reset_scene_runtime(sce_copy); /* grease pencil */ sce_copy->gpd = NULL; @@ -779,7 +778,7 @@ void BKE_scene_init(Scene *sce) srv = sce->r.views.last; BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix)); - BKE_sound_create_scene(sce); + BKE_sound_reset_scene_runtime(sce); /* color management */ colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER); @@ -1507,6 +1506,30 @@ static void prepare_mesh_for_viewport_render(Main *bmain, const ViewLayer *view_ } } +static void scene_update_sound(Depsgraph *depsgraph, Main *bmain) +{ + Scene *scene = DEG_get_evaluated_scene(depsgraph); + const int recalc = scene->id.recalc; + BKE_sound_ensure_scene(scene); + if (recalc & ID_RECALC_AUDIO_SEEK) { + BKE_sound_seek_scene(bmain, scene); + } + if (recalc & ID_RECALC_AUDIO_FPS) { + BKE_sound_update_fps(scene); + } + if (recalc & ID_RECALC_AUDIO_VOLUME) { + BKE_sound_set_scene_volume(scene, scene->audio.volume); + } + if (recalc & ID_RECALC_AUDIO_MUTE) { + const bool is_mute = (scene->audio.flag & AUDIO_MUTE); + BKE_sound_mute_scene(scene, is_mute); + } + if (recalc & ID_RECALC_AUDIO_LISTENER) { + BKE_sound_update_scene_listener(scene); + } + BKE_sound_update_scene(bmain, scene); +} + /* TODO(sergey): This actually should become view_layer_graph or so. * Same applies to update_for_newframe. * @@ -1542,10 +1565,9 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on * by depgraph or manual, no layer check here, gets correct flushed. */ DEG_evaluate_on_refresh(depsgraph); - /* Update sound system animation (TODO, move to depsgraph). */ - BKE_sound_update_scene(bmain, scene); - - /* Notify python about depsgraph update */ + /* Update sound system. */ + scene_update_sound(depsgraph, bmain); + /* Notify python about depsgraph update. */ if (run_callbacks) { BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_DEPSGRAPH_UPDATE_POST); } @@ -1590,8 +1612,8 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain) * by depgraph or manual, no layer check here, gets correct flushed. */ DEG_evaluate_on_framechange(bmain, depsgraph, ctime); - /* Update sound system animation (TODO, move to depsgraph). */ - BKE_sound_update_scene(bmain, scene); + /* Update sound system animation. */ + scene_update_sound(depsgraph, bmain); /* Notify editors and python about recalc. */ BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_FRAME_CHANGE_POST); /* Inform editors about possible changes. */ @@ -2420,3 +2442,31 @@ void BKE_scene_cursor_from_mat4(View3DCursor *cursor, const float mat[4][4], boo } /** \} */ + +/* Dependency graph evaluation. */ + +void BKE_scene_eval_sequencer_sequences(Depsgraph *depsgraph, Scene *scene) +{ + DEG_debug_print_eval(depsgraph, __func__, scene->id.name, scene); + if (scene->ed == NULL) { + return; + } + 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) { + BKE_sound_set_scene_sound_volume( + seq->scene_sound, seq->volume, (seq->flag & SEQ_AUDIO_VOLUME_ANIMATED) != 0); + BKE_sound_set_scene_sound_pitch( + seq->scene_sound, seq->pitch, (seq->flag & SEQ_AUDIO_PITCH_ANIMATED) != 0); + BKE_sound_set_scene_sound_pan( + seq->scene_sound, seq->pan, (seq->flag & SEQ_AUDIO_PAN_ANIMATED) != 0); + } + } + SEQ_END; + BKE_sequencer_update_muting(scene->ed); + BKE_sequencer_update_sound_bounds_all(scene); +} |