diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-01-19 16:09:06 +0100 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-01-19 17:38:10 +0100 |
commit | e6ef1644418401e5ace5a12537d6bd500db7f0e2 (patch) | |
tree | de1de5510b1ddcffc3af0b374440fb9cc5cb2c9a /src/math/Matrix.h | |
parent | Get rid of RwMatrix in CMatrix (diff) | |
download | re3-e6ef1644418401e5ace5a12537d6bd500db7f0e2.tar re3-e6ef1644418401e5ace5a12537d6bd500db7f0e2.tar.gz re3-e6ef1644418401e5ace5a12537d6bd500db7f0e2.tar.bz2 re3-e6ef1644418401e5ace5a12537d6bd500db7f0e2.tar.lz re3-e6ef1644418401e5ace5a12537d6bd500db7f0e2.tar.xz re3-e6ef1644418401e5ace5a12537d6bd500db7f0e2.tar.zst re3-e6ef1644418401e5ace5a12537d6bd500db7f0e2.zip |
Diffstat (limited to 'src/math/Matrix.h')
-rw-r--r-- | src/math/Matrix.h | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/src/math/Matrix.h b/src/math/Matrix.h index fdbd0b60..9d50a4f6 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -1,7 +1,5 @@ #pragma once -#include "VuVector.h" - class CMatrix { public: @@ -10,10 +8,10 @@ public: float f[4][4]; struct { - CVuVector right; - CVuVector forward; - CVuVector up; - CVuVector pos; + float rx, ry, rz, rw; + float fx, fy, fz, fw; + float ux, uy, uz, uw; + float px, py, pz, pw; }; }; @@ -38,17 +36,23 @@ public: CMatrix &operator+=(CMatrix const &rhs); CMatrix &operator*=(CMatrix const &rhs); - CVector &GetPosition(void){ return pos; } - CVector &GetRight(void) { return right; } - CVector &GetForward(void) { return forward; } - CVector &GetUp(void) { return up; } + CVector &GetPosition(void) { return *(CVector*)&px; } + CVector &GetRight(void) { return *(CVector*)℞ } + CVector &GetForward(void) { return *(CVector*)&fx; } + CVector &GetUp(void) { return *(CVector*)&ux; } + + const CVector &GetPosition(void) const { return *(CVector*)&px; } + const CVector &GetRight(void) const { return *(CVector*)℞ } + const CVector &GetForward(void) const { return *(CVector*)&fx; } + const CVector &GetUp(void) const { return *(CVector*)&ux; } + void SetTranslate(float x, float y, float z); void SetTranslate(const CVector &trans){ SetTranslate(trans.x, trans.y, trans.z); } void Translate(float x, float y, float z){ - pos.x += x; - pos.y += y; - pos.z += z; + px += x; + py += y; + pz += z; } void Translate(const CVector &trans){ Translate(trans.x, trans.y, trans.z); } @@ -72,17 +76,17 @@ public: float c = Cos(angle); float s = Sin(angle); - right.x = c * scale; - right.y = s * scale; - right.z = 0.0f; + rx = c * scale; + ry = s * scale; + rz = 0.0f; - forward.x = -s * scale; - forward.y = c * scale; - forward.z = 0.0f; + fx = -s * scale; + fy = c * scale; + fz = 0.0f; - up.x = 0.0f; - up.y = 0.0f; - up.z = scale; + ux = 0.0f; + uy = 0.0f; + uz = scale; } void SetRotateX(float angle); void SetRotateY(float angle); @@ -98,9 +102,9 @@ public: void SetUnity(void); void ResetOrientation(void); void SetTranslateOnly(float x, float y, float z) { - pos.x = x; - pos.y = y; - pos.z = z; + px = x; + py = y; + pz = z; } void SetTranslateOnly(const CVector& pos) { SetTranslateOnly(pos.x, pos.y, pos.z); @@ -114,11 +118,11 @@ CMatrix Invert(const CMatrix &matrix); CMatrix operator*(const CMatrix &m1, const CMatrix &m2); inline CVector MultiplyInverse(const CMatrix &mat, const CVector &vec) { - CVector v(vec.x - mat.pos.x, vec.y - mat.pos.y, vec.z - mat.pos.z); + CVector v(vec.x - mat.px, vec.y - mat.py, vec.z - mat.pz); return CVector( - mat.right.x * v.x + mat.right.y * v.y + mat.right.z * v.z, - mat.forward.x * v.x + mat.forward.y * v.y + mat.forward.z * v.z, - mat.up.x * v.x + mat.up.y * v.y + mat.up.z * v.z); + mat.rx * v.x + mat.ry * v.y + mat.rz * v.z, + mat.fx * v.x + mat.fy * v.y + mat.fz * v.z, + mat.ux * v.x + mat.uy * v.y + mat.uz * v.z); } |