Don't call sqrtf when axis already normalized (#1672)

This commit is contained in:
Dan Bechard 2021-03-23 03:32:25 -07:00 committed by GitHub
parent 81738bfa98
commit 5325d8d2ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -856,14 +856,14 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
float x = axis.x, y = axis.y, z = axis.z;
float length = sqrtf(x*x + y*y + z*z);
float lengthSquared = x*x + y*y + z*z;
if ((length != 1.0f) && (length != 0.0f))
if ((lengthSquared != 1.0f) && (lengthSquared != 0.0f))
{
length = 1.0f/length;
x *= length;
y *= length;
z *= length;
float inverseLength = 1.0f/sqrtf(lengthSquared);
x *= inverseLength;
y *= inverseLength;
z *= inverseLength;
}
float sinres = sinf(angle);