Added HMM_FastInverseSquareRoot function

With it's original comments. :)

I won't mess too much with the coding style,
because I don't fully understand it.

It works, though.
This commit is contained in:
Kyle De'Vir
2016-05-29 03:55:47 +10:00
parent 9b2c7bf301
commit 004b65f6e3

View File

@@ -343,6 +343,24 @@ HMM_SquareRoot(float Float)
return(Result);
}
HINLINE float
HMM_FastInverseSquareRoot(float Number)
{
long i;
float x2, y;
const float threehalfs = 1.5f;
x2 = Number * 0.5f;
y = Number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) );
return ( y );
}
HINLINE float
HMM_LengthSquareRoot(hmm_vec3 A)
{