mirror of
https://github.com/lightsoutgames/bevy_openal.git
synced 2024-12-21 12:46:01 +00:00
The listener should query the global transform first.
This commit is contained in:
parent
c33a28efce
commit
2ca07730ab
|
@ -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<Transform> = 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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user