Implement/match LegoPathController::ReadEdge (#907)

* Implement/match LegoPathController::ReadEdge

* Fix

* Rename

* Add 100482b0

* Rename
This commit is contained in:
Christian Semmler 2024-05-11 13:45:13 -04:00 committed by GitHub
parent 09394c3512
commit 1f0a2a50ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 86 additions and 19 deletions

View file

@ -9,7 +9,7 @@
struct LegoEdge;
class LegoPathBoundary;
class LegoPathController;
class LegoUnknown100db7f4;
struct LegoUnknown100db7f4;
// VTABLE: LEGO1 0x100d6e28
// SIZE 0x154

View file

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

View file

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

View file

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

View file

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