diff options
| author | Rico P <[email protected]> | 2023-03-22 11:01:05 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-22 11:01:05 +0100 |
| commit | 8b8eddc8e29ddfb679100c5acc290c065e177d42 (patch) | |
| tree | ea4c24c402523f2a511fb91ada051e6c49b9a080 /src/raymath.h | |
| parent | e55bdd5d8af913016b74776d0878b30eb830f138 (diff) | |
| download | raylib-8b8eddc8e29ddfb679100c5acc290c065e177d42.tar.gz raylib-8b8eddc8e29ddfb679100c5acc290c065e177d42.zip | |
slightly optimize Vector3Normalize (#2982)
Diffstat (limited to 'src/raymath.h')
| -rw-r--r-- | src/raymath.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/raymath.h b/src/raymath.h index 422a42ee..54eaa815 100644 --- a/src/raymath.h +++ b/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; } |
