Fix matrix inliune lol

This commit is contained in:
intns 2024-05-13 22:28:15 +01:00
parent ef261db46d
commit 62ef40d2cc
3 changed files with 19 additions and 15 deletions

View File

@ -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.

View File

@ -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(); }

View File

@ -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;