From 41281dcbec1073e11243d5e5897fa83e3b0e4f12 Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Tue, 16 Apr 2024 06:54:08 -0400 Subject: [PATCH] Implement LegoPathActor::VTable0x70 (#807) * Implement LegoPathActor::VTable0x70 * match --------- Co-authored-by: Christian Semmler --- .../legoomni/include/legocameracontroller.h | 1 + .../lego/legoomni/include/legonavcontroller.h | 1 + LEGO1/lego/legoomni/include/legopathactor.h | 2 +- .../src/entity/legocameracontroller.cpp | 5 ++ .../lego/legoomni/src/paths/legopathactor.cpp | 52 +++++++++++++++++-- 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocameracontroller.h b/LEGO1/lego/legoomni/include/legocameracontroller.h index ea94d86b..50439347 100644 --- a/LEGO1/lego/legoomni/include/legocameracontroller.h +++ b/LEGO1/lego/legoomni/include/legocameracontroller.h @@ -37,6 +37,7 @@ class LegoCameraController : public LegoPointOfViewController { virtual MxResult Create(); // vtable+0x44 void SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up); + void FUN_10012290(float); void FUN_10012320(MxFloat); void FUN_100123e0(const Matrix4& p_transform, MxU32 p_und); Mx3DPointFloat GetWorldUp(); diff --git a/LEGO1/lego/legoomni/include/legonavcontroller.h b/LEGO1/lego/legoomni/include/legonavcontroller.h index 241cb417..ef2d204e 100644 --- a/LEGO1/lego/legoomni/include/legonavcontroller.h +++ b/LEGO1/lego/legoomni/include/legonavcontroller.h @@ -74,6 +74,7 @@ class LegoNavController : public MxCore { static MxResult UpdateCameraLocation(const char* p_location); inline void SetLinearVel(MxFloat p_linearVel) { m_linearVel = p_linearVel; } inline MxFloat GetLinearVel() { return m_linearVel; } + inline MxFloat GetRotationalVel() { return m_rotationalVel; } inline MxFloat GetMaxLinearVel() { return m_maxLinearVel; } inline void ResetLinearVel(MxFloat p_maxLinearVel) { diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 3b430b45..feb35c35 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -33,7 +33,7 @@ class LegoPathActor : public LegoActor { void ParseAction(char* p_extra) override; // vtable+0x20 virtual MxS32 VTable0x68(Vector3&, Vector3&, Vector3&); // vtable+0x68 virtual void VTable0x6c(); // vtable+0x6c - virtual void VTable0x70(float p_float); // vtable+0x70 + virtual void VTable0x70(float p_time); // vtable+0x70 virtual void VTable0x74(Matrix4& p_transform); // vtable+0x74 // FUNCTION: LEGO1 0x10002d20 diff --git a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp index ed9820c7..1076e787 100644 --- a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp @@ -122,6 +122,11 @@ void LegoCameraController::SetWorldTransform(const Vector3& p_at, const Vector3& m_matrix2 = m_matrix1; } +// STUB: LEGO1 0x10012290 +void LegoCameraController::FUN_10012290(float) +{ +} + // STUB: LEGO1 0x10012320 void LegoCameraController::FUN_10012320(MxFloat) { diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index f8a51088..a28f4e74 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -10,6 +10,14 @@ DECOMP_SIZE_ASSERT(LegoPathActor, 0x154) +#ifndef M_PI +#define M_PI 3.1416 +#endif +#ifdef DTOR +#undef DTOR +#endif +#define DTOR(angle) ((angle) * M_PI / 180.) + // GLOBAL: LEGO1 0x100f3304 // STRING: LEGO1 0x100f32f4 const char* g_strHIT_WALL_SOUND = "HIT_WALL_SOUND"; @@ -355,10 +363,48 @@ void LegoPathActor::VTable0x74(Matrix4& p_transform) } } -// STUB: LEGO1 0x1002e790 -void LegoPathActor::VTable0x70(float) +// FUNCTION: LEGO1 0x1002e790 +void LegoPathActor::VTable0x70(float p_time) { - // TODO + MxMatrix transform; + MxU32 b = FALSE; + + while (m_lastTime < p_time) { + if (m_state != 0 && !VTable0x90(p_time, transform)) { + return; + } + + if (VTable0x8c(p_time, transform) != 0) { + break; + } + + m_unk0xec = transform; + b = TRUE; + + if (m_unk0xe9 != 0) { + break; + } + } + + if (m_userNavFlag && m_unk0x148) { + LegoNavController* nav = NavController(); + float vel = (nav->GetLinearVel() > 0) + ? -(nav->GetRotationalVel() / (nav->GetMaxLinearVel() * m_unk0x150) * nav->GetLinearVel()) + : 0; + + if ((MxS32) vel != m_unk0x14c) { + m_unk0x14c = vel; + LegoWorld* world = CurrentWorld(); + + if (world) { + world->GetCamera()->FUN_10012290(DTOR(m_unk0x14c)); + } + } + } + + if (b) { + VTable0x74(transform); + } } // STUB: LEGO1 0x1002e8b0