From 13d994a1ee371239c3e4cf02629c72cdb1d795ea Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Thu, 28 Mar 2024 09:19:32 -0400 Subject: [PATCH] Implement LegoExtraActor:: VTable0xa4 & FUN_1002aae0 (#742) * Implement LegoExtraActor:: VTable0xa4 & FUN_1002aae0 * Match LegoExtraActor::FUN_1002aae0 --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/include/legoextraactor.h | 2 +- LEGO1/lego/legoomni/include/legopathactor.h | 6 +-- .../legoomni/src/paths/legoextraactor.cpp | 43 ++++++++++++++++--- .../lego/legoomni/src/paths/legopathactor.cpp | 2 +- LEGO1/realtime/matrix.h | 3 ++ LEGO1/realtime/vector.h | 5 ++- 6 files changed, 50 insertions(+), 11 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index 2b2612a6..be929f92 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -41,7 +41,7 @@ class LegoExtraActor : public virtual LegoAnimActor { MxU32 VTable0x90(float p_float, Matrix4& p_matrix) override; // vtable+0x90 MxS32 VTable0x94() override; // vtable+0x94 void VTable0x9c() override; // vtable+0x9c - void VTable0xa4() override; // vtable+0xa4 + void VTable0xa4(MxU8& p_und1, MxS32& p_und2) override; // vtable+0xa4 void VTable0xc4() override; // vtable+0xc4 virtual MxResult FUN_1002aae0(); diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 8cdf5b00..2c22df81 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -57,8 +57,8 @@ class LegoPathActor : public LegoActor { // FUNCTION: LEGO1 0x10002d60 virtual MxS32 VTable0xa0() { return 0; } // vtable+0xa0 - virtual void VTable0xa4(); // vtable+0xa4 - virtual void VTable0xa8(); // vtable+0xa8 + virtual void VTable0xa4(MxU8&, MxS32&); // vtable+0xa4 + virtual void VTable0xa8(); // vtable+0xa8 // FUNCTION: LEGO1 0x10002d70 virtual void VTable0xac(MxFloat p_unk0x13c) { m_unk0x13c = p_unk0x13c; } // vtable+0xac @@ -104,7 +104,7 @@ class LegoPathActor : public LegoActor { MxFloat m_unk0xa0; // 0xa0 undefined m_unk0xa4[0x38]; // 0xa4 MxU32 m_unk0xdc; // 0xdc - undefined4 m_destEdge; // 0xe0 + Edge* m_destEdge; // 0xe0 undefined4 m_unk0xe4; // 0xe4 undefined2 m_unk0xe8; // 0xe8 MxBool m_userNavFlag; // 0xea diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index d469a7b2..3243cb8f 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -86,16 +86,49 @@ MxU32 LegoExtraActor::VTable0x90(float p_time, Matrix4& p_transform) } } -// STUB: LEGO1 0x1002aa90 -void LegoExtraActor::VTable0xa4() +// FUNCTION: LEGO1 0x1002aa90 +void LegoExtraActor::VTable0xa4(MxU8& p_und1, MxS32& p_und2) { + switch (m_unk0x0c) { + case 1: + p_und1 = 1; + p_und2 = 1; + break; + case 2: + p_und1 = 0; + p_und2 = 1; + break; + default: + p_und1 = 1; + p_und2 = rand() % p_und2 + 1; + break; + } } -// STUB: LEGO1 0x1002aae0 +// FUNCTION: LEGO1 0x1002aae0 MxResult LegoExtraActor::FUN_1002aae0() { - // TODO - VTable0x9c(); + LegoPathBoundary* oldEdge = m_boundary; + Vector3 dir(m_unk0xec[0]); + Vector3 right(m_unk0xec[1]); + Vector3 up(m_unk0xec[2]); + Vector3 unused(m_unk0xec[3]); + + up.Mul(-1.0f); + dir.EqualsCross(&right, &up); + + if (m_boundary == m_destEdge->m_faceA) { + m_boundary = (LegoPathBoundary*) m_destEdge->m_faceB; + } + else { + m_boundary = (LegoPathBoundary*) m_destEdge->m_faceA; + } + + if (!m_boundary) { + m_boundary = oldEdge; + } + + LegoPathActor::VTable0x9c(); return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index f8b8d297..8ab1c470 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -81,7 +81,7 @@ void LegoPathActor::VTable0x9c() } // STUB: LEGO1 0x1002f650 -void LegoPathActor::VTable0xa4() +void LegoPathActor::VTable0xa4(MxU8&, MxS32&) { // TODO } diff --git a/LEGO1/realtime/matrix.h b/LEGO1/realtime/matrix.h index 8604e0ce..1345e965 100644 --- a/LEGO1/realtime/matrix.h +++ b/LEGO1/realtime/matrix.h @@ -9,6 +9,9 @@ struct UnknownMatrixType { float m_data[4][4]; }; +// Note: Many functions most likely take const references/pointers instead of non-const. +// The class needs to undergo a very careful refactoring to fix that (no matches should break). + // VTABLE: LEGO1 0x100d4350 // SIZE 0x08 class Matrix4 { diff --git a/LEGO1/realtime/vector.h b/LEGO1/realtime/vector.h index ad1f53eb..2911e7c4 100644 --- a/LEGO1/realtime/vector.h +++ b/LEGO1/realtime/vector.h @@ -6,6 +6,9 @@ #include #include +// Note: Many functions most likely take const references/pointers instead of non-const. +// The class needs to undergo a very careful refactoring to fix that (no matches should break). + // VTABLE: LEGO1 0x100d4288 // SIZE 0x08 class Vector2 { @@ -130,7 +133,7 @@ class Vector2 { virtual void Mul(Vector2* p_other) { MulVectorImpl(p_other->m_data); } // vtable+0x60 // FUNCTION: LEGO1 0x10002230 - virtual void Mul(float& p_value) { MulScalarImpl(&p_value); } // vtable+0x5c + virtual void Mul(const float& p_value) { MulScalarImpl((float*) &p_value); } // vtable+0x5c // FUNCTION: LEGO1 0x10002240 virtual void Div(float& p_value) { DivScalarImpl(&p_value); } // vtable+0x68