slightly optimize Vector3Normalize
This commit is contained in:
parent
d61303b1b0
commit
5a71974538
|
|
@ -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;
|
||||
float ilength = 1.0f/length;
|
||||
if (length != 0.0f)
|
||||
{
|
||||
float ilength = 1.0f/length;
|
||||
|
||||
result.x *= ilength;
|
||||
result.y *= ilength;
|
||||
result.z *= ilength;
|
||||
result.x *= ilength;
|
||||
result.y *= ilength;
|
||||
result.z *= ilength;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user