More robust approximation of distance attenuation at extreme settings.

Fixes artifacts that occur when attenuation zone coef = 1.0 and distance > 32m.
This commit is contained in:
Ken Cooke 2019-01-16 11:10:38 -08:00
parent 4c502cdbc9
commit 328809f008

View file

@ -43,8 +43,9 @@ static inline float fastLog2f(float x) {
} }
// //
// for -127 <= x < 128, returns exp2(x) // for -126 <= x < 128, returns exp2(x)
// otherwise, returns undefined // for x < -126, returns 0
// for x >= 128, returns undefined
// //
// rel |error| < 9e-6, smooth (exact for x=N) // rel |error| < 9e-6, smooth (exact for x=N)
// //
@ -60,6 +61,7 @@ static inline float fastExp2f(float x) {
x -= xi.i; x -= xi.i;
// construct exp2(xi) as a float // construct exp2(xi) as a float
xi.i &= ~(xi.i >> 31); // MAX(xi.i, 0)
xi.i <<= IEEE754_MANT_BITS; xi.i <<= IEEE754_MANT_BITS;
// polynomial for exp2(x) over x=[0,1] // polynomial for exp2(x) over x=[0,1]