slightly optimize Vector3Normalize (#2982)

This commit is contained in:
Rico P 2023-03-22 11:01:05 +01:00 committed by GitHub
parent e55bdd5d8a
commit 8b8eddc8e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -703,12 +703,14 @@ RMAPI Vector3 Vector3Normalize(Vector3 v)
Vector3 result = v;
float length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
if (length == 0.0f) length = 1.0f;
if (length != 0.0f)
{
float ilength = 1.0f/length;
result.x *= ilength;
result.y *= ilength;
result.z *= ilength;
}
return result;
}