Fast square root function?
I heard the standard sqrt function from math.h demands a lot of resources. So I ask does anyone know a faster square root function? Currently, I am using a FastSqrt function from the source sdk which is used to calculate the distance from player origin to enemy origin.
Code:
static inline float FastSqrt(float x)
{
__m128 root = _mm_sqrt_ss(_mm_load_ss(&x));
return *(reinterpret_cast<float *>(&root));
}
Yes, I'm shit at maths and sorry for copy pasting.