From 238fd35611576cf56350c882e421f09cef3e28e9 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 7 Apr 2024 07:51:07 -0400 Subject: [PATCH] Match functions, fixes --- LEGO1/lego/legoomni/include/legopathactor.h | 15 +++----- .../lego/legoomni/src/paths/legopathactor.cpp | 38 +++++++------------ LEGO1/mxgeometry/mxgeometry3d.h | 8 ++-- LEGO1/mxgeometry/mxmatrix.h | 4 +- LEGO1/realtime/matrix.h | 4 +- LEGO1/realtime/vector.h | 6 +-- LEGO1/viewmanager/viewmanager.cpp | 6 +-- 7 files changed, 33 insertions(+), 48 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index c545a933..60f2a5ef 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -11,12 +11,7 @@ class LegoPathController; struct LegoActorStruct { LegoActorStruct(); ~LegoActorStruct(); - void FUN_1009a140( - Mx3DPointFloat& p_point1, - Mx3DPointFloat& p_point2, - Mx3DPointFloat& p_point3, - Mx3DPointFloat& p_point4 - ); + void FUN_1009a140(Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, Vector3& p_point4); Mx3DPointFloat m_unk0x00[4]; // 0x00 }; @@ -54,10 +49,10 @@ class LegoPathActor : public LegoActor { virtual MxU8 GetUserNavFlag() { return m_userNavFlag; } // vtable+0x7c virtual MxResult VTable0x80( - Mx3DPointFloat& p_point1, - Mx3DPointFloat& p_point2, - Mx3DPointFloat& p_point3, - Mx3DPointFloat& p_point4 + Vector3& p_point1, + Vector3& p_point2, + Vector3& p_point3, + Vector3& p_point4 ); // vtable+0x80 virtual void VTable0x84(); // vtable+0x84 virtual void VTable0x88(); // vtable+0x88 diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 4af1cbd8..a66c8f18 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -1,6 +1,6 @@ #include "legopathactor.h" -#include "vec.h" +#include DECOMP_SIZE_ASSERT(LegoPathActor, 0x154) @@ -32,29 +32,24 @@ LegoPathActor::~LegoPathActor() } // FUNCTION: LEGO1 0x1002d8d0 -MxResult LegoPathActor::VTable0x80( - Mx3DPointFloat& p_point1, - Mx3DPointFloat& p_point2, - Mx3DPointFloat& p_point3, - Mx3DPointFloat& p_point4 -) +MxResult LegoPathActor::VTable0x80(Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, Vector3& p_point4) { Mx3DPointFloat p1, p2, p3; - p3 = p_point3; - ((Mx3DPointFloat&) p3).Sub(&p_point1); - m_BADuration = NORMSQRD3(p3.GetData()); + + p1 = p_point3; + ((Vector3&) p1).Sub(&p_point1); + m_BADuration = p1.LenSquared(); if (m_BADuration > 0.0f) { m_BADuration = sqrtf(m_BADuration); - p1 = p_point2; - p2 = p_point4; - m_unk0x8c.FUN_1009a140(p_point1, p1, p_point3, p2); - m_BADuration *= 1000.0; + p2 = p_point2; + p3 = p_point4; + m_unk0x8c.FUN_1009a140(p_point1, p2, p_point3, p3); + m_BADuration /= 0.001; return SUCCESS; } - else { - return FAILURE; - } + + return FAILURE; } // STUB: LEGO1 0x1002d9c0 @@ -144,17 +139,12 @@ LegoActorStruct::~LegoActorStruct() } // FUNCTION: LEGO1 0x1009a140 -void LegoActorStruct::FUN_1009a140( - Mx3DPointFloat& p_point1, - Mx3DPointFloat& p_point2, - Mx3DPointFloat& p_point3, - Mx3DPointFloat& p_point4 -) +void LegoActorStruct::FUN_1009a140(Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, Vector3& p_point4) { m_unk0x00[0] = p_point1; m_unk0x00[1] = p_point2; - for (MxU32 i = 0; i < 3; i++) { + for (MxS32 i = 0; i < 3; i++) { m_unk0x00[2][i] = (p_point3[i] - p_point1[i]) * 3.0f - p_point2[i] * 2.0f - p_point4[i]; m_unk0x00[3][i] = (p_point1[i] - p_point3[i]) * 2.0f + p_point4[i] + p_point2[i]; } diff --git a/LEGO1/mxgeometry/mxgeometry3d.h b/LEGO1/mxgeometry/mxgeometry3d.h index c5dfeeda..6b822ae0 100644 --- a/LEGO1/mxgeometry/mxgeometry3d.h +++ b/LEGO1/mxgeometry/mxgeometry3d.h @@ -32,8 +32,8 @@ class Mx3DPointFloat : public Vector3 { inline float GetY() { return m_data[1]; } inline float GetZ() { return m_data[2]; } - inline float& operator[](size_t idx) { return m_data[idx]; } - inline const float& operator[](size_t idx) const { return m_data[idx]; } + inline float& operator[](int idx) { return m_data[idx]; } + inline const float& operator[](int idx) const { return m_data[idx]; } // SYNTHETIC: LEGO1 0x10010c00 // Mx3DPointFloat::operator= @@ -60,8 +60,8 @@ class Mx4DPointFloat : public Vector4 { // FUNCTION: LEGO1 0x10003200 virtual void operator=(const Vector4& p_impl) { EqualsImpl(p_impl.m_data); } // vtable+0x98 - inline float& operator[](size_t idx) { return m_data[idx]; } - inline const float& operator[](size_t idx) const { return m_data[idx]; } + inline float& operator[](int idx) { return m_data[idx]; } + inline const float& operator[](int idx) const { return m_data[idx]; } private: float m_elements[4]; // 0x08 diff --git a/LEGO1/mxgeometry/mxmatrix.h b/LEGO1/mxgeometry/mxmatrix.h index c32635b9..abbc92f5 100644 --- a/LEGO1/mxgeometry/mxmatrix.h +++ b/LEGO1/mxgeometry/mxmatrix.h @@ -14,8 +14,8 @@ class MxMatrix : public Matrix4 { inline MxMatrix(const Matrix4& p_matrix) : Matrix4(m_elements) { Equals(p_matrix); } - float* operator[](size_t idx) { return m_data[idx]; } - const float* operator[](size_t idx) const { return m_data[idx]; } + float* operator[](int idx) { return m_data[idx]; } + const float* operator[](int idx) const { return m_data[idx]; } // FUNCTION: LEGO1 0x10002850 void operator=(const Matrix4& p_matrix) override { Equals(p_matrix); } // vtable+0x28 diff --git a/LEGO1/realtime/matrix.h b/LEGO1/realtime/matrix.h index 1345e965..bc45dd54 100644 --- a/LEGO1/realtime/matrix.h +++ b/LEGO1/realtime/matrix.h @@ -144,8 +144,8 @@ class Matrix4 { inline virtual void ToQuaternion(Vector4& p_resultQuat); // vtable+0x40 inline virtual int FromQuaternion(const Vector4& p_vec); // vtable+0x44 - float* operator[](size_t idx) { return m_data[idx]; } - const float* operator[](size_t idx) const { return m_data[idx]; } + float* operator[](int idx) { return m_data[idx]; } + const float* operator[](int idx) const { return m_data[idx]; } protected: float (*m_data)[4]; diff --git a/LEGO1/realtime/vector.h b/LEGO1/realtime/vector.h index 2911e7c4..746008f2 100644 --- a/LEGO1/realtime/vector.h +++ b/LEGO1/realtime/vector.h @@ -152,8 +152,8 @@ class Vector2 { Vector2::SetVector(&p_other); return *this; } - inline float& operator[](size_t idx) { return m_data[idx]; } - inline const float& operator[](size_t idx) const { return m_data[idx]; } + inline float& operator[](int idx) { return m_data[idx]; } + inline const float& operator[](int idx) const { return m_data[idx]; } protected: float* m_data; // 0x04 @@ -265,7 +265,7 @@ class Vector3 : public Vector2 { // FUNCTION: LEGO1 0x10003bd0 float LenSquared() const override { - return m_data[1] * m_data[1] + m_data[0] * m_data[0] + m_data[2] * m_data[2]; + return m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2]; } // vtable+0x40 inline void Fill(float p_value) { EqualsScalar(&p_value); } diff --git a/LEGO1/viewmanager/viewmanager.cpp b/LEGO1/viewmanager/viewmanager.cpp index 588fb21d..0521dc26 100644 --- a/LEGO1/viewmanager/viewmanager.cpp +++ b/LEGO1/viewmanager/viewmanager.cpp @@ -2,9 +2,10 @@ #include "mxdirectx/mxstopwatch.h" #include "tgl/d3drm/impl.h" -#include "vec.h" #include "viewlod.h" +#include + DECOMP_SIZE_ASSERT(ViewManager, 0x1bc) // GLOBAL: LEGO1 0x100dbcd8 @@ -372,8 +373,7 @@ void ViewManager::FUN_100a6b90() { flags &= ~c_bit2; - // TODO: Should be signed, but worsens match - unsigned int i, j, k; + int i, j, k; for (i = 0; i < 8; i++) { for (j = 0; j < 3; j++) {