From 0ee2df3490ee94dd17c1becb4d8a8a07b63ec49e Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 28 Apr 2021 10:51:58 -0500 Subject: [PATCH] Sources can bypass global effects. --- src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bf0e589..d198bef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, } @@ -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;