Fix AudioListener2D ignoring rotation
This commit is contained in:
parent
1285e0e21c
commit
20ceba9e82
1 changed files with 5 additions and 4 deletions
|
@ -174,13 +174,14 @@ void AudioStreamPlayer2D::_update_panning() {
|
||||||
|
|
||||||
//screen in global is used for attenuation
|
//screen in global is used for attenuation
|
||||||
AudioListener2D *listener = vp->get_audio_listener_2d();
|
AudioListener2D *listener = vp->get_audio_listener_2d();
|
||||||
|
Transform2D full_canvas_transform = vp->get_global_canvas_transform() * vp->get_canvas_transform();
|
||||||
if (listener) {
|
if (listener) {
|
||||||
listener_in_global = listener->get_global_position();
|
listener_in_global = listener->get_global_position();
|
||||||
relative_to_listener = global_pos - listener_in_global;
|
relative_to_listener = (global_pos - listener_in_global).rotated(-listener->get_global_rotation());
|
||||||
|
relative_to_listener *= full_canvas_transform.get_scale(); // Default listener scales with canvas size, do the same here.
|
||||||
} else {
|
} else {
|
||||||
Transform2D to_listener = vp->get_global_canvas_transform() * vp->get_canvas_transform();
|
listener_in_global = full_canvas_transform.affine_inverse().xform(screen_size * 0.5);
|
||||||
listener_in_global = to_listener.affine_inverse().xform(screen_size * 0.5);
|
relative_to_listener = full_canvas_transform.xform(global_pos) - screen_size * 0.5;
|
||||||
relative_to_listener = to_listener.xform(global_pos) - screen_size * 0.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float dist = global_pos.distance_to(listener_in_global); // Distance to listener, or screen if none.
|
float dist = global_pos.distance_to(listener_in_global); // Distance to listener, or screen if none.
|
||||||
|
|
Loading…
Reference in a new issue