diff --git a/src/engine/include/models/math/matrix.hpp b/src/engine/include/models/math/matrix.hpp index b30f6d1..d14855b 100644 --- a/src/engine/include/models/math/matrix.hpp +++ b/src/engine/include/models/math/matrix.hpp @@ -52,13 +52,6 @@ public: // Operators // ---- - Matrix operator*(const Matrix &v) const - { - Matrix result; - cross(result.data, this->data, v.data); - return result; - } - Vector3 operator*(const Vector3 &v) const; Matrix operator*(const Matrix &v) const @@ -99,6 +92,25 @@ public: translate(t_val); } + /** Create rotation matrix. */ + inline void rotation(const Vector3 &t_val) + { + identity(); + Matrix temp = Matrix(); + + temp.identity(); + temp.rotateX(t_val.x); + operator*=(temp); + + temp.identity(); + temp.rotateY(t_val.y); + operator*=(temp); + + temp.identity(); + temp.rotateZ(t_val.z); + operator*=(temp); + } + /** Create X rotation matrix. */ inline void rotationX(const float &t_radians) { diff --git a/src/engine/models/math/matrix.cpp b/src/engine/models/math/matrix.cpp index 1f4ff64..805c433 100644 --- a/src/engine/models/math/matrix.cpp +++ b/src/engine/models/math/matrix.cpp @@ -55,7 +55,8 @@ Matrix::Matrix(const float &m11, const float &m12, const float &m13, const float Vector3 Matrix::operator*(const Vector3 &v) const { - Vector3 result; + float a[4] = {v.x, v.y, v.z, 1.0F}; + float res[4]; asm volatile( "lqc2 vf4, 0x00(%1) \n\t" "lqc2 vf5, 0x10(%1) \n\t" @@ -68,7 +69,8 @@ Vector3 Matrix::operator*(const Vector3 &v) const "vmaddw.xyzw vf9, vf7, vf8 \n\t" "sqc2 vf9, 0x00(%0) \n\t" : - : "r"(result.xyz), "r"(this->data), "r"(v.xyz)); + : "r"(res), "r"(this->data), "r"(a)); + return Vector3(res[0], res[1], res[2]); } // ----