浏览代码

Reviewed some functions to avoid calling other functions

pull/1923/head
raysan5 3 年前
父节点
当前提交
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: * CONFIGURATION:
* *
@ -488,14 +488,14 @@ RMDEF Vector3 Vector3Normalize(Vector3 v)
{ {
Vector3 result = v; Vector3 result = v;
float length, ilength; float length, inverseLength;
length = Vector3Length(v); length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
if (length == 0.0f) length = 1.0f; if (length == 0.0f) length = 1.0f;
ilength = 1.0f/length; inverseLength = 1.0f/length;
result.x *= ilength; result.x *= inverseLength;
result.y *= ilength; result.y *= inverseLength;
result.z *= ilength; result.z *= inverseLength;
return result; return result;
} }
@ -1429,8 +1429,9 @@ RMDEF Matrix QuaternionToMatrix(Quaternion q)
RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle) RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
{ {
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
float axisLength = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);
if (Vector3Length(axis) != 0.0f) if (axisLength != 0.0f)
{ {
angle *= 0.5f; angle *= 0.5f;

||||||
x
 
000:0
正在加载...
取消
保存