aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-11-24 01:39:34 -0800
committerChris Robinson <[email protected]>2009-11-24 01:39:34 -0800
commit35a9ccb41ff4291c7703c17538a6d6900d2968bf (patch)
treea96f310e1686c893adf6aab1710186222e573098
parentc7c2f9385f7bfde9962eb7743770679cca07181e (diff)
Revert "Base air absorption on the distance attenuation"
This reverts commit c7c2f9385f7bfde9962eb7743770679cca07181e. Fundamentally wrong. The -6dB rolloff is every doubling of the distance, and the (scaled) -0.05dB rolloff is supposed to be every additional unit.
-rw-r--r--Alc/ALu.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 16ad0d5a..c2ff4d57 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -628,20 +628,20 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource,
}
// Distance-based air absorption
- if(ALSource->AirAbsorptionFactor > 0.0f)
+ if(ALSource->AirAbsorptionFactor > 0.0f && ALSource->DistanceModel != AL_NONE)
{
- ALfloat amount = AIRABSORBGAINDBHF * ALSource->AirAbsorptionFactor *
- MetersPerUnit;
+ ALfloat dist = Distance-MinDist;
ALfloat absorb;
- // Convert a -6dB rolloff into a -0.05dB rolloff
- absorb = pow(10.0f, log10(flAttenuation) * amount / -6.0f);
- if(absorb < 1.0f)
- {
- DryGainHF *= absorb;
- for(i = 0;i < MAX_SENDS;i++)
- WetGainHF[i] *= absorb;
- }
+ 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);
+ DryGainHF *= absorb;
+ for(i = 0;i < MAX_SENDS;i++)
+ WetGainHF[i] *= absorb;
}
//3. Apply directional soundcones