Fix T75686: Animating scene audio volume doesn't work
Scene audio volume changes require the scene to be tagged with `ID_RECALC_AUDIO_VOLUME` (see `BKE_scene_update_sound()`). Tagging happens in the RNA update function `rna_Scene_volume_update()`, but that function is not called by the animation system. As a result, animated volume changes are not sent to the audio system. This commit adds a new depsgraph operation node that sets this tag when necessary, so that the animated values are used in the rest of the depsgraph evaluation. Reviewed By: sergey Differential Revision: https://developer.blender.org/D7429
This commit is contained in:
@@ -141,6 +141,7 @@ int BKE_scene_orientation_slot_get_index(const struct TransformOrientationSlot *
|
|||||||
/* ** Scene evaluation ** */
|
/* ** Scene evaluation ** */
|
||||||
|
|
||||||
void BKE_scene_update_sound(struct Depsgraph *depsgraph, struct Main *bmain);
|
void BKE_scene_update_sound(struct Depsgraph *depsgraph, struct Main *bmain);
|
||||||
|
void BKE_scene_update_tag_audio_volume(struct Depsgraph *, struct Scene *scene);
|
||||||
|
|
||||||
void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bmain);
|
void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bmain);
|
||||||
void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain);
|
void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain);
|
||||||
|
@@ -1278,6 +1278,14 @@ void BKE_scene_update_sound(Depsgraph *depsgraph, Main *bmain)
|
|||||||
BKE_sound_update_scene(depsgraph, scene);
|
BKE_sound_update_scene(depsgraph, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BKE_scene_update_tag_audio_volume(Depsgraph *UNUSED(depsgraph), Scene *scene)
|
||||||
|
{
|
||||||
|
BLI_assert(DEG_is_evaluated_id(&scene->id));
|
||||||
|
/* The volume is actually updated in BKE_scene_update_sound(), from either
|
||||||
|
* scene_graph_update_tagged() or from BKE_scene_graph_update_for_newframe(). */
|
||||||
|
scene->id.recalc |= ID_RECALC_AUDIO_VOLUME;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO(sergey): This actually should become view_layer_graph or so.
|
/* TODO(sergey): This actually should become view_layer_graph or so.
|
||||||
* Same applies to update_for_newframe.
|
* Same applies to update_for_newframe.
|
||||||
*
|
*
|
||||||
|
@@ -1736,7 +1736,14 @@ void DepsgraphNodeBuilder::build_scene_audio(Scene *scene)
|
|||||||
if (built_map_.checkIsBuiltAndTag(scene, BuilderMap::TAG_SCENE_AUDIO)) {
|
if (built_map_.checkIsBuiltAndTag(scene, BuilderMap::TAG_SCENE_AUDIO)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_operation_node(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
|
add_operation_node(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
|
||||||
|
|
||||||
|
Scene *scene_cow = get_cow_datablock(scene);
|
||||||
|
add_operation_node(&scene->id,
|
||||||
|
NodeType::AUDIO,
|
||||||
|
OperationCode::AUDIO_VOLUME,
|
||||||
|
function_bind(BKE_scene_update_tag_audio_volume, _1, scene_cow));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphNodeBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer)
|
void DepsgraphNodeBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer)
|
||||||
|
@@ -2544,8 +2544,16 @@ void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_scene_audio(Scene * /*scene*/)
|
void DepsgraphRelationBuilder::build_scene_audio(Scene *scene)
|
||||||
{
|
{
|
||||||
|
OperationKey scene_audio_volume_key(&scene->id, NodeType::AUDIO, OperationCode::AUDIO_VOLUME);
|
||||||
|
OperationKey scene_sound_eval_key(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
|
||||||
|
add_relation(scene_audio_volume_key, scene_sound_eval_key, "Audio Volume -> Sound");
|
||||||
|
|
||||||
|
if (scene->audio.flag & AUDIO_VOLUME_ANIMATED) {
|
||||||
|
ComponentKey scene_anim_key(&scene->id, NodeType::ANIMATION);
|
||||||
|
add_relation(scene_anim_key, scene_audio_volume_key, "Animation -> Audio Volume");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer)
|
void DepsgraphRelationBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer)
|
||||||
|
@@ -61,6 +61,8 @@ const char *operationCodeAsString(OperationCode opcode)
|
|||||||
/* Scene related. */
|
/* Scene related. */
|
||||||
case OperationCode::SCENE_EVAL:
|
case OperationCode::SCENE_EVAL:
|
||||||
return "SCENE_EVAL";
|
return "SCENE_EVAL";
|
||||||
|
case OperationCode::AUDIO_VOLUME:
|
||||||
|
return "AUDIO_VOLUME";
|
||||||
/* Object related. */
|
/* Object related. */
|
||||||
case OperationCode::OBJECT_BASE_FLAGS:
|
case OperationCode::OBJECT_BASE_FLAGS:
|
||||||
return "OBJECT_BASE_FLAGS";
|
return "OBJECT_BASE_FLAGS";
|
||||||
|
@@ -60,6 +60,7 @@ enum class OperationCode {
|
|||||||
|
|
||||||
/* Scene related. ------------------------------------------------------- */
|
/* Scene related. ------------------------------------------------------- */
|
||||||
SCENE_EVAL,
|
SCENE_EVAL,
|
||||||
|
AUDIO_VOLUME,
|
||||||
|
|
||||||
/* Object related. ------------------------------------------------------ */
|
/* Object related. ------------------------------------------------------ */
|
||||||
OBJECT_BASE_FLAGS,
|
OBJECT_BASE_FLAGS,
|
||||||
|
Reference in New Issue
Block a user