Sources can bypass global effects.

This commit is contained in:
Nolan Darilek 2021-04-28 10:51:58 -05:00
parent 8a07a26fb5
commit 0ee2df3490

View File

@ -160,6 +160,7 @@ pub struct Sound {
pub pitch: f32,
pub reference_distance: f32,
pub rolloff_factor: f32,
pub bypass_global_effects: bool,
#[reflect(ignore)]
pub source: Option<StaticSource>,
}
@ -174,6 +175,7 @@ impl Default for Sound {
pitch: 1.,
reference_distance: 1.,
rolloff_factor: 1.,
bypass_global_effects: false,
source: None,
}
}
@ -261,6 +263,7 @@ fn source_update(
let pitch = sound.pitch;
let reference_distance = sound.reference_distance;
let rolloff_factor = sound.rolloff_factor;
let bypass_global_effects = sound.bypass_global_effects;
let source_state = if let Some(source) = &sound.source {
Some(source.state())
} else {
@ -285,8 +288,10 @@ fn source_update(
source.set_reference_distance(reference_distance).unwrap();
source.set_rolloff_factor(rolloff_factor).unwrap();
update_source_position(source, transform, global_transform);
for (send, effect) in global_effects.iter_mut().enumerate() {
source.set_aux_send(send as i32, effect).unwrap();
if !bypass_global_effects {
for (send, effect) in global_effects.iter_mut().enumerate() {
source.set_aux_send(send as i32, effect).unwrap();
}
}
} else {
sound.source = None;