summaryrefslogtreecommitdiffstats
path: root/src/sound
diff options
context:
space:
mode:
authorerihel <erihel@gmail.com>2013-05-03 21:12:39 +0200
committererihel <erihel@gmail.com>2013-05-03 21:12:39 +0200
commit3c442d17dcc0d81a17a5ee8e25a5adc6f0b3d1bd (patch)
treeccc4865e772b5e63cc9842bfa8cebdb4537f46b9 /src/sound
parentf68581a3aef1aff0df0881248cf7440ede29a806 (diff)
downloadcolobot-3c442d17dcc0d81a17a5ee8e25a5adc6f0b3d1bd.tar.gz
colobot-3c442d17dcc0d81a17a5ee8e25a5adc6f0b3d1bd.tar.bz2
colobot-3c442d17dcc0d81a17a5ee8e25a5adc6f0b3d1bd.zip
Fix for issue #202 with 3D sound disabled
Diffstat (limited to 'src/sound')
-rw-r--r--src/sound/oalsound/alsound.cpp10
1 files 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)) );
}