From 62ef40d2ccbfe445a097592e296ecf3ca286b302 Mon Sep 17 00:00:00 2001 From: intns <84647527+intns@users.noreply.github.com> Date: Mon, 13 May 2024 22:28:15 +0100 Subject: [PATCH] Fix matrix inliune lol --- include/Matrixf.h | 22 +++++++++++++--------- include/Vector3.h | 8 ++++---- src/plugProjectKandoU/collinfo.cpp | 4 ++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/Matrixf.h b/include/Matrixf.h index 4a38d81c1..e6c3d197d 100644 --- a/include/Matrixf.h +++ b/include/Matrixf.h @@ -215,19 +215,17 @@ struct Matrixf { */ inline void getColumn(int index, Vector3f& out) { - out.x = mMatrix.mtxView[0][index]; - out.y = mMatrix.mtxView[1][index]; - out.z = mMatrix.mtxView[2][index]; + out.x = operator()(0, index); + out.y = operator()(1, index); + out.z = operator()(2, index); } // for navi_demoCheck.cpp inline void getBasis(int index, Vector3f& out) { - out.x = mMatrix.mtxView[0][index]; - out.y = mMatrix.mtxView[1][index]; - out.z = mMatrix.mtxView[2][index]; - - FORCE_DONT_INLINE; + out.x = operator()(0, index); + out.y = operator()(1, index); + out.z = operator()(2, index); } /** @@ -297,6 +295,12 @@ struct Matrixf { */ inline Vector3f getRow(int index) { return Vector3f(mMatrix.mtxView[index][0], mMatrix.mtxView[index][1], mMatrix.mtxView[index][2]); } + inline f32 getRowLength(int index) + { + Vector3f row = getRow(index); + return row.length(); + } + /** * @brief Sets the values of a specific row in the matrix. * @@ -330,7 +334,7 @@ struct Matrixf { * * @param out The output vector to store the translation. */ - inline void getTranslation(Vector3f& out) { getColumn(3, out); } + inline void getTranslation(Vector3f& out) { getBasis(3, out); } /** * Returns the translation vector of the matrix. diff --git a/include/Vector3.h b/include/Vector3.h index 227a29612..45e6bd8d1 100644 --- a/include/Vector3.h +++ b/include/Vector3.h @@ -49,10 +49,10 @@ struct Vector3 { * @param from The starting point of the direction vector. * @param to The ending point of the direction vector. */ - static inline void getDirectionFromTo(Vector3& from, Vector3& to) + static inline f32 getDirectionFromTo(const Vector3& from, Vector3& to) { to -= from; - to.normalise(); + return to.normalise(); } /** @@ -252,10 +252,10 @@ struct Vector3 { * @param from The starting point of the direction. * @param to The ending point of the direction. */ - inline void setDirectionFromTo(Vector3& from, Vector3& to) + inline f32 setDirectionFromTo(const Vector3& from, const Vector3& to) { *this = to - from; - this->normalise(); + return this->normalise(); } static inline f32 distance(Vector3& a, Vector3& b) { return (a - b).length(); } diff --git a/src/plugProjectKandoU/collinfo.cpp b/src/plugProjectKandoU/collinfo.cpp index aa93d7783..cd9141973 100644 --- a/src/plugProjectKandoU/collinfo.cpp +++ b/src/plugProjectKandoU/collinfo.cpp @@ -848,11 +848,11 @@ void CollPart::calcStickLocal(Vector3f& input, Vector3f& localPosition) case COLLTYPE_SPHERE: Matrixf mtx; makeMatrixTo(mtx); + Matrixf inv; PSMTXInverse(mtx.mMatrix.mtxView, inv.mMatrix.mtxView); - Vector3f row0 = mtx.getRow(0); - f32 len = _length(row0); + f32 len = mtx.getRowLength(0); if (FABS(len) < 0.001f) { localPosition = Vector3f(0.0f); return;