瀏覽代碼
slightly optimize Vector3Normalize (#2982)
pull/2986/head
Rico P
2 年之前
committed by
GitHub
沒有發現已知的金鑰在資料庫的簽署中
GPG Key ID: 4AEE18F83AFDEB23
共有
1 個文件被更改,包括
7 次插入 和
5 次删除
-
src/raymath.h
|
|
@ -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; |
|
|
|
} |
|
|
|