From 3c442d17dcc0d81a17a5ee8e25a5adc6f0b3d1bd Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 3 May 2013 21:12:39 +0200 Subject: Fix for issue #202 with 3D sound disabled --- src/sound/oalsound/alsound.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index ef8ff8d..dc2b64d 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -662,8 +662,12 @@ void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) } mChannels[channel]->SetVolumeAtrib(1.0f - ((dist - 10.0f) / 100.0f)); - a = fmodf(Angle(mLookat, mEye), Math::PI * 2.0f); - g = fmodf(Angle(pos, mEye), Math::PI * 2.0f); + Math::Vector one = Math::Vector(1.0f, 0.0f, 0.0f); + float angle_a = Angle(Math::Vector(mLookat.x - mEye.x, mLookat.z - mEye.z, 0.0f), one); + float angle_g = Angle(Math::Vector(pos.x - mEye.x, pos.z - mEye.z, 0.0f), one); + + a = fmodf(angle_a, Math::PI * 2.0f); + g = fmodf(angle_g, Math::PI * 2.0f); if ( a < 0.0f ) { a += Math::PI * 2.0f; @@ -682,5 +686,5 @@ void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) } } - mChannels[channel]->SetPan( Math::Vector(sinf(g - a), 0.0f, 0.0f) ); + mChannels[channel]->SetPan( Math::Vector(0.0f, 0.0f, sinf(g - a)) ); } -- cgit v1.2.3-1-g7c22