From 1f0a2a50ce33b366fd06d69a0a1567581ea6e443 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 11 May 2024 13:45:13 -0400 Subject: [PATCH] Implement/match LegoPathController::ReadEdge (#907) * Implement/match LegoPathController::ReadEdge * Fix * Rename * Add 100482b0 * Rename --- LEGO1/lego/legoomni/include/legopathactor.h | 2 +- .../legoomni/include/legopathcontroller.h | 8 +- .../legoomni/src/paths/legopathcontroller.cpp | 83 ++++++++++++++++--- .../lego/sources/geom/legounkown100db7f4.cpp | 2 +- LEGO1/lego/sources/geom/legounkown100db7f4.h | 10 ++- 5 files changed, 86 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 06eb4103..2051a1b8 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -9,7 +9,7 @@ struct LegoEdge; class LegoPathBoundary; class LegoPathController; -class LegoUnknown100db7f4; +struct LegoUnknown100db7f4; // VTABLE: LEGO1 0x100d6e28 // SIZE 0x154 diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index 7149300b..53a4ef36 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -16,7 +16,7 @@ class Vector3; // VTABLE: LEGO1 0x100d7da8 // SIZE 0x40 -class LegoPathCtrlEdge : public LegoUnknown100db7f4 {}; +struct LegoPathCtrlEdge : public LegoUnknown100db7f4 {}; struct LegoPathCtrlEdgeCompare { MxU32 operator()(const LegoPathCtrlEdge* p_lhs, const LegoPathCtrlEdge* p_rhs) const @@ -73,10 +73,10 @@ class LegoPathController : public MxCore { private: MxResult Read(LegoStorage* p_storage); - MxResult FUN_10047b30(LegoStorage* p_storage); - MxResult FUN_10047c10(LegoStorage* p_storage); + MxResult ReadStructs(LegoStorage* p_storage); + MxResult ReadEdges(LegoStorage* p_storage); MxResult FUN_10047e90(LegoStorage* p_storage); - static MxResult FUN_100482b0(LegoStorage* p_storage, Mx3DPointFloat&); + static MxResult ReadVector(LegoStorage* p_storage, Mx3DPointFloat&); LegoPathBoundary* m_unk0x08; // 0x08 LegoPathCtrlEdge* m_unk0x0c; // 0x0c diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index c6c70780..1889e391 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -154,19 +154,19 @@ MxResult LegoPathController::Read(LegoStorage* p_storage) m_unk0x08 = new LegoPathBoundary[m_numL]; } - if (m_numT > 0 && FUN_10047b30(p_storage) != SUCCESS) { + if (m_numT > 0 && ReadStructs(p_storage) != SUCCESS) { return FAILURE; } if (m_numN > 0) { for (MxS32 i = 0; i < m_numN; i++) { - if (FUN_100482b0(p_storage, m_unk0x10[i]) != SUCCESS) { + if (ReadVector(p_storage, m_unk0x10[i]) != SUCCESS) { return FAILURE; } } } - if (m_numE > 0 && FUN_10047c10(p_storage) != SUCCESS) { + if (m_numE > 0 && ReadEdges(p_storage) != SUCCESS) { return FAILURE; } @@ -183,7 +183,7 @@ MxResult LegoPathController::Read(LegoStorage* p_storage) // FUNCTION: LEGO1 0x10047b30 // FUNCTION: BETA10 0x100b7cd6 -MxResult LegoPathController::FUN_10047b30(LegoStorage* p_storage) +MxResult LegoPathController::ReadStructs(LegoStorage* p_storage) { for (MxS32 i = 0; i < m_numT; i++) { MxU8 length = 0; @@ -210,11 +210,71 @@ MxResult LegoPathController::FUN_10047b30(LegoStorage* p_storage) return SUCCESS; } -// STUB: LEGO1 0x10047c10 +// FUNCTION: LEGO1 0x10047c10 // FUNCTION: BETA10 0x100b7df3 -MxResult LegoPathController::FUN_10047c10(LegoStorage* p_storage) +MxResult LegoPathController::ReadEdges(LegoStorage* p_storage) { - // TODO + for (MxS32 i = 0; i < m_numE; i++) { + LegoPathCtrlEdge& edge = m_unk0x0c[i]; + MxU16 s; + + if (p_storage->Read(&edge.m_flags, sizeof(edge.m_flags)) != SUCCESS) { + return FAILURE; + } + + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_pointA = &m_unk0x10[s]; + + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_pointB = &m_unk0x10[s]; + + if (edge.m_flags & LegoUnknown100db7f4::c_bit3) { + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_faceA = &m_unk0x08[s]; + + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_ccwA = &m_unk0x0c[s]; + + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_cwA = &m_unk0x0c[s]; + } + + if (edge.m_flags & LegoUnknown100db7f4::c_bit4) { + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_faceB = &m_unk0x08[s]; + + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_ccwB = &m_unk0x0c[s]; + + if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + return FAILURE; + } + edge.m_cwB = &m_unk0x0c[s]; + } + + if (ReadVector(p_storage, edge.m_unk0x28) != SUCCESS) { + return FAILURE; + } + + if (p_storage->Read(&edge.m_unk0x3c, sizeof(edge.m_unk0x3c)) != SUCCESS) { + return FAILURE; + } + } + return SUCCESS; } @@ -226,10 +286,13 @@ MxResult LegoPathController::FUN_10047e90(LegoStorage* p_storage) return SUCCESS; } -// STUB: LEGO1 0x100482b0 +// FUNCTION: LEGO1 0x100482b0 // FUNCTION: BETA10 0x100b8864 -MxResult LegoPathController::FUN_100482b0(LegoStorage* p_storage, Mx3DPointFloat&) +MxResult LegoPathController::ReadVector(LegoStorage* p_storage, Mx3DPointFloat& p_vec) { - // TODO + if (p_storage->Read(p_vec.GetData(), sizeof(float) * 3) != SUCCESS) { + return FAILURE; + } + return SUCCESS; } diff --git a/LEGO1/lego/sources/geom/legounkown100db7f4.cpp b/LEGO1/lego/sources/geom/legounkown100db7f4.cpp index 4262da76..eab51447 100644 --- a/LEGO1/lego/sources/geom/legounkown100db7f4.cpp +++ b/LEGO1/lego/sources/geom/legounkown100db7f4.cpp @@ -6,7 +6,7 @@ DECOMP_SIZE_ASSERT(LegoUnknown100db7f4, 0x40) // FUNCTION: BETA10 0x10183050 LegoUnknown100db7f4::LegoUnknown100db7f4() { - m_unk0x24 = 0; + m_flags = 0; m_unk0x28.Clear(); m_unk0x3c = 0; } diff --git a/LEGO1/lego/sources/geom/legounkown100db7f4.h b/LEGO1/lego/sources/geom/legounkown100db7f4.h index fa0dd995..be51e2d1 100644 --- a/LEGO1/lego/sources/geom/legounkown100db7f4.h +++ b/LEGO1/lego/sources/geom/legounkown100db7f4.h @@ -7,8 +7,13 @@ // VTABLE: LEGO1 0x100db7f4 // SIZE 0x40 -class LegoUnknown100db7f4 : public LegoEdge { +struct LegoUnknown100db7f4 : public LegoEdge { public: + enum { + c_bit3 = 0x04, + c_bit4 = 0x08 + }; + LegoUnknown100db7f4(); // FUNCTION: LEGO1 0x1002ddc0 @@ -30,8 +35,7 @@ class LegoUnknown100db7f4 : public LegoEdge { // SYNTHETIC: LEGO1 0x1009a6c0 // LegoUnknown100db7f4::`scalar deleting destructor' -private: - LegoU16 m_unk0x24; // 0x24 + LegoU16 m_flags; // 0x24 Mx3DPointFloat m_unk0x28; // 0x28 LegoU32 m_unk0x3c; // 0x3c };