diff options
author | Chris Robinson <[email protected]> | 2009-05-16 03:54:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-05-16 03:54:16 -0700 |
commit | c447eeb2c77d91d11750270aaed36a2354069095 (patch) | |
tree | 1a3a7e4d5153ca8e73ac6daac6b25c87313b3b9b | |
parent | ad19cea6e014b7a3bee0b098d5e3e58def631a49 (diff) |
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
-rw-r--r-- | Alc/ALu.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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]; |