From 93c640a45f326a60e408210820c6a3757f6cbca8 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 15 Nov 2024 10:35:53 -0700 Subject: [PATCH] Implement/match PickEntity (#1153) * Implement/match PickEntity * Rename function --- LEGO1/lego/legoomni/include/legoutils.h | 6 +++--- LEGO1/lego/legoomni/src/actors/ambulance.cpp | 2 +- LEGO1/lego/legoomni/src/common/legoutils.cpp | 21 ++++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoutils.h b/LEGO1/lego/legoomni/include/legoutils.h index 3eece302..e0353ba7 100644 --- a/LEGO1/lego/legoomni/include/legoutils.h +++ b/LEGO1/lego/legoomni/include/legoutils.h @@ -40,9 +40,9 @@ class LegoTreeNode; extern MxAtomId* g_isleScript; -LegoEntity* PickEntity(MxLong, MxLong); -LegoROI* PickROI(MxLong, MxLong); -LegoROI* PickParentROI(MxLong p_a, MxLong p_b); +LegoEntity* PickEntity(MxLong p_x, MxLong p_y); +LegoROI* PickROI(MxLong p_x, MxLong p_y); +LegoROI* PickRootROI(MxLong p_x, MxLong p_y); void RotateY(LegoROI* p_roi, MxFloat p_angle); MxBool SpheresIntersect(const BoundingSphere& p_sphere1, const BoundingSphere& p_sphere2); MxBool FUN_1003ded0(MxFloat p_param1[2], MxFloat p_param2[3], MxFloat p_param3[3]); diff --git a/LEGO1/lego/legoomni/src/actors/ambulance.cpp b/LEGO1/lego/legoomni/src/actors/ambulance.cpp index 22d34e74..8d2d8374 100644 --- a/LEGO1/lego/legoomni/src/actors/ambulance.cpp +++ b/LEGO1/lego/legoomni/src/actors/ambulance.cpp @@ -253,7 +253,7 @@ MxLong Ambulance::HandleButtonDown(LegoControlManagerNotificationParam& p_param) return 1; } - roi = PickParentROI(p_param.GetX(), p_param.GetY()); + roi = PickRootROI(p_param.GetX(), p_param.GetY()); if (roi != NULL && !strcmpi(roi->GetName(), "gd")) { m_unk0x170 = 3; diff --git a/LEGO1/lego/legoomni/src/common/legoutils.cpp b/LEGO1/lego/legoomni/src/common/legoutils.cpp index 0fcece8a..b1579d2f 100644 --- a/LEGO1/lego/legoomni/src/common/legoutils.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutils.cpp @@ -36,20 +36,20 @@ // FUNCTION: LEGO1 0x1003dd70 // FUNCTION: BETA10 0x100d3410 -LegoROI* PickROI(MxLong p_a, MxLong p_b) +LegoROI* PickROI(MxLong p_x, MxLong p_y) { LegoVideoManager* videoManager = VideoManager(); Lego3DView* view = videoManager->Get3DManager()->GetLego3DView(); - return (LegoROI*) view->Pick(p_a, p_b); + return (LegoROI*) view->Pick(p_x, p_y); } // FUNCTION: LEGO1 0x1003dd90 // FUNCTION: BETA10 0x100d3449 -LegoROI* PickParentROI(MxLong p_a, MxLong p_b) +LegoROI* PickRootROI(MxLong p_x, MxLong p_y) { LegoVideoManager* videoManager = VideoManager(); Lego3DView* view = videoManager->Get3DManager()->GetLego3DView(); - LegoROI* roi = (LegoROI*) view->Pick(p_a, p_b); + LegoROI* roi = (LegoROI*) view->Pick(p_x, p_y); while (roi != NULL && roi->GetParentROI() != NULL) { roi = (LegoROI*) roi->GetParentROI(); @@ -58,11 +58,16 @@ LegoROI* PickParentROI(MxLong p_a, MxLong p_b) return roi; } -// STUB: LEGO1 0x1003ddc0 -LegoEntity* PickEntity(MxLong, MxLong) +// FUNCTION: LEGO1 0x1003ddc0 +LegoEntity* PickEntity(MxLong p_x, MxLong p_y) { - // TODO - return NULL; + LegoROI* roi = PickRootROI(p_x, p_y); + + if (roi == NULL) { + return NULL; + } + + return roi->GetEntity(); } // FUNCTION: LEGO1 0x1003dde0