2
0
Эх сурвалжийг харах

Reviewed some functions to avoid calling other functions

raysan5 4 жил өмнө
parent
commit
58e9a0894f
1 өөрчлөгдсөн 10 нэмэгдсэн , 9 устгасан
  1. 10 9
      src/raymath.h

+ 10 - 9
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;