aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-11-24 21:19:11 -0800
committerChris Robinson <[email protected]>2009-11-24 21:19:11 -0800
commit877f4340ba509ed9b31b2de4bcbb11c1befaf3ed (patch)
tree77306b1faeee5672ff0dc78b97f21a2478878d8d /Alc
parent35a9ccb41ff4291c7703c17538a6d6900d2968bf (diff)
Base air absorption on distance attenuation, try 2
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index c2ff4d57..01621f6f 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -628,17 +628,18 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource,
}
// Distance-based air absorption
- if(ALSource->AirAbsorptionFactor > 0.0f && ALSource->DistanceModel != AL_NONE)
+ if(ALSource->AirAbsorptionFactor > 0.0f && flAttenuation < 1.0f)
{
- ALfloat dist = Distance-MinDist;
- ALfloat absorb;
+ ALfloat absorb = 0.0f;
- if(dist < 0.0f) dist = 0.0f;
// Absorption calculation is done in dB
- absorb = (ALSource->AirAbsorptionFactor*AIRABSORBGAINDBHF) *
- (dist*MetersPerUnit);
- // Convert dB to linear gain before applying
- absorb = pow(10.0, absorb/20.0);
+ if(flAttenuation > 0.0f)
+ {
+ absorb = (MinDist/flAttenuation - MinDist)*MetersPerUnit *
+ (ALSource->AirAbsorptionFactor*AIRABSORBGAINDBHF);
+ // Convert dB to linear gain before applying
+ absorb = pow(10.0, absorb/20.0);
+ }
DryGainHF *= absorb;
for(i = 0;i < MAX_SENDS;i++)
WetGainHF[i] *= absorb;