From bc91fd2189017ebab6643fbab1bb20a9107394cd Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 20 May 2024 14:27:00 -0400 Subject: [PATCH] Implement/match LegoPathActor::SwitchBoundary (#943) * Implement/match LegoPathActor::SwitchBoundary * Rename var --- .../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 | 8 +- .../lego/legoomni/include/legopathboundary.h | 6 ++ LEGO1/lego/legoomni/include/legoracecar.h | 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 | 8 +- .../lego/legoomni/src/paths/legopathactor.cpp | 10 +- .../legoomni/src/paths/legopathboundary.cpp | 97 +++++++++++++++++++ LEGO1/lego/legoomni/src/race/legoracecar.cpp | 2 +- LEGO1/lego/sources/geom/legounkown100db7f4.h | 6 ++ 15 files changed, 131 insertions(+), 22 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocarraceactor.h b/LEGO1/lego/legoomni/include/legocarraceactor.h index 060ac703..41994ea5 100644 --- a/LEGO1/lego/legoomni/include/legocarraceactor.h +++ b/LEGO1/lego/legoomni/include/legocarraceactor.h @@ -38,7 +38,7 @@ class LegoCarRaceActor : public virtual LegoRaceActor { void VTable0x70(float p_float) override; // vtable+0x70 MxU32 VTable0x90(float, Matrix4&) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 - void VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) + void SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) override; // vtable+0x98 MxResult VTable0x9c() override; // vtable+0x9c diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index 2e8bae7d..7d75f338 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -47,7 +47,7 @@ class LegoExtraActor : public virtual LegoAnimActor { MxU32 VTable0x90(float p_float, Matrix4& p_matrix) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 MxResult VTable0x9c() override; // vtable+0x9c - void VTable0xa4(MxU8& p_und1, MxS32& p_und2) override; // vtable+0xa4 + void VTable0xa4(MxBool& p_und1, MxS32& p_und2) override; // vtable+0xa4 void VTable0xc4() override; // vtable+0xc4 virtual MxResult FUN_1002aae0(); diff --git a/LEGO1/lego/legoomni/include/legojetski.h b/LEGO1/lego/legoomni/include/legojetski.h index a90f817b..30000b5d 100644 --- a/LEGO1/lego/legoomni/include/legojetski.h +++ b/LEGO1/lego/legoomni/include/legojetski.h @@ -43,7 +43,7 @@ class LegoJetski : public LegoJetskiRaceActor, public LegoRaceMap { ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 - void VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) + void SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) override; // vtable+0x98 MxResult VTable0x9c() override; // vtable+0x9c diff --git a/LEGO1/lego/legoomni/include/legojetskiraceactor.h b/LEGO1/lego/legoomni/include/legojetskiraceactor.h index d7b58c63..27ba401a 100644 --- a/LEGO1/lego/legoomni/include/legojetskiraceactor.h +++ b/LEGO1/lego/legoomni/include/legojetskiraceactor.h @@ -36,7 +36,7 @@ class LegoJetskiRaceActor : public virtual LegoCarRaceActor { Vector3& p_v3 ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 - void VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) + void SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) override; // vtable+0x98 MxResult VTable0x9c() override; // vtable+0x9c void VTable0x1c() override; // vtable+0x1c diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index fd62fa76..c43e5877 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -54,7 +54,7 @@ class LegoPathActor : public LegoActor { virtual void SetUserNavFlag(MxBool p_userNavFlag) { m_userNavFlag = p_userNavFlag; } // vtable+0x78 // FUNCTION: LEGO1 0x10002d30 - virtual MxU8 GetUserNavFlag() { return m_userNavFlag; } // vtable+0x7c + virtual MxBool GetUserNavFlag() { return m_userNavFlag; } // vtable+0x7c virtual MxResult VTable0x80( Vector3& p_point1, @@ -86,7 +86,7 @@ class LegoPathActor : public LegoActor { // FUNCTION: LEGO1 0x10002d50 virtual MxResult VTable0x94(LegoPathActor*, MxBool) { return 0; } // vtable+0x94 - virtual void VTable0x98( + virtual void SwitchBoundary( LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4 @@ -96,8 +96,8 @@ class LegoPathActor : public LegoActor { // FUNCTION: LEGO1 0x10002d60 virtual MxS32 VTable0xa0() { return 0; } // vtable+0xa0 - virtual void VTable0xa4(MxU8&, MxS32&); // vtable+0xa4 - virtual void VTable0xa8(); // vtable+0xa8 + virtual void VTable0xa4(MxBool&, MxS32&); // vtable+0xa4 + virtual void VTable0xa8(); // vtable+0xa8 // FUNCTION: LEGO1 0x10002d70 virtual void VTable0xac(MxFloat p_unk0x13c) { m_unk0x13c = p_unk0x13c; } // vtable+0xac diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index 448eb37c..f46633d7 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -34,6 +34,12 @@ 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); + void SwitchBoundary( + LegoPathActor* p_actor, + LegoPathBoundary*& p_boundary, + LegoUnknown100db7f4*& p_edge, + float& p_unk0xe4 + ); MxU32 Intersect( float p_scale, Vector3& p_point1, diff --git a/LEGO1/lego/legoomni/include/legoracecar.h b/LEGO1/lego/legoomni/include/legoracecar.h index 6427fbf9..51c248ca 100644 --- a/LEGO1/lego/legoomni/include/legoracecar.h +++ b/LEGO1/lego/legoomni/include/legoracecar.h @@ -42,7 +42,7 @@ class LegoRaceCar : public LegoCarRaceActor, public LegoRaceMap { ) override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 - void VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) + void SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) override; // vtable+0x98 MxResult VTable0x9c() override; // vtable+0x9c diff --git a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp index e2f807fc..33c04798 100644 --- a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp @@ -72,7 +72,7 @@ void LegoCarRaceActor::VTable0x70(float p_float) } // STUB: LEGO1 0x10081d20 -void LegoCarRaceActor::VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) +void LegoCarRaceActor::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) { // TODO } diff --git a/LEGO1/lego/legoomni/src/entity/legojetski.cpp b/LEGO1/lego/legoomni/src/entity/legojetski.cpp index 8d64dcd9..a0e72803 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetski.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetski.cpp @@ -71,7 +71,7 @@ MxResult LegoJetski::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) } // STUB: LEGO1 0x100141c0 -void LegoJetski::VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) +void LegoJetski::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) { // TODO } diff --git a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp index bdb8539f..9faead44 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp @@ -38,7 +38,7 @@ void LegoJetskiRaceActor::VTable0x70(float p_float) } // STUB: LEGO1 0x100822d0 -void LegoJetskiRaceActor::VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) +void LegoJetskiRaceActor::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) { // TODO } diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index b3118e38..9b3a6304 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -109,19 +109,19 @@ MxU32 LegoExtraActor::VTable0x90(float p_time, Matrix4& p_transform) } // FUNCTION: LEGO1 0x1002aa90 -void LegoExtraActor::VTable0xa4(MxU8& p_und1, MxS32& p_und2) +void LegoExtraActor::VTable0xa4(MxBool& p_und1, MxS32& p_und2) { switch (m_unk0x0c) { case 1: - p_und1 = 1; + p_und1 = TRUE; p_und2 = 1; break; case 2: - p_und1 = 0; + p_und1 = FALSE; p_und2 = 1; break; default: - p_und1 = 1; + p_und1 = TRUE; p_und2 = rand() % p_und2 + 1; break; } diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 9c608ddf..ee0da2fa 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -417,11 +417,11 @@ void LegoPathActor::VTable0x70(float p_time) } } -// STUB: LEGO1 0x1002e8b0 +// FUNCTION: LEGO1 0x1002e8b0 // FUNCTION: BETA10 0x100af2f7 -void LegoPathActor::VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) +void LegoPathActor::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) { - // TODO + m_boundary->SwitchBoundary(this, p_boundary, p_edge, p_unk0xe4); } // FUNCTION: LEGO1 0x1002e8d0 @@ -576,7 +576,7 @@ MxResult LegoPathActor::VTable0x9c() } if (local1c != 0) { - VTable0x98(m_boundary, m_destEdge, m_unk0xe4); + SwitchBoundary(m_boundary, m_destEdge, m_unk0xe4); } if (local20 != 0) { @@ -629,7 +629,7 @@ MxResult LegoPathActor::VTable0x9c() } // STUB: LEGO1 0x1002f650 -void LegoPathActor::VTable0xa4(MxU8&, MxS32&) +void LegoPathActor::VTable0xa4(MxBool&, MxS32&) { // TODO } diff --git a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp index dedfc2f4..729b1575 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp @@ -80,6 +80,103 @@ void LegoPathBoundary::FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPa } } +// FUNCTION: LEGO1 0x10057720 +// FUNCTION: BETA10 0x100b17ef +void LegoPathBoundary::SwitchBoundary( + LegoPathActor* p_actor, + LegoPathBoundary*& p_boundary, + LegoUnknown100db7f4*& p_edge, + float& p_unk0xe4 +) +{ + LegoUnknown100db7f4* e = p_edge; + + if (p_edge->Unknown2(*p_boundary)) { + LegoPathBoundary* newBoundary = (LegoPathBoundary*) p_edge->OtherFace(p_boundary); + + if (newBoundary == NULL) { + newBoundary = p_boundary; + } + + MxS32 local10 = 0; + MxU8 userNavFlag; + + if (e->Unknown(*newBoundary, 1)) { + userNavFlag = p_actor->GetUserNavFlag(); + } + else { + userNavFlag = TRUE; + } + + do { + p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary); + LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(newBoundary); + + if (p_edge->GetMask0x03() && (userNavFlag || p_edge->Unknown(*local20, 1))) { + local10++; + } + } while (p_edge != e); + + MxBool localc = TRUE; + MxS32 local8 = local10 - 1; + + if (local10 <= 1) { + local8 = 0; + } + else if (local10 == 2) { + local8 = 1; + } + else { + p_actor->VTable0xa4(localc, local8); + } + + while (local8 > 0) { + if (localc) { + p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary); + } + else { + p_edge = (LegoUnknown100db7f4*) p_edge->GetClockwiseEdge(*newBoundary); + } + + LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(newBoundary); + + if (p_edge->GetMask0x03() && (userNavFlag || p_edge->Unknown(*local20, 1))) { + local8--; + } + } + + if (p_edge == e) { + p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary); + p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary); + } + + if (p_boundary != newBoundary) { + p_boundary->RemoveActor(p_actor); + p_boundary = newBoundary; + p_boundary->AddActor(p_actor); + } + else { + p_unk0xe4 = 1.0 - p_unk0xe4; + } + } + else { + do { + p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*p_boundary); + + if (p_edge->GetMask0x03()) { + break; + } + } while (p_edge != e); + + if (p_edge == e) { + p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*p_boundary); + p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*p_boundary); + } + + p_unk0xe4 = 1.0 - p_unk0xe4; + } +} + // FUNCTION: LEGO1 0x10057950 // FUNCTION: BETA10 0x100b1adc MxU32 LegoPathBoundary::Intersect( diff --git a/LEGO1/lego/legoomni/src/race/legoracecar.cpp b/LEGO1/lego/legoomni/src/race/legoracecar.cpp index e520317a..949ae142 100644 --- a/LEGO1/lego/legoomni/src/race/legoracecar.cpp +++ b/LEGO1/lego/legoomni/src/race/legoracecar.cpp @@ -91,7 +91,7 @@ MxResult LegoRaceCar::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) } // STUB: LEGO1 0x10014550 -void LegoRaceCar::VTable0x98(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) +void LegoRaceCar::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4) { // TODO } diff --git a/LEGO1/lego/sources/geom/legounkown100db7f4.h b/LEGO1/lego/sources/geom/legounkown100db7f4.h index 7c73a9e3..4e6ffead 100644 --- a/LEGO1/lego/sources/geom/legounkown100db7f4.h +++ b/LEGO1/lego/sources/geom/legounkown100db7f4.h @@ -41,6 +41,12 @@ struct LegoUnknown100db7f4 : public LegoEdge { (p_face.IsEqual(*m_faceA) && (m_flags & c_bit2) && (p_face.GetMask0x03() & p_mask) == p_mask); } + // FUNCTION: BETA10 0x100b53b0 + LegoU32 Unknown2(LegoWEGEdge& p_face) + { + return (p_face.IsEqual(*m_faceA) && (m_flags & c_bit1)) || (p_face.IsEqual(*m_faceB) && (m_flags & c_bit2)); + } + // FUNCTION: BETA10 0x1001cbe0 LegoWEEdge* OtherFace(LegoWEEdge* p_other) {