From 2ca07730abc27b632c4944a5764f22f834608575 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Fri, 8 Jan 2021 14:06:13 -0600 Subject: [PATCH] The listener should query the global transform first. --- src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5b3a40a..0f2a06c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -236,10 +236,12 @@ fn source_update( source.set_gain(gain).unwrap(); source.set_looping(looping); source.set_pitch(pitch).unwrap(); + //println!("Global: {:?}, transform: {:?}", global_transform, transform); let translation = global_transform .map(|v| v.translation) .or_else(|| transform.map(|v| v.translation)); if let Some(translation) = translation { + //println!("Translation: {:?}", translation); source.set_relative(false); source .set_position([translation.x, translation.y, translation.z]) @@ -291,12 +293,12 @@ fn listener_update( query: Query<(&Listener, Option<&Transform>, Option<&GlobalTransform>)>, ) { for (_, transform, global_transform) in query.iter() { - let transform = transform.cloned().or_else(|| { - global_transform.map(|v| { + let transform: Option = global_transform + .map(|v| { let matrix = v.compute_matrix(); Transform::from_matrix(matrix) }) - }); + .or_else(|| transform.cloned()); if let Some(transform) = transform { let matrix = transform.compute_matrix().inverse(); let look = matrix.x_axis;