summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDan Bechard <[email protected]>2021-03-23 03:32:25 -0700
committerGitHub <[email protected]>2021-03-23 11:32:25 +0100
commit5325d8d2bab019dece92115939932ce4440cdf19 (patch)
tree013bf633d99b0c6a3a0c6dcae968465da9f81e44
parent81738bfa98006714f8529362ffd658e4610f684a (diff)
downloadraylib-5325d8d2bab019dece92115939932ce4440cdf19.tar.gz
raylib-5325d8d2bab019dece92115939932ce4440cdf19.zip
Don't call sqrtf when axis already normalized (#1672)
-rw-r--r--src/raymath.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/raymath.h b/src/raymath.h
index b9ced952..7fc1df6c 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -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);