aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-03-09 23:53:45 -0800
committerChris Robinson <[email protected]>2012-03-09 23:53:45 -0800
commitf5f519aa800e8e342d5e139e95d33b4b3a6b5629 (patch)
treed28506f3bf4b136960014af295e6519886d3a169 /Alc
parent7db29a233249fd0c0ce37064c118072ca5b5a29e (diff)
Properly make the source velocity relative to the listener velocity
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 223928bb..5a53dbba 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -354,11 +354,12 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALboolean WetGainAuto;
ALboolean WetGainHFAuto;
enum Resampler Resampler;
+ ALfloat Matrix[4][4];
ALfloat Pitch;
ALuint Frequency;
ALint NumSends;
ALfloat cw;
- ALint i;
+ ALint i, j;
DryGainHF = 1.0f;
for(i = 0;i < MAX_SENDS;i++)
@@ -443,17 +444,15 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALSource->Params.Send[i].Slot = Slot;
}
+ for(i = 0;i < 4;i++)
+ {
+ for(j = 0;j < 4;j++)
+ Matrix[i][j] = ALContext->Listener.Matrix[i][j];
+ }
+
//1. Translate Listener to origin (convert to head relative)
if(ALSource->bHeadRelative == AL_FALSE)
{
- ALfloat Matrix[4][4];
- for(i = 0;i < 4;i++)
- {
- ALint i2;
- for(i2 = 0;i2 < 4;i2++)
- Matrix[i][i2] = ALContext->Listener.Matrix[i][i2];
- }
-
/* Translate position */
Position[0] -= ALContext->Listener.Position[0];
Position[1] -= ALContext->Listener.Position[1];
@@ -463,14 +462,17 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
aluMatrixVector(Position, 1.0f, Matrix);
aluMatrixVector(Direction, 0.0f, Matrix);
aluMatrixVector(Velocity, 0.0f, Matrix);
- /* Transform listener vectors into listener space */
+ /* Transform listener velocity into listener space */
aluMatrixVector(ListenerVel, 0.0f, Matrix);
}
else
{
- ListenerVel[0] = 0.0f;
- ListenerVel[1] = 0.0f;
- ListenerVel[2] = 0.0f;
+ /* Transform listener velocity into listener space */
+ aluMatrixVector(ListenerVel, 0.0f, Matrix);
+ /* Offset the source velocity to be relative of the listener velocity */
+ Velocity[0] += ListenerVel[0];
+ Velocity[1] += ListenerVel[1];
+ Velocity[2] += ListenerVel[2];
}
SourceToListener[0] = -Position[0];