mirror of
https://github.com/lightsoutgames/bevy_openal.git
synced 2024-11-21 17:05:55 +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_gain(gain).unwrap();
|
||||||
source.set_looping(looping);
|
source.set_looping(looping);
|
||||||
source.set_pitch(pitch).unwrap();
|
source.set_pitch(pitch).unwrap();
|
||||||
|
//println!("Global: {:?}, transform: {:?}", global_transform, transform);
|
||||||
let translation = global_transform
|
let translation = global_transform
|
||||||
.map(|v| v.translation)
|
.map(|v| v.translation)
|
||||||
.or_else(|| transform.map(|v| v.translation));
|
.or_else(|| transform.map(|v| v.translation));
|
||||||
if let Some(translation) = translation {
|
if let Some(translation) = translation {
|
||||||
|
//println!("Translation: {:?}", translation);
|
||||||
source.set_relative(false);
|
source.set_relative(false);
|
||||||
source
|
source
|
||||||
.set_position([translation.x, translation.y, translation.z])
|
.set_position([translation.x, translation.y, translation.z])
|
||||||
|
@ -291,12 +293,12 @@ fn listener_update(
|
||||||
query: Query<(&Listener, Option<&Transform>, Option<&GlobalTransform>)>,
|
query: Query<(&Listener, Option<&Transform>, Option<&GlobalTransform>)>,
|
||||||
) {
|
) {
|
||||||
for (_, transform, global_transform) in query.iter() {
|
for (_, transform, global_transform) in query.iter() {
|
||||||
let transform = transform.cloned().or_else(|| {
|
let transform: Option<Transform> = global_transform
|
||||||
global_transform.map(|v| {
|
.map(|v| {
|
||||||
let matrix = v.compute_matrix();
|
let matrix = v.compute_matrix();
|
||||||
Transform::from_matrix(matrix)
|
Transform::from_matrix(matrix)
|
||||||
})
|
})
|
||||||
});
|
.or_else(|| transform.cloned());
|
||||||
if let Some(transform) = transform {
|
if let Some(transform) = transform {
|
||||||
let matrix = transform.compute_matrix().inverse();
|
let matrix = transform.compute_matrix().inverse();
|
||||||
let look = matrix.x_axis;
|
let look = matrix.x_axis;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user