From 2bbe0fcd208ad2204c52b3343a466bcf9eee6fe7 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Fri, 4 Nov 2022 14:33:59 +0200 Subject: [PATCH] Change CQuaternion to use a CVector3f for the non-w coordinates Former-commit-id: c9e5e494e0b244c384bbb42b3c7d0c10923912df --- include/Kyoto/Math/CQuaternion.hpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/include/Kyoto/Math/CQuaternion.hpp b/include/Kyoto/Math/CQuaternion.hpp index d1cb695b..5737d658 100644 --- a/include/Kyoto/Math/CQuaternion.hpp +++ b/include/Kyoto/Math/CQuaternion.hpp @@ -12,7 +12,7 @@ class CNUQuaternion; class CQuaternion { public: - CQuaternion(float w, float x, float y, float z) : w(w), x(x), y(y), z(z) {} + CQuaternion(float w, float x, float y, float z) : w(w), imaginary(x, y, z) {} // __ct__11CQuaternionFfRC9CVector3f // CQuaternion(const CQuaternion& other) @@ -53,7 +53,7 @@ public: // double x = -this->x; // double y = -this->y; // double z = -this->z; - return CQuaternion(w, -x, -y, -z); + return CQuaternion(w, -imaginary.GetX(), -imaginary.GetY(), -imaginary.GetZ()); } static CQuaternion FromMatrixRows(const CVector3f&, const CVector3f&, const CVector3f&); @@ -68,19 +68,14 @@ public: } float GetW() const { return w; } - float GetX() const { return x; } - float GetY() const { return y; } - float GetZ() const { return z; } - const CVector3f& GetImaginary() const { - // TODO: hack! has a Vector3f field? - return *reinterpret_cast(&x); - } + float GetX() const { return imaginary.GetX(); } + float GetY() const { return imaginary.GetY(); } + float GetZ() const { return imaginary.GetZ(); } + const CVector3f& GetImaginary() const { return imaginary; } private: float w; - float x; - float y; - float z; + CVector3f imaginary; static const CQuaternion sNoRotation; };