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