From 556cbdaab31808c8c4f9a1f3bcc77242628d372a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 9 May 2024 16:24:45 -0400 Subject: [PATCH] Implement/match LegoAnimationManager::FUN_10062650 (#896) * Implement/match LegoAnimationManager::FUN_10062650 * Shorten code --- .../legoomni/include/legoanimationmanager.h | 2 +- .../src/common/legoanimationmanager.cpp | 28 +++++++++++++++---- LEGO1/realtime/vector.h | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimationmanager.h b/LEGO1/lego/legoomni/include/legoanimationmanager.h index 6a3af707..2851ee5c 100644 --- a/LEGO1/lego/legoomni/include/legoanimationmanager.h +++ b/LEGO1/lego/legoomni/include/legoanimationmanager.h @@ -140,7 +140,7 @@ class LegoAnimationManager : public MxCore { MxBool FUN_100623a0(AnimInfo& p_info); MxBool ModelExists(AnimInfo& p_info, const char* p_name); void FUN_10062580(AnimInfo& p_info); - MxBool FUN_10062650(Vector3&, float, LegoROI*); + MxBool FUN_10062650(Vector3& p_position, float p_und, LegoROI* p_roi); MxBool FUN_10062710(AnimInfo& p_info); void FUN_10063aa0(); void FUN_10063d10(); diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 624fd437..c633364f 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -1309,6 +1309,7 @@ MxU16 LegoAnimationManager::FUN_10062110( if (direction.Dot(&direction, &p_direction) > 0.707) { Mx3DPointFloat position(p_roi->GetWorldPosition()); + // TODO: Fix call ((Vector3&) position).Sub(&p_position); float len = position.LenSquared(); float min, max; @@ -1389,7 +1390,7 @@ MxBool LegoAnimationManager::FUN_100623a0(AnimInfo& p_info) LegoEntityList* entityList = world->GetEntityList(); if (entityList != NULL) { - Mx3DPointFloat vec(p_info.m_unk0x10[0], p_info.m_unk0x10[1], p_info.m_unk0x10[2]); + Mx3DPointFloat position(p_info.m_unk0x10[0], p_info.m_unk0x10[1], p_info.m_unk0x10[2]); float und = p_info.m_unk0x10[3]; LegoEntityListCursor cursor(entityList); @@ -1400,7 +1401,7 @@ MxBool LegoAnimationManager::FUN_100623a0(AnimInfo& p_info) if (entity != actor && entity->IsA("LegoPathActor")) { LegoROI* roi = entity->GetROI(); - if (roi->GetVisibility() && FUN_10062650(vec, und, roi)) { + if (roi->GetVisibility() && FUN_10062650(position, und, roi)) { if (!ModelExists(p_info, roi->GetName())) { return TRUE; } @@ -1467,11 +1468,28 @@ void LegoAnimationManager::FUN_10062580(AnimInfo& p_info) } } -// STUB: LEGO1 0x10062650 +// FUNCTION: LEGO1 0x10062650 // FUNCTION: BETA10 0x100436e2 -MxBool LegoAnimationManager::FUN_10062650(Vector3&, float, LegoROI*) +MxBool LegoAnimationManager::FUN_10062650(Vector3& p_position, float p_und, LegoROI* p_roi) { - return TRUE; + if (p_roi != NULL) { + Mx3DPointFloat position(p_position); + + // TODO: Fix call + ((Vector3&) position).Sub(p_roi->GetWorldPosition()); + + float len = position.LenSquared(); + if (len <= 0.0f) { + return TRUE; + } + + len = sqrt(len); + if (p_roi->GetWorldBoundingSphere().Radius() + p_und >= len) { + return TRUE; + } + } + + return FALSE; } // STUB: LEGO1 0x10062710 diff --git a/LEGO1/realtime/vector.h b/LEGO1/realtime/vector.h index 06d3acc5..7d7a06e4 100644 --- a/LEGO1/realtime/vector.h +++ b/LEGO1/realtime/vector.h @@ -123,7 +123,7 @@ class Vector2 { virtual void Add(Vector2* p_other) { AddImpl(p_other->m_data); } // vtable+0x48 // FUNCTION: LEGO1 0x100021f0 - virtual void Sub(float* p_other) { SubImpl(p_other); } // vtable+0x58 + virtual void Sub(const float* p_other) { SubImpl((float*) p_other); } // vtable+0x58 // FUNCTION: LEGO1 0x10002200 virtual void Sub(const Vector2* p_other) { SubImpl((float*) p_other->m_data); } // vtable+0x54