From 3a09e446b3b298c0da638f46a7b72ad246044a18 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 3 Jul 2008 03:13:43 -0700 Subject: [PATCH] Leave SourceToListener untransformed for use with untransformed velocities Distance is also left untransformed so cone calculations with SoundToListener are correct --- Alc/ALu.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 7b9363c3..8ef39cfa 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -273,6 +273,10 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, if(isMono != AL_FALSE) { //1. Translate Listener to origin (convert to head relative) + // Note that Direction and SourceToListener are *not* transformed. + // SourceToListener is used with the source and listener velocities, + // which are untransformed, and Direction is used with SourceToListener + // for the sound cone if(ALSource->bHeadRelative==AL_FALSE) { // Build transform matrix @@ -290,10 +294,21 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, Position[0] -= ALContext->Listener.Position[0]; Position[1] -= ALContext->Listener.Position[1]; Position[2] -= ALContext->Listener.Position[2]; + + SourceToListener[0] = -Position[0]; + SourceToListener[1] = -Position[1]; + SourceToListener[2] = -Position[2]; + // Transform source position and direction into listener space aluMatrixVector(Position, Matrix); - aluMatrixVector(Direction, Matrix); } + else + { + SourceToListener[0] = -Position[0]; + SourceToListener[1] = -Position[1]; + SourceToListener[2] = -Position[2]; + } + aluNormalize(SourceToListener); aluNormalize(Direction); //2. Calculate distance attenuation @@ -372,11 +387,6 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, WetMix = __max(WetMix,MinVolume); //3. Apply directional soundcones - SourceToListener[0] = -Position[0]; - SourceToListener[1] = -Position[1]; - SourceToListener[2] = -Position[2]; - aluNormalize(SourceToListener); - Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * 180.0f / 3.141592654f; if(Angle >= InnerAngle && Angle <= OuterAngle) -- 2.11.4.GIT