From c447eeb2c77d91d11750270aaed36a2354069095 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 16 May 2009 03:54:16 -0700 Subject: [PATCH] Use the source reference distance to specify full panning magnitude Sources that are closer than the specified reference distance will not pan to full magnitude, thus providing a smoother transition as it moves around near the listener --- Alc/ALu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 1d1878af..78c936cc 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -572,6 +572,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALfloat RoomRolloff[MAX_SENDS]; ALfloat DryGainHF = 1.0f; ALfloat DirGain, AmbientGain; + ALfloat length; const ALfloat *SpeakerGain; ALint NumSends; ALint pos, s, i; @@ -855,7 +856,16 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, DryMix *= ListenerGain; // Use energy-preserving panning algorithm for multi-speaker playback - aluNormalize(Position); + length = aluSqrt(Position[0]*Position[0] + Position[1]*Position[1] + + Position[2]*Position[2]); + length = __max(length, MinDist); + if(length > 0.0f) + { + ALfloat invlen = 1.0f/length; + Position[0] *= invlen; + Position[1] *= invlen; + Position[2] *= invlen; + } pos = aluCart2LUTpos(-Position[2], Position[0]); SpeakerGain = &ALContext->PanningLUT[OUTPUTCHANNELS * pos]; -- 2.11.4.GIT