From 1694e5bd12d021169cf6cf541c5a5d0c652c8989 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 8 Dec 2009 10:12:18 -0800 Subject: [PATCH] Store the original pre-clamped distance instead of re-computing it --- Alc/ALu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 728de0c..8874ccc 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -408,7 +408,7 @@ ALvoid aluInitPanning(ALCcontext *Context) static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource, ALboolean isMono) { - ALfloat InnerAngle,OuterAngle,Angle,Distance,DryMix; + ALfloat InnerAngle,OuterAngle,Angle,Distance,DryMix,OrigDist; ALfloat Direction[3],Position[3],SourceToListener[3]; ALfloat Velocity[3],ListenerVel[3]; ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff,OuterGainHF; @@ -584,6 +584,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource, //2. Calculate distance attenuation Distance = aluSqrt(aluDotproduct(Position, Position)); + OrigDist = Distance; flAttenuation = 1.0f; for(i = 0;i < NumSends;i++) @@ -808,9 +809,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource, ALSource->Params.Pitch = ALSource->flPitch; // Use energy-preserving panning algorithm for multi-speaker playback - length = aluSqrt(Position[0]*Position[0] + Position[1]*Position[1] + - Position[2]*Position[2]); - length = __max(length, MinDist); + length = __max(OrigDist, MinDist); if(length > 0.0f) { ALfloat invlen = 1.0f/length;