From 334246432189c7b283fce7b8901ec12f78654d31 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 20 May 2024 11:34:31 -0400 Subject: [PATCH] Implement/match LegoPathController::FUN_1004a240 (#941) --- LEGO1/lego/legoomni/include/act2actor.h | 2 +- .../lego/legoomni/include/legocarraceactor.h | 2 +- LEGO1/lego/legoomni/include/legoextraactor.h | 2 +- LEGO1/lego/legoomni/include/legojetski.h | 2 +- .../legoomni/include/legojetskiraceactor.h | 2 +- LEGO1/lego/legoomni/include/legopathactor.h | 15 ++++-- .../lego/legoomni/include/legopathboundary.h | 8 ++- .../legoomni/include/legopathcontroller.h | 11 +++++ .../legoomni/include/legopathedgecontainer.h | 49 +++++++++++++++++++ LEGO1/lego/legoomni/include/legoracecar.h | 2 +- LEGO1/lego/legoomni/src/actors/act2actor.cpp | 2 +- .../legoomni/src/entity/legocarraceactor.cpp | 2 +- LEGO1/lego/legoomni/src/entity/legojetski.cpp | 2 +- .../src/entity/legojetskiraceactor.cpp | 2 +- .../legoomni/src/paths/legoextraactor.cpp | 6 +-- .../lego/legoomni/src/paths/legopathactor.cpp | 21 ++++---- .../legoomni/src/paths/legopathboundary.cpp | 6 +-- .../legoomni/src/paths/legopathcontroller.cpp | 34 +++++++++++++ LEGO1/lego/legoomni/src/race/legoracecar.cpp | 2 +- 19 files changed, 141 insertions(+), 31 deletions(-) create mode 100644 LEGO1/lego/legoomni/include/legopathedgecontainer.h diff --git a/LEGO1/lego/legoomni/include/act2actor.h b/LEGO1/lego/legoomni/include/act2actor.h index f73c6d07..7ae28781 100644 --- a/LEGO1/lego/legoomni/include/act2actor.h +++ b/LEGO1/lego/legoomni/include/act2actor.h @@ -15,7 +15,7 @@ class Act2Actor : public LegoAnimActor { MxS32 VTable0x68(Vector3&, Vector3&, Vector3&) override; // vtable+0x68 void VTable0x70(float p_und) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor*, MxBool) override; // vtable+0x94 - MxResult WaitForAnimation() override; // vtable+0x9c + MxResult VTable0x9c() override; // vtable+0x9c MxS32 VTable0xa0() override; // vtable+0xa0 // SYNTHETIC: LEGO1 0x1001a0a0 diff --git a/LEGO1/lego/legoomni/include/legocarraceactor.h b/LEGO1/lego/legoomni/include/legocarraceactor.h index 97e734cb..dc0a74be 100644 --- a/LEGO1/lego/legoomni/include/legocarraceactor.h +++ b/LEGO1/lego/legoomni/include/legocarraceactor.h @@ -39,7 +39,7 @@ class LegoCarRaceActor : public virtual LegoRaceActor { MxU32 VTable0x90(float, Matrix4&) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - MxResult WaitForAnimation() override; // vtable+0x9c + MxResult VTable0x9c() override; // vtable+0x9c virtual void FUN_10080590(); diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index ea3fdeb1..2e8bae7d 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -46,7 +46,7 @@ class LegoExtraActor : public virtual LegoAnimActor { void VTable0x74(Matrix4& p_transform) override; // vtable+0x74 MxU32 VTable0x90(float p_float, Matrix4& p_matrix) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 - MxResult WaitForAnimation() override; // vtable+0x9c + MxResult VTable0x9c() override; // vtable+0x9c void VTable0xa4(MxU8& p_und1, MxS32& p_und2) override; // vtable+0xa4 void VTable0xc4() override; // vtable+0xc4 diff --git a/LEGO1/lego/legoomni/include/legojetski.h b/LEGO1/lego/legoomni/include/legojetski.h index 61fd0121..682fbda8 100644 --- a/LEGO1/lego/legoomni/include/legojetski.h +++ b/LEGO1/lego/legoomni/include/legojetski.h @@ -44,7 +44,7 @@ class LegoJetski : public LegoJetskiRaceActor, public LegoRaceMap { void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - MxResult WaitForAnimation() override; // vtable+0x9c + MxResult VTable0x9c() override; // vtable+0x9c virtual void FUN_100136f0(float p_worldSpeed); diff --git a/LEGO1/lego/legoomni/include/legojetskiraceactor.h b/LEGO1/lego/legoomni/include/legojetskiraceactor.h index 388107d1..e4616527 100644 --- a/LEGO1/lego/legoomni/include/legojetskiraceactor.h +++ b/LEGO1/lego/legoomni/include/legojetskiraceactor.h @@ -37,7 +37,7 @@ class LegoJetskiRaceActor : public virtual LegoCarRaceActor { ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 void VTable0x98() override; // vtable+0x98 - MxResult WaitForAnimation() override; // vtable+0x9c + MxResult VTable0x9c() override; // vtable+0x9c void VTable0x1c() override; // vtable+0x1c // SYNTHETIC: LEGO1 0x10081d40 diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index e800c281..261ee3a6 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -9,6 +9,7 @@ struct LegoEdge; class LegoPathBoundary; class LegoPathController; +struct LegoPathEdgeContainer; struct LegoUnknown100db7f4; class LegoWEEdge; @@ -85,8 +86,8 @@ class LegoPathActor : public LegoActor { // FUNCTION: LEGO1 0x10002d50 virtual MxResult VTable0x94(LegoPathActor*, MxBool) { return 0; } // vtable+0x94 - virtual void VTable0x98(); // vtable+0x98 - virtual MxResult WaitForAnimation(); // vtable+0x9c + virtual void VTable0x98(); // vtable+0x98 + virtual MxResult VTable0x9c(); // vtable+0x9c // FUNCTION: LEGO1 0x10002d60 virtual MxS32 VTable0xa0() { return 0; } // vtable+0xa0 @@ -148,13 +149,13 @@ class LegoPathActor : public LegoActor { LegoPathBoundary* m_boundary; // 0x88 LegoUnknown m_unk0x8c; // 0x8c MxU32 m_state; // 0xdc - LegoEdge* m_destEdge; // 0xe0 + LegoUnknown100db7f4* m_destEdge; // 0xe0 MxFloat m_unk0xe4; // 0xe4 undefined m_unk0xe8; // 0xe8 undefined m_unk0xe9; // 0xe9 MxBool m_userNavFlag; // 0xea MxMatrix m_unk0xec; // 0xec - undefined* m_unk0x134; // 0x134 + LegoPathEdgeContainer* m_grec; // 0x134 LegoPathController* m_controller; // 0x138 MxFloat m_unk0x13c; // 0x13c MxFloat m_unk0x140; // 0x140 @@ -164,6 +165,12 @@ class LegoPathActor : public LegoActor { MxFloat m_unk0x150; // 0x150 }; +// TEMPLATE: LEGO1 0x10018b70 +// List::~List + +// TEMPLATE: LEGO1 0x10018bc0 +// list >::~list > + // TEMPLATE: LEGO1 0x1002ef10 // list >::~list > diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index ba548d4f..448eb37c 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -34,7 +34,13 @@ class LegoPathBoundary : public LegoWEGEdge { MxResult AddActor(LegoPathActor* p_actor); MxResult RemoveActor(LegoPathActor* p_actor); void FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPathActor* p_actor); - MxU32 Intersect(float p_scale, Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, LegoEdge*& p_edge); + MxU32 Intersect( + float p_scale, + Vector3& p_point1, + Vector3& p_point2, + Vector3& p_point3, + LegoUnknown100db7f4*& p_edge + ); MxU32 FUN_10057fe0(LegoAnimPresenter* p_presenter); MxU32 FUN_100586e0(LegoAnimPresenter* p_presenter); diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index 46c4935c..10b83de5 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -103,6 +103,14 @@ class LegoPathController : public MxCore { LegoPathBoundary* GetPathBoundary(const char* p_name); void Enable(MxBool p_enable); void FUN_10046bb0(LegoWorld* p_world); + MxU32 FUN_1004a240( + LegoPathEdgeContainer& p_grec, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + LegoUnknown100db7f4*& p_edge, + LegoPathBoundary*& p_boundary + ); static MxResult Init(); static MxResult Reset(); @@ -177,6 +185,9 @@ class LegoPathController : public MxCore { // SYNTHETIC: LEGO1 0x10047ae0 // LegoUnknown100db7f4::~LegoUnknown100db7f4 +// TEMPLATE: LEGO1 0x10048f70 +// list >::erase + // TEMPLATE: LEGO1 0x1004a780 // _Construct diff --git a/LEGO1/lego/legoomni/include/legopathedgecontainer.h b/LEGO1/lego/legoomni/include/legopathedgecontainer.h new file mode 100644 index 00000000..2d6f7b38 --- /dev/null +++ b/LEGO1/lego/legoomni/include/legopathedgecontainer.h @@ -0,0 +1,49 @@ +#ifndef LEGOPATHEDGECONTAINER_H +#define LEGOPATHEDGECONTAINER_H + +#include "mxgeometry/mxgeometry3d.h" +#include "mxstl/stlcompat.h" +#include "mxtypes.h" + +class LegoPathBoundary; +struct LegoUnknown100db7f4; + +// SIZE 0x08 +struct LegoBoundaryEdge { + LegoUnknown100db7f4* m_edge; // 0x00 + LegoPathBoundary* m_boundary; // 0x04 + + int operator==(LegoBoundaryEdge) const { return 0; } + int operator<(LegoBoundaryEdge) const { return 0; } +}; + +// SIZE 0x3c +struct LegoPathEdgeContainer : public list { + enum { + c_bit1 = 0x01 + }; + + // FUNCTION: BETA10 0x100118e0 + LegoPathEdgeContainer() + { + m_boundary = NULL; + m_flags = 0; + } + + void SetBit1(MxU32 p_flag) + { + if (p_flag) { + m_flags |= c_bit1; + } + else { + m_flags &= ~c_bit1; + } + } + + Mx3DPointFloat m_unk0x0c; // 0x0c + Mx3DPointFloat m_unk0x20; // 0x20 + LegoPathBoundary* m_boundary; // 0x34 + MxU8 m_flags; // 0x38 +}; + +#endif // LEGOPATHEDGECONTAINER_H diff --git a/LEGO1/lego/legoomni/include/legoracecar.h b/LEGO1/lego/legoomni/include/legoracecar.h index d090b686..b8b1f66b 100644 --- a/LEGO1/lego/legoomni/include/legoracecar.h +++ b/LEGO1/lego/legoomni/include/legoracecar.h @@ -43,7 +43,7 @@ class LegoRaceCar : public LegoCarRaceActor, public LegoRaceMap { void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - MxResult WaitForAnimation() override; // vtable+0x9c + MxResult VTable0x9c() override; // vtable+0x9c virtual void FUN_10012ea0(float p_worldSpeed); virtual void FUN_10012ff0(float); diff --git a/LEGO1/lego/legoomni/src/actors/act2actor.cpp b/LEGO1/lego/legoomni/src/actors/act2actor.cpp index bd187361..bc100885 100644 --- a/LEGO1/lego/legoomni/src/actors/act2actor.cpp +++ b/LEGO1/lego/legoomni/src/actors/act2actor.cpp @@ -22,7 +22,7 @@ MxResult Act2Actor::VTable0x94(LegoPathActor*, MxBool) } // STUB: LEGO1 0x10018a20 -MxResult Act2Actor::WaitForAnimation() +MxResult Act2Actor::VTable0x9c() { // TODO return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp index d724f763..a7d7f3ad 100644 --- a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp @@ -78,7 +78,7 @@ void LegoCarRaceActor::VTable0x98() } // STUB: LEGO1 0x10081d30 -MxResult LegoCarRaceActor::WaitForAnimation() +MxResult LegoCarRaceActor::VTable0x9c() { // TODO return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/entity/legojetski.cpp b/LEGO1/lego/legoomni/src/entity/legojetski.cpp index 3656e1c7..38d881d1 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetski.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetski.cpp @@ -77,7 +77,7 @@ void LegoJetski::VTable0x98() } // STUB: LEGO1 0x10014200 -MxResult LegoJetski::WaitForAnimation() +MxResult LegoJetski::VTable0x9c() { // TODO return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp index 654c00b1..e19e6cb3 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp @@ -44,7 +44,7 @@ void LegoJetskiRaceActor::VTable0x98() } // STUB: LEGO1 0x100822e0 -MxResult LegoJetskiRaceActor::WaitForAnimation() +MxResult LegoJetskiRaceActor::VTable0x9c() { // TODO return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index d1600d13..900e7c5c 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -151,7 +151,7 @@ MxResult LegoExtraActor::FUN_1002aae0() m_boundary = oldEdge; } - LegoPathActor::WaitForAnimation(); + LegoPathActor::VTable0x9c(); return SUCCESS; } @@ -280,10 +280,10 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) } // FUNCTION: LEGO1 0x1002b290 -MxResult LegoExtraActor::WaitForAnimation() +MxResult LegoExtraActor::VTable0x9c() { LegoPathBoundary* oldBoundary = m_boundary; - MxResult result = LegoPathActor::WaitForAnimation(); + MxResult result = LegoPathActor::VTable0x9c(); if (m_boundary != oldBoundary) { MxU32 b = FALSE; diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 0d1f8438..f30e2136 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -5,6 +5,7 @@ #include "legocameracontroller.h" #include "legonavcontroller.h" #include "legopathboundary.h" +#include "legopathedgecontainer.h" #include "legosoundmanager.h" #include "legoworld.h" #include "misc.h" @@ -15,6 +16,7 @@ #include DECOMP_SIZE_ASSERT(LegoPathActor, 0x154) +DECOMP_SIZE_ASSERT(LegoPathEdgeContainer, 0x3c) #ifndef M_PI #define M_PI 3.1416 @@ -40,21 +42,21 @@ LegoPathActor::LegoPathActor() m_unk0x7c = 0; m_userNavFlag = FALSE; m_state = 0; - m_unk0x134 = NULL; + m_grec = NULL; m_controller = NULL; m_unk0xe8 = 0; m_unk0x148 = 0; m_unk0x14c = 0; - m_unk0x140 = 0.0099999998f; - m_unk0x144 = 0.80000001f; + m_unk0x140 = 0.0099999999f; + m_unk0x144 = 0.8f; m_unk0x150 = 2.0f; } -// STUB: LEGO1 0x1002d820 +// FUNCTION: LEGO1 0x1002d820 LegoPathActor::~LegoPathActor() { - if (m_unk0x134) { - delete m_unk0x134; + if (m_grec) { + delete m_grec; } } @@ -264,7 +266,7 @@ MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform) LegoPathBoundary* oldBoundary = m_boundary; if (m_unk0xe9 != 0) { - WaitForAnimation(); + VTable0x9c(); if (m_boundary == oldBoundary) { MxLong time = Timer()->GetTime(); @@ -344,7 +346,7 @@ MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform) pos2 = pos1; if (m_unk0xe9 != 0) { - WaitForAnimation(); + VTable0x9c(); } return 0; @@ -544,7 +546,8 @@ void LegoPathActor::ParseAction(char* p_extra) } // STUB: LEGO1 0x1002f1b0 -MxResult LegoPathActor::WaitForAnimation() +// FUNCTION: BETA10 0x100af899 +MxResult LegoPathActor::VTable0x9c() { // TODO return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp index 593c9955..dedfc2f4 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp @@ -87,7 +87,7 @@ MxU32 LegoPathBoundary::Intersect( Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, - LegoEdge*& p_edge + LegoUnknown100db7f4*& p_edge ) { LegoUnknown100db7f4* e = NULL; @@ -207,7 +207,7 @@ MxU32 LegoPathBoundary::Intersect( if (local58 <= 0.0f) { if (!e->GetMask0x03()) { - p_edge = e->GetClockwiseEdge(*this); + p_edge = (LegoUnknown100db7f4*) e->GetClockwiseEdge(*this); } else { p_edge = e; @@ -227,7 +227,7 @@ MxU32 LegoPathBoundary::Intersect( p_point3 = *e->CCWVertex(*this); if (!e->GetMask0x03()) { - p_edge = e->GetCounterclockwiseEdge(*this); + p_edge = (LegoUnknown100db7f4*) e->GetCounterclockwiseEdge(*this); } else { p_edge = e; diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 3d3d6c62..ec7c8530 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -1,5 +1,6 @@ #include "legopathcontroller.h" +#include "legopathedgecontainer.h" #include "legopathstruct.h" #include "misc/legostorage.h" #include "mxmisc.h" @@ -727,3 +728,36 @@ MxResult LegoPathController::ReadVector(LegoStorage* p_storage, Mx4DPointFloat& return SUCCESS; } + +// FUNCTION: LEGO1 0x1004a240 +// FUNCTION: BETA10 0x100b9160 +MxU32 LegoPathController::FUN_1004a240( + LegoPathEdgeContainer& p_grec, + Vector3& p_v1, + Vector3& p_v2, + float p_f1, + LegoUnknown100db7f4*& p_edge, + LegoPathBoundary*& p_boundary +) +{ + if (p_grec.size() == 0) { + p_v1 = p_grec.m_unk0x0c; + p_v2 = p_grec.m_unk0x20; + p_boundary = p_grec.m_boundary; + p_grec.SetBit1(FALSE); + return 1; + } + + p_edge = p_grec.front().m_edge; + p_boundary = p_grec.front().m_boundary; + p_grec.pop_front(); + + Mx3DPointFloat vec; + p_v1 = *p_edge->CCWVertex(*p_boundary); + p_v1.Sub(p_edge->GetOpposingPoint(*p_boundary)); + p_v1.Mul(p_f1); + p_v1.Add(p_edge->GetOpposingPoint(*p_boundary)); + p_edge->FUN_1002ddc0(*p_boundary, vec); + p_v2.EqualsCross(p_boundary->GetUnknown0x14(), &vec); + return 0; +} diff --git a/LEGO1/lego/legoomni/src/race/legoracecar.cpp b/LEGO1/lego/legoomni/src/race/legoracecar.cpp index ccd28cd8..c22310a3 100644 --- a/LEGO1/lego/legoomni/src/race/legoracecar.cpp +++ b/LEGO1/lego/legoomni/src/race/legoracecar.cpp @@ -97,7 +97,7 @@ void LegoRaceCar::VTable0x98() } // STUB: LEGO1 0x10014580 -MxResult LegoRaceCar::WaitForAnimation() +MxResult LegoRaceCar::VTable0x9c() { // TODO return SUCCESS;