summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2021-07-29 21:50:50 +0200
committerraysan5 <[email protected]>2021-07-29 21:50:50 +0200
commit58e9a0894f65a50004e637f7db72bd12da809cd9 (patch)
treea322c662e7d4d42b4d94d1163857af3b5c2dbdf5
parent6ef3ab3d3ac98f2e8a77b4bd065008d2ce9d7e8f (diff)
downloadraylib-58e9a0894f65a50004e637f7db72bd12da809cd9.tar.gz
raylib-58e9a0894f65a50004e637f7db72bd12da809cd9.zip
Reviewed some functions to avoid calling other functions
-rw-r--r--src/raymath.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/raymath.h b/src/raymath.h
index 3b65e382..ffdd2c27 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -1,6 +1,6 @@
/**********************************************************************************************
*
-* raymath v1.2 - Math functions to work with Vector3, Matrix and Quaternions
+* raymath v1.3 - Math functions to work with Vector3, Matrix and Quaternions
*
* CONFIGURATION:
*
@@ -488,14 +488,14 @@ RMDEF Vector3 Vector3Normalize(Vector3 v)
{
Vector3 result = v;
- float length, ilength;
- length = Vector3Length(v);
+ float length, inverseLength;
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
if (length == 0.0f) length = 1.0f;
- ilength = 1.0f/length;
+ inverseLength = 1.0f/length;
- result.x *= ilength;
- result.y *= ilength;
- result.z *= ilength;
+ result.x *= inverseLength;
+ result.y *= inverseLength;
+ result.z *= inverseLength;
return result;
}
@@ -1429,8 +1429,9 @@ RMDEF Matrix QuaternionToMatrix(Quaternion q)
RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
{
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
-
- if (Vector3Length(axis) != 0.0f)
+ float axisLength = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);
+
+ if (axisLength != 0.0f)
{
angle *= 0.5f;