summaryrefslogtreecommitdiffstats
path: root/src/math/Matrix.h
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-06-26 23:14:42 +0200
committerGitHub <noreply@github.com>2019-06-26 23:14:42 +0200
commit990d7f9d192dae891782b70b612b4889862545be (patch)
treecc4203c9266b450e393c179c8d528f71c5957f01 /src/math/Matrix.h
parentbla (diff)
parentfixed autobuild (diff)
downloadre3-990d7f9d192dae891782b70b612b4889862545be.tar
re3-990d7f9d192dae891782b70b612b4889862545be.tar.gz
re3-990d7f9d192dae891782b70b612b4889862545be.tar.bz2
re3-990d7f9d192dae891782b70b612b4889862545be.tar.lz
re3-990d7f9d192dae891782b70b612b4889862545be.tar.xz
re3-990d7f9d192dae891782b70b612b4889862545be.tar.zst
re3-990d7f9d192dae891782b70b612b4889862545be.zip
Diffstat (limited to 'src/math/Matrix.h')
-rw-r--r--src/math/Matrix.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/math/Matrix.h b/src/math/Matrix.h
index 74e3d70d..e2e5394e 100644
--- a/src/math/Matrix.h
+++ b/src/math/Matrix.h
@@ -270,3 +270,37 @@ Multiply3x3(const CMatrix &mat, const CVector &vec)
mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z,
mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z);
}
+
+class CCompressedMatrixNotAligned
+{
+ CVector m_vecPos;
+ int8 m_rightX;
+ int8 m_rightY;
+ int8 m_rightZ;
+ int8 m_upX;
+ int8 m_upY;
+ int8 m_upZ;
+public:
+ void CompressFromFullMatrix(CMatrix &other)
+ {
+ m_rightX = 127.0f * other.GetRight()->x;
+ m_rightY = 127.0f * other.GetRight()->y;
+ m_rightZ = 127.0f * other.GetRight()->z;
+ m_upX = 127.0f * other.GetForward()->x;
+ m_upY = 127.0f * other.GetForward()->y;
+ m_upZ = 127.0f * other.GetForward()->z;
+ m_vecPos = *other.GetPosition();
+ }
+ void DecompressIntoFullMatrix(CMatrix &other)
+ {
+ other.GetRight()->x = m_rightX / 127.0f;
+ other.GetRight()->y = m_rightY / 127.0f;
+ other.GetRight()->z = m_rightZ / 127.0f;
+ other.GetForward()->x = m_upX / 127.0f;
+ other.GetForward()->y = m_upY / 127.0f;
+ other.GetForward()->z = m_upZ / 127.0f;
+ *other.GetUp() = CrossProduct(*other.GetRight(), *other.GetForward());
+ *other.GetPosition() = m_vecPos;
+ other.Reorthogonalise();
+ }
+}; \ No newline at end of file