diff options
author | Chris Robinson <[email protected]> | 2017-05-30 05:13:54 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-05-30 05:13:54 -0700 |
commit | e893211b659a5dbaf75aa437ab594aac87984b85 (patch) | |
tree | 6589dd8c1be14ed11d2319e4ed027fc54fdef49b | |
parent | 6d4adc6ad6f387dcde4e01099e33672c4a19fda6 (diff) |
Restrict ClampedDist to RefDistance for invalid distance attenuation
-rw-r--r-- | Alc/ALu.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1195,7 +1195,9 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop break; /*fall-through*/ case InverseDistance: - if(props->RefDistance > 0.0f) + if(!(props->RefDistance > 0.0f)) + ClampedDist = props->RefDistance; + else { ALfloat dist = lerp(props->RefDistance, ClampedDist, props->RolloffFactor); if(dist > 0.0f) DryGain *= props->RefDistance / dist; @@ -1213,10 +1215,12 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop break; /*fall-through*/ case LinearDistance: - if(props->MaxDistance != props->RefDistance) + if(!(props->MaxDistance != props->RefDistance)) + ClampedDist = props->RefDistance; + else { ALfloat attn = props->RolloffFactor * (ClampedDist-props->RefDistance) / - (props->MaxDistance-props->RefDistance); + (props->MaxDistance-props->RefDistance); DryGain *= maxf(1.0f - attn, 0.0f); for(i = 0;i < NumSends;i++) { @@ -1233,7 +1237,9 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop break; /*fall-through*/ case ExponentDistance: - if(ClampedDist > 0.0f && props->RefDistance > 0.0f) + if(!(ClampedDist > 0.0f && props->RefDistance > 0.0f)) + ClampedDist = props->RefDistance; + else { DryGain *= powf(ClampedDist/props->RefDistance, -props->RolloffFactor); for(i = 0;i < NumSends;i++) |