From c8a0e4cf8d2204e619c1f642ba3465ac56b8944f Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 19 May 2024 14:22:53 -0400 Subject: [PATCH] Implement LegoPathActor::VTable0x68 (#938) * Implement LegoPathActor::VTable0x68 * Fix naming --- LEGO1/lego/legoomni/include/legopathactor.h | 25 ++++++- .../lego/legoomni/src/paths/legopathactor.cpp | 74 ++++++++++++++++++- 2 files changed, 93 insertions(+), 6 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 43b6c480..e800c281 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -10,6 +10,7 @@ struct LegoEdge; class LegoPathBoundary; class LegoPathController; struct LegoUnknown100db7f4; +class LegoWEEdge; // VTABLE: LEGO1 0x100d6e28 // SIZE 0x154 @@ -35,8 +36,8 @@ class LegoPathActor : public LegoActor { return !strcmp(p_name, LegoPathActor::ClassName()) || LegoActor::IsA(p_name); } - void ParseAction(char* p_extra) override; // vtable+0x20 - virtual MxS32 VTable0x68(Vector3&, Vector3&, Vector3&); // vtable+0x68 + void ParseAction(char* p_extra) override; // vtable+0x20 + virtual MxS32 VTable0x68(Vector3& p_v1, Vector3& p_v2, Vector3& p_v3); // vtable+0x68 virtual MxU32 VTable0x6c( LegoPathBoundary* p_boundary, Vector3& p_v1, @@ -129,6 +130,17 @@ class LegoPathActor : public LegoActor { // LegoPathActor::`scalar deleting destructor' protected: + inline MxU32 FUN_1002edd0( + list& p_boundaries, + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3, + MxS32 p_und + ); + MxFloat m_BADuration; // 0x78 MxFloat m_unk0x7c; // 0x7c MxFloat m_actorTime; // 0x80 @@ -152,4 +164,13 @@ class LegoPathActor : public LegoActor { MxFloat m_unk0x150; // 0x150 }; +// TEMPLATE: LEGO1 0x1002ef10 +// list >::~list > + +// TEMPLATE: LEGO1 0x1002ef80 +// list >::insert + +// TEMPLATE: LEGO1 0x1002efd0 +// List::~List + #endif // LEGOPATHACTOR_H diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 0a00221b..390f185e 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -464,11 +464,77 @@ MxU32 LegoPathActor::VTable0x6c( return 0; } -// STUB: LEGO1 0x1002ebe0 -MxS32 LegoPathActor::VTable0x68(Vector3&, Vector3&, Vector3&) +// FUNCTION: LEGO1 0x1002ebe0 +// FUNCTION: BETA10 0x100af35e +MxS32 LegoPathActor::VTable0x68(Vector3& p_v1, Vector3& p_v2, Vector3& p_v3) { - // TODO - return 0; + Mx3DPointFloat v2(p_v2); + ((Vector3&) v2).Sub(&p_v1); + + float len = v2.LenSquared(); + + if (len <= 0.001) { + return 0; + } + + len = sqrt(len); + ((Vector3&) v2).Div(len); + + float radius = m_roi->GetWorldBoundingSphere().Radius(); + list boundaries; + + return FUN_1002edd0(boundaries, m_boundary, p_v1, v2, len, radius, p_v3, 0); +} + +// FUNCTION: LEGO1 0x1002edd0 +inline MxU32 LegoPathActor::FUN_1002edd0( + list& p_boundaries, + LegoPathBoundary* p_boundary, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + float p_f2, + Vector3& p_v3, + MxS32 p_und +) +{ + MxU32 result = VTable0x6c(p_boundary, p_v1, p_v2, p_f1, p_f2, p_v3); + + if (result == 0) { + p_boundaries.push_back(p_boundary); + + if (p_und >= 2) { + return 0; + } + + LegoS32 numEdges = p_boundary->GetNumEdges(); + for (MxS32 i = 0; i < numEdges; i++) { + LegoUnknown100db7f4* edge = ((LegoUnknown100db7f4*) p_boundary->GetEdges()[i]); + LegoPathBoundary* boundary = (LegoPathBoundary*) edge->OtherFace(p_boundary); + + if (boundary != NULL) { + list::iterator it; + + for (it = p_boundaries.begin(); it != p_boundaries.end(); it++) { + if ((*it) == boundary) { + break; + } + } + + if (it == p_boundaries.end()) { + result = FUN_1002edd0(p_boundaries, boundary, p_v1, p_v2, p_f1, p_f2, p_v3, p_und + 1); + + if (result != 0) { + return result; + } + } + } + } + + result = 0; + } + + return result; } // STUB: LEGO1 0x1002f020