From e05cb05983088d70e3baf84cc62757c330da83d6 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Sun, 18 Jan 2026 21:31:56 +0100 Subject: [PATCH] Clear unknowns in `LegoPathController` (#1724) --- .../legoomni/include/legopathcontroller.h | 26 +-- LEGO1/lego/legoomni/src/actors/act2actor.cpp | 2 +- LEGO1/lego/legoomni/src/actors/act3actors.cpp | 10 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 6 +- .../lego/legoomni/src/paths/legopathactor.cpp | 2 +- .../legoomni/src/paths/legopathcontroller.cpp | 181 +++++++++--------- LEGO1/lego/legoomni/src/worlds/act3.cpp | 4 +- 7 files changed, 116 insertions(+), 115 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index 89b11074..32c483a8 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -104,13 +104,13 @@ class LegoPathController : public MxCore { ); MxResult PlaceActor(LegoPathActor* p_actor); MxResult RemoveActor(LegoPathActor* p_actor); - void FUN_100468f0(LegoAnimPresenter* p_presenter); + void AddPresenterIfInRange(LegoAnimPresenter* p_presenter); void RemovePresenterFromBoundaries(LegoAnimPresenter* p_presenter); - MxResult FUN_10046b30(LegoPathBoundary*& p_boundaries, MxS32& p_numL); + MxResult GetBoundaries(LegoPathBoundary*& p_boundaries, MxS32& p_numL); LegoPathBoundary* GetPathBoundary(const char* p_name); void Enable(MxBool p_enable); - void FUN_10046bb0(LegoWorld* p_world); - MxResult FUN_10048310( + void SetWorld(LegoWorld* p_world); + MxResult FindPath( LegoPathEdgeContainer* p_grec, const Vector3& p_oldPosition, const Vector3& p_oldDirection, @@ -119,17 +119,17 @@ class LegoPathController : public MxCore { const Vector3& p_newDirection, LegoPathBoundary* p_newBoundary, LegoU8 p_mask, - MxFloat* p_param9 + MxFloat* p_distance ); - MxS32 FUN_1004a240( + MxS32 GetNextPathEdge( LegoPathEdgeContainer& p_grec, - Vector3& p_v1, - Vector3& p_v2, + Vector3& p_position, + Vector3& p_direction, float p_f1, LegoOrientedEdge*& p_edge, LegoPathBoundary*& p_boundary ); - MxResult FUN_1004a380( + MxResult FindIntersectionBoundary( Vector3& p_param1, Vector3& p_param2, Mx3DPointFloat* p_param3, @@ -154,7 +154,7 @@ class LegoPathController : public MxCore { static LegoPathBoundary* GetControlBoundaryB(MxS32 p_index) { return g_ctrlBoundariesB[p_index].m_boundary; } private: - void FUN_10046970(); + void AnimateActors(); MxResult Read(LegoStorage* p_storage); MxResult ReadStructs(LegoStorage* p_storage); MxResult ReadEdges(LegoStorage* p_storage); @@ -174,7 +174,7 @@ class LegoPathController : public MxCore { } // FUNCTION: BETA10 0x100c17a0 - static MxU32 FUN_100c17a0(MxFloat p_v1, MxFloat p_v2, MxFloat p_a, MxFloat p_b) + static MxU32 BothSameComparison(MxFloat p_v1, MxFloat p_v2, MxFloat p_a, MxFloat p_b) { assert(IsBetween(p_v1, p_a, p_b)); assert(IsBetween(p_v2, p_a, p_b)); @@ -202,8 +202,8 @@ class LegoPathController : public MxCore { static CtrlBoundary* g_ctrlBoundariesA; static CtrlEdge* g_ctrlEdgesA; - static const char* g_unk0x100f42f0[]; - static const char* g_unk0x100f4330[]; + static const char* g_ctrlBoundariesNamesA[]; + static const char* g_ctrlBoundariesNamesB[]; static CtrlBoundary* g_ctrlBoundariesB; static CtrlEdge* g_ctrlEdgesB; }; diff --git a/LEGO1/lego/legoomni/src/actors/act2actor.cpp b/LEGO1/lego/legoomni/src/actors/act2actor.cpp index 187931b5..18b099ee 100644 --- a/LEGO1/lego/legoomni/src/actors/act2actor.cpp +++ b/LEGO1/lego/legoomni/src/actors/act2actor.cpp @@ -410,7 +410,7 @@ void Act2Actor::FindPath(MxU32 p_location) newDirection = g_brickstrLocations[p_location].m_direction; LegoPathBoundary* newBoundary = m_pathController->GetPathBoundary(g_brickstrLocations[p_location].m_boundary); - MxResult sts = m_pathController->FUN_10048310( + MxResult sts = m_pathController->FindPath( m_grec, m_roi->GetWorldPosition(), m_roi->GetWorldDirection(), diff --git a/LEGO1/lego/legoomni/src/actors/act3actors.cpp b/LEGO1/lego/legoomni/src/actors/act3actors.cpp index af36e119..8a0c1383 100644 --- a/LEGO1/lego/legoomni/src/actors/act3actors.cpp +++ b/LEGO1/lego/legoomni/src/actors/act3actors.cpp @@ -345,7 +345,7 @@ MxResult Act3Cop::FUN_10040360() assert(grec); MxFloat local34; - if (m_pathController->FUN_10048310( + if (m_pathController->FindPath( grec, local2c, local20, @@ -383,7 +383,7 @@ MxResult Act3Cop::FUN_10040360() MxFloat locald8; LegoPathEdgeContainer *local138, *local134, *local140, *local13c; // unused - if (m_pathController->FUN_10048310( + if (m_pathController->FindPath( r2, local2c, local20, @@ -423,7 +423,7 @@ MxResult Act3Cop::FUN_10040360() MxFloat local100; LegoPathEdgeContainer *local150, *local14c; // unused - if (m_pathController->FUN_10048310( + if (m_pathController->FindPath( grec, local2c, local20, @@ -823,7 +823,7 @@ MxResult Act3Brickster::FUN_100417c0() MxFloat locald8; LegoPathEdgeContainer *local16c, *local168, *local174, *local170; // unused - if (m_pathController->FUN_10048310( + if (m_pathController->FindPath( r2, local28, local20, @@ -907,7 +907,7 @@ MxResult Act3Brickster::FUN_100417c0() MxFloat local13c; LegoPathEdgeContainer *local1c0, *local1bc; // unused - if (m_pathController->FUN_10048310( + if (m_pathController->FindPath( grec, local28, local20, diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 47b54d8b..8cdff940 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -358,7 +358,7 @@ void LegoWorld::AddPresenterIfInRange(LegoAnimPresenter* p_presenter) LegoPathController* controller; while (cursor.Next(controller)) { - controller->FUN_100468f0(p_presenter); + controller->AddPresenterIfInRange(p_presenter); } } @@ -377,7 +377,7 @@ void LegoWorld::RemovePresenterFromBoundaries(LegoAnimPresenter* p_presenter) // FUNCTION: LEGO1 0x1001ff80 void LegoWorld::AddPath(LegoPathController* p_controller) { - p_controller->FUN_10046bb0(this); + p_controller->SetWorld(this); m_pathControllerList.Append(p_controller); } @@ -411,7 +411,7 @@ MxResult LegoWorld::GetCurrPathInfo(LegoPathBoundary** p_boundaries, MxS32& p_nu return FAILURE; } - return controller->FUN_10046b30(*p_boundaries, p_numL); + return controller->GetBoundaries(*p_boundaries, p_numL); } // FUNCTION: LEGO1 0x10020220 diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 85e29f7e..40e312dd 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -635,7 +635,7 @@ MxResult LegoPathActor::VTable0x9c() local20 = 0; Mx3DPointFloat vec; - switch (m_pathController->FUN_1004a240(*m_grec, local34, local48, m_unk0xe4, m_destEdge, m_boundary)) { + switch (m_pathController->GetNextPathEdge(*m_grec, local34, local48, m_unk0xe4, m_destEdge, m_boundary)) { case 0: case 1: break; diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 27c9fc2a..38367bb2 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -12,10 +12,10 @@ DECOMP_SIZE_ASSERT(LegoPathController::CtrlBoundary, 0x08) DECOMP_SIZE_ASSERT(LegoPathController::CtrlEdge, 0x08) // GLOBAL: LEGO1 0x100d7cc8 -MxU32 g_unk0x100d7cc8[] = {2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0}; +MxU32 g_ctrlEdgesNamesA[] = {2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0}; // GLOBAL: LEGO1 0x100d7d08 -MxU32 g_unk0x100d7d08[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +MxU32 g_ctrlEdgesNamesB[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // GLOBAL: LEGO1 0x100f42e8 // GLOBAL: BETA10 0x101f25f0 @@ -26,7 +26,7 @@ LegoPathController::CtrlBoundary* LegoPathController::g_ctrlBoundariesA = NULL; LegoPathController::CtrlEdge* LegoPathController::g_ctrlEdgesA = NULL; // GLOBAL: LEGO1 0x100f42f0 -const char* LegoPathController::g_unk0x100f42f0[] = { +const char* LegoPathController::g_ctrlBoundariesNamesA[] = { "edg03_21", "edg03_23", "edg03_30", @@ -46,7 +46,7 @@ const char* LegoPathController::g_unk0x100f42f0[] = { }; // GLOBAL: LEGO1 0x100f4330 -const char* LegoPathController::g_unk0x100f4330[] = { +const char* LegoPathController::g_ctrlBoundariesNamesB[] = { "edg03_06", "edg03_21", "edg03_30", @@ -101,23 +101,23 @@ MxResult LegoPathController::Create(MxU8* p_data, const Vector3& p_location, con LegoPathBoundary& boundary = m_boundaries[i]; MxS32 j; - for (j = 0; j < sizeOfArray(g_unk0x100f42f0); j++) { - if (!strcmpi(g_unk0x100f42f0[j], boundary.GetName())) { + for (j = 0; j < sizeOfArray(g_ctrlBoundariesNamesA); j++) { + if (!strcmpi(g_ctrlBoundariesNamesA[j], boundary.GetName())) { g_ctrlBoundariesA[j].m_controller = this; g_ctrlBoundariesA[j].m_boundary = &boundary; - MxU32 edge = g_unk0x100d7cc8[j]; + MxU32 edge = g_ctrlEdgesNamesA[j]; g_ctrlEdgesA[j].m_controller = this; g_ctrlEdgesA[j].m_edge = boundary.GetEdges()[edge]; } } - for (j = 0; j < sizeOfArray(g_unk0x100f4330); j++) { - if (!strcmpi(g_unk0x100f4330[j], boundary.GetName())) { + for (j = 0; j < sizeOfArray(g_ctrlBoundariesNamesB); j++) { + if (!strcmpi(g_ctrlBoundariesNamesB[j], boundary.GetName())) { g_ctrlBoundariesB[j].m_controller = this; g_ctrlBoundariesB[j].m_boundary = &boundary; g_ctrlEdgesB[j].m_controller = this; - g_ctrlEdgesB[j].m_edge = boundary.GetEdges()[g_unk0x100d7d08[j]]; + g_ctrlEdgesB[j].m_edge = boundary.GetEdges()[g_ctrlEdgesNamesB[j]]; } } } @@ -163,7 +163,7 @@ void LegoPathController::Destroy() m_numE = 0; MxS32 j; - for (j = 0; j < sizeOfArray(g_unk0x100f42f0); j++) { + for (j = 0; j < sizeOfArray(g_ctrlBoundariesNamesA); j++) { if (g_ctrlBoundariesA[j].m_controller == this) { g_ctrlBoundariesA[j].m_controller = NULL; g_ctrlBoundariesA[j].m_boundary = NULL; @@ -175,7 +175,7 @@ void LegoPathController::Destroy() } } - for (j = 0; j < sizeOfArray(g_unk0x100f4330); j++) { + for (j = 0; j < sizeOfArray(g_ctrlBoundariesNamesB); j++) { if (g_ctrlBoundariesB[j].m_controller == this) { g_ctrlBoundariesB[j].m_controller = NULL; g_ctrlBoundariesB[j].m_boundary = NULL; @@ -192,7 +192,7 @@ void LegoPathController::Destroy() // FUNCTION: BETA10 0x100b6d60 MxResult LegoPathController::Tickle() { - FUN_10046970(); + AnimateActors(); return SUCCESS; } @@ -343,7 +343,7 @@ MxResult LegoPathController::RemoveActor(LegoPathActor* p_actor) // FUNCTION: LEGO1 0x100468f0 // FUNCTION: BETA10 0x100b72f7 -void LegoPathController::FUN_100468f0(LegoAnimPresenter* p_presenter) +void LegoPathController::AddPresenterIfInRange(LegoAnimPresenter* p_presenter) { for (MxS32 i = 0; i < m_numL; i++) { if (!(m_boundaries[i].m_flags & LegoWEGEdge::c_bit3)) { @@ -363,7 +363,7 @@ void LegoPathController::RemovePresenterFromBoundaries(LegoAnimPresenter* p_pres // FUNCTION: LEGO1 0x10046970 // FUNCTION: BETA10 0x100b73d8 -void LegoPathController::FUN_10046970() +void LegoPathController::AnimateActors() { float time = Timer()->GetTime(); @@ -381,7 +381,7 @@ void LegoPathController::FUN_10046970() } // FUNCTION: LEGO1 0x10046b30 -MxResult LegoPathController::FUN_10046b30(LegoPathBoundary*& p_boundaries, MxS32& p_numL) +MxResult LegoPathController::GetBoundaries(LegoPathBoundary*& p_boundaries, MxS32& p_numL) { p_boundaries = m_boundaries; p_numL = m_numL; @@ -403,7 +403,7 @@ LegoPathBoundary* LegoPathController::GetPathBoundary(const char* p_name) // FUNCTION: LEGO1 0x10046bb0 // FUNCTION: BETA10 0x100b75bc -void LegoPathController::FUN_10046bb0(LegoWorld* p_world) +void LegoPathController::SetWorld(LegoWorld* p_world) { for (MxS32 i = 0; i < m_numT; i++) { m_structs[i].SetWorld(p_world); @@ -430,10 +430,10 @@ MxResult LegoPathController::Init() return FAILURE; } - g_ctrlBoundariesA = new CtrlBoundary[sizeOfArray(g_unk0x100f42f0)]; - g_ctrlEdgesA = new CtrlEdge[sizeOfArray(g_unk0x100f42f0)]; - g_ctrlBoundariesB = new CtrlBoundary[sizeOfArray(g_unk0x100f4330)]; - g_ctrlEdgesB = new CtrlEdge[sizeOfArray(g_unk0x100f4330)]; + g_ctrlBoundariesA = new CtrlBoundary[sizeOfArray(g_ctrlBoundariesNamesA)]; + g_ctrlEdgesA = new CtrlEdge[sizeOfArray(g_ctrlBoundariesNamesA)]; + g_ctrlBoundariesB = new CtrlBoundary[sizeOfArray(g_ctrlBoundariesNamesB)]; + g_ctrlEdgesB = new CtrlEdge[sizeOfArray(g_ctrlBoundariesNamesB)]; return SUCCESS; } @@ -758,7 +758,7 @@ MxResult LegoPathController::ReadVector(LegoStorage* p_storage, Mx4DPointFloat& // FUNCTION: LEGO1 0x10048310 // FUNCTION: BETA10 0x100b8911 -MxResult LegoPathController::FUN_10048310( +MxResult LegoPathController::FindPath( LegoPathEdgeContainer* p_grec, const Vector3& p_oldPosition, const Vector3& p_oldDirection, @@ -767,7 +767,7 @@ MxResult LegoPathController::FUN_10048310( const Vector3& p_newDirection, LegoPathBoundary* p_newBoundary, LegoU8 p_mask, - MxFloat* p_param9 + MxFloat* p_distance ) { p_grec->m_position = p_newPosition; @@ -788,7 +788,7 @@ MxResult LegoPathController::FUN_10048310( LegoPathCtrlEdgeSet pathCtrlEdgeSet(m_pfsE); - MxFloat local14 = 999999.0f; + MxFloat minDistance = 999999.0f; p_grec->SetPath(FALSE); @@ -802,8 +802,8 @@ MxResult LegoPathController::FUN_10048310( if (p_newBoundary == otherFace) { float dist; if ((dist = edge->DistanceToMidpoint(p_oldPosition) + edge->DistanceToMidpoint(p_newPosition)) < - local14) { - local14 = dist; + minDistance) { + minDistance = dist; p_grec->erase(p_grec->begin(), p_grec->end()); p_grec->SetPath(TRUE); p_grec->push_back(LegoBoundaryEdge(edge, p_oldBoundary)); @@ -823,8 +823,8 @@ MxResult LegoPathController::FUN_10048310( if (!p_grec->HasPath()) { while (pathCtrlEdgeSet.size() > 0) { - LegoBEWithMidpoint edgeWithFloat; - MxFloat local70 = 999999.0f; + LegoBEWithMidpoint edgeWithMidpoint; + MxFloat minDist = 999999.0f; boundarySetItA = boundarySetItB = boundarySet.begin(); @@ -854,13 +854,13 @@ MxResult LegoPathController::FUN_10048310( float dist; if ((dist = pfs->m_edge->DistanceToMidpoint(p_newPosition) + pfs->m_distanceToMidpoint) < - local70) { - edgeWithFloat.m_edge = NULL; - local70 = dist; + minDist) { + edgeWithMidpoint.m_edge = NULL; + minDist = dist; // TODO: Match - if (dist < local14) { - local14 = dist; + if (dist < minDistance) { + minDistance = dist; p_grec->erase(p_grec->begin(), p_grec->end()); p_grec->SetPath(TRUE); @@ -881,9 +881,9 @@ MxResult LegoPathController::FUN_10048310( float dist; if ((dist = edge->DistanceBetweenMidpoints(*e) + - (*boundarySetItA)->m_distanceToMidpoint) < local70) { - local70 = dist; - edgeWithFloat = LegoBEWithMidpoint(edge, bOther, *boundarySetItA, dist); + (*boundarySetItA)->m_distanceToMidpoint) < minDist) { + minDist = dist; + edgeWithMidpoint = LegoBEWithMidpoint(edge, bOther, *boundarySetItA, dist); } } } @@ -904,9 +904,9 @@ MxResult LegoPathController::FUN_10048310( } } - if (edgeWithFloat.m_edge != NULL) { - pathCtrlEdgeSet.erase(edgeWithFloat.m_edge); - boundaryList.push_back(edgeWithFloat); + if (edgeWithMidpoint.m_edge != NULL) { + pathCtrlEdgeSet.erase(edgeWithMidpoint.m_edge); + boundaryList.push_back(edgeWithMidpoint); boundarySet.insert(&boundaryList.back()); } else { @@ -936,8 +936,8 @@ MxResult LegoPathController::FUN_10048310( } } - if (p_param9 != NULL) { - *p_param9 = local14; + if (p_distance != NULL) { + *p_distance = minDistance; } return SUCCESS; @@ -948,18 +948,18 @@ MxResult LegoPathController::FUN_10048310( // FUNCTION: LEGO1 0x1004a240 // FUNCTION: BETA10 0x100b9160 -MxS32 LegoPathController::FUN_1004a240( +MxS32 LegoPathController::GetNextPathEdge( LegoPathEdgeContainer& p_grec, - Vector3& p_v1, - Vector3& p_v2, + Vector3& p_position, + Vector3& p_direction, float p_f1, LegoOrientedEdge*& p_edge, LegoPathBoundary*& p_boundary ) { if (p_grec.size() == 0) { - p_v1 = p_grec.m_position; - p_v2 = p_grec.m_direction; + p_position = p_grec.m_position; + p_direction = p_grec.m_direction; p_boundary = p_grec.m_boundary; p_grec.SetPath(FALSE); return 1; @@ -970,28 +970,28 @@ MxS32 LegoPathController::FUN_1004a240( p_grec.pop_front(); Mx3DPointFloat vec; - p_v1 = *p_edge->CCWVertex(*p_boundary); - p_v1 -= *p_edge->CWVertex(*p_boundary); - p_v1 *= p_f1; - p_v1 += *p_edge->CWVertex(*p_boundary); + p_position = *p_edge->CCWVertex(*p_boundary); + p_position -= *p_edge->CWVertex(*p_boundary); + p_position *= p_f1; + p_position += *p_edge->CWVertex(*p_boundary); p_edge->GetFaceNormal(*p_boundary, vec); - p_v2.EqualsCross(*p_boundary->GetUp(), vec); + p_direction.EqualsCross(*p_boundary->GetUp(), vec); return 0; } // FUNCTION: LEGO1 0x1004a380 // FUNCTION: BETA10 0x100b957f -MxResult LegoPathController::FUN_1004a380( - Vector3& p_param1, - Vector3& p_param2, - Mx3DPointFloat* p_param3, +MxResult LegoPathController::FindIntersectionBoundary( + Vector3& p_location, + Vector3& p_direction, + Mx3DPointFloat* p_coefficients, LegoPathBoundary*& p_boundary, - MxFloat& p_param5 + MxFloat& p_apexParameter ) { - MxFloat param5 = p_param5; - Mx3DPointFloat local24; - MxU32 local8 = TRUE; + MxFloat originalApexParameter = p_apexParameter; + Mx3DPointFloat intersectionPoint; + MxU32 solutionNotFound = TRUE; for (MxS32 i = 0; i < m_numL; i++) { if (m_boundaries[i].m_flags & LegoPathBoundary::c_bit3) { @@ -999,75 +999,76 @@ MxResult LegoPathController::FUN_1004a380( } LegoPathBoundary* b = &m_boundaries[i]; - Mx4DPointFloat* unk0x14 = b->GetUp(); - float local28 = p_param3[0].Dot(p_param3[0], *unk0x14); + Mx4DPointFloat* up = b->GetUp(); + float coeffADotUp = p_coefficients[0].Dot(p_coefficients[0], *up); - if (local28 < 0.001 && local28 > -0.001) { + if (coeffADotUp < 0.001 && coeffADotUp > -0.001) { continue; } - float local2c = p_param3[1].Dot(p_param3[1], *unk0x14); - float local34 = p_param3[2].Dot(p_param3[2], *unk0x14) + unk0x14->index_operator(3); - float local3c = local2c * local2c - local34 * local28 * 4.0f; + float coeffBDotUp = p_coefficients[1].Dot(p_coefficients[1], *up); + float coeffCDotUp = p_coefficients[2].Dot(p_coefficients[2], *up) + up->index_operator(3); + float quadraticDiscriminant = coeffBDotUp * coeffBDotUp - coeffCDotUp * coeffADotUp * 4.0f; - if (local3c < -0.001) { + if (quadraticDiscriminant < -0.001) { continue; } - if (local3c < 0.0f) { - local3c = 0.0f; + if (quadraticDiscriminant < 0.0f) { + quadraticDiscriminant = 0.0f; } else { - local3c = sqrt(local3c); + quadraticDiscriminant = sqrt(quadraticDiscriminant); } - float local38 = (local3c - local2c) / (local28 * 2.0f); - float local44 = (-local3c - local2c) / (local28 * 2.0f); + float intersectionParameter = (quadraticDiscriminant - coeffBDotUp) / (coeffADotUp * 2.0f); + float alternativeIntersectionParameter = (-quadraticDiscriminant - coeffBDotUp) / (coeffADotUp * 2.0f); - if (!IsBetween(local38, 0.0f, param5)) { - if (IsBetween(local44, 0.0f, param5)) { - local38 = local44; + if (!IsBetween(intersectionParameter, 0.0f, originalApexParameter)) { + if (IsBetween(alternativeIntersectionParameter, 0.0f, originalApexParameter)) { + intersectionParameter = alternativeIntersectionParameter; } else { continue; } } - if (local8 || FUN_100c17a0(local38, p_param5, 0.0f, param5)) { - Mx3DPointFloat local58(p_param3[0]); + if (solutionNotFound || + BothSameComparison(intersectionParameter, p_apexParameter, 0.0f, originalApexParameter)) { + Mx3DPointFloat tSqrA(p_coefficients[0]); - local58 *= local38 * local38; - local24 = p_param3[1]; - local24 *= local38; - local24 += p_param3[2]; - local24 += local58; + tSqrA *= intersectionParameter * intersectionParameter; + intersectionPoint = p_coefficients[1]; + intersectionPoint *= intersectionParameter; + intersectionPoint += p_coefficients[2]; + intersectionPoint += tSqrA; assert(b->GetNumEdges() > 1); MxS32 j; for (j = b->GetNumEdges() - 1; j >= 0; j--) { - Mx4DPointFloat* local60 = b->GetEdgeNormal(j); + Mx4DPointFloat* edgeNormal = b->GetEdgeNormal(j); - if (local24.Dot(*local60, local24) + local60->index_operator(3) < -0.001) { + if (intersectionPoint.Dot(*edgeNormal, intersectionPoint) + edgeNormal->index_operator(3) < -0.001) { break; } } if (j < 0) { - Mx3DPointFloat local74(p_param1); - local74 -= local24; + Mx3DPointFloat direction(p_location); + direction -= intersectionPoint; - if (local74.Dot(local74, *unk0x14) >= 0.0f) { - p_param5 = local38; + if (direction.Dot(direction, *up) >= 0.0f) { + p_apexParameter = intersectionParameter; p_boundary = b; - local8 = FALSE; + solutionNotFound = FALSE; } } } } - if (local8) { - p_param5 = param5; + if (solutionNotFound) { + p_apexParameter = originalApexParameter; return FAILURE; } diff --git a/LEGO1/lego/legoomni/src/worlds/act3.cpp b/LEGO1/lego/legoomni/src/worlds/act3.cpp index f7c773ed..bedbf451 100644 --- a/LEGO1/lego/legoomni/src/worlds/act3.cpp +++ b/LEGO1/lego/legoomni/src/worlds/act3.cpp @@ -335,7 +335,7 @@ MxResult Act3::ShootPizza(LegoPathController* p_controller, Vector3& p_location, } MxFloat unk0x19c = *m_pizzas[nextPizza].GetApexParameter(); - if (p_controller->FUN_1004a380( + if (p_controller->FindIntersectionBoundary( p_location, p_direction, m_pizzas[nextPizza].GetCoefficients(), @@ -390,7 +390,7 @@ MxResult Act3::ShootDonut(LegoPathController* p_controller, Vector3& p_location, } MxFloat unk0x19c = *m_donuts[nextDonut].GetApexParameter(); - if (p_controller->FUN_1004a380( + if (p_controller->FindIntersectionBoundary( p_location, p_direction, m_donuts[nextDonut].GetCoefficients(),