From f4c124ea86335b2c56966eb5060c6ad8574eb4e3 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 5 Dec 2024 18:11:07 -0700 Subject: [PATCH] WIP --- .../legoomni/include/legopathedgecontainer.h | 26 +++++++++++++----- .../legoomni/src/paths/legopathcontroller.cpp | 27 +++++++++++++++++-- LEGO1/lego/sources/geom/legounkown100db7f4.h | 13 +++++++++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopathedgecontainer.h b/LEGO1/lego/legoomni/include/legopathedgecontainer.h index 58a25d43..d342e911 100644 --- a/LEGO1/lego/legoomni/include/legopathedgecontainer.h +++ b/LEGO1/lego/legoomni/include/legopathedgecontainer.h @@ -32,7 +32,7 @@ struct LegoBoundaryEdgeWithFloat { { m_edge = NULL; m_boundary = NULL; - m_unk0x08 = 0; + m_next = NULL; m_unk0x0c = 0.0f; } @@ -41,14 +41,28 @@ struct LegoBoundaryEdgeWithFloat { { m_edge = p_edge; m_boundary = p_boundary; - m_unk0x08 = 0; + m_next = NULL; m_unk0x0c = p_unk0x0c; } - LegoPathCtrlEdge* m_edge; // 0x00 - LegoPathBoundary* m_boundary; // 0x04 - undefined4 m_unk0x08; // 0x08 - MxFloat m_unk0x0c; // 0x0c + // FUNCTION: BETA10 0x100bd9f0 + LegoBoundaryEdgeWithFloat( + LegoPathCtrlEdge* p_edge, + LegoPathBoundary* p_boundary, + LegoBoundaryEdgeWithFloat* p_next, + MxFloat p_unk0x0c + ) + { + m_edge = p_edge; + m_boundary = p_boundary; + m_next = p_next; + m_unk0x0c = p_unk0x0c; + } + + LegoPathCtrlEdge* m_edge; // 0x00 + LegoPathBoundary* m_boundary; // 0x04 + LegoBoundaryEdgeWithFloat* m_next; // 0x08 + MxFloat m_unk0x0c; // 0x0c int operator==(LegoBoundaryEdgeWithFloat) const { return 0; } int operator<(LegoBoundaryEdgeWithFloat) const { return 0; } diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 29539c31..fac68083 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -832,12 +832,35 @@ MxResult LegoPathController::FUN_10048310( edgeWithFloat.m_edge = NULL; if (dist < local14) { - // TODO + local14 = dist; + p_grec->erase(p_grec->begin(), p_grec->end()); + p_grec->SetBit1(TRUE); + + do { + p_grec->push_front(LegoBoundaryEdge(pfs->m_edge, pfs->m_boundary)); + pfs = pfs->m_next; + } while (pfs != NULL); } } } else { - // TODO + for (MxS32 i = 0; i < bOther->GetNumEdges(); i++) { + LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) p_oldBoundary->GetEdges()[i]; + + if (edge->GetMask0x03()) { + if (pathCtrlEdgeSet.find(edge) != pathCtrlEdgeSet.end()) { + shouldRemove = FALSE; + + float dist = edge->DistanceBetweenMidpoints(*e) + (*boundarySetItA)->m_unk0x0c; + + if (dist < local70) { + local70 = dist; + edgeWithFloat = + LegoBoundaryEdgeWithFloat(edge, bOther, *boundarySetItA, dist); + } + } + } + } } } diff --git a/LEGO1/lego/sources/geom/legounkown100db7f4.h b/LEGO1/lego/sources/geom/legounkown100db7f4.h index a4ff0822..110b7089 100644 --- a/LEGO1/lego/sources/geom/legounkown100db7f4.h +++ b/LEGO1/lego/sources/geom/legounkown100db7f4.h @@ -74,6 +74,19 @@ struct LegoUnknown100db7f4 : public LegoEdge { return sqrt(point.LenSquared()); } + // FUNCTION: BETA10 0x100bd540 + LegoFloat DistanceBetweenMidpoints(const LegoUnknown100db7f4& p_other) + { + Mx3DPointFloat point1(*m_pointA); + Mx3DPointFloat point2(*p_other.m_pointA); + ((Vector3&) point1).Add(*m_pointB); + ((Vector3&) point1).Mul(0.5f); + ((Vector3&) point2).Add(*m_pointB); + ((Vector3&) point2).Mul(0.5f); + ((Vector3&) point1).Sub(point2); + return sqrt(point1.LenSquared()); + } + // FUNCTION: BETA10 0x1001cc60 LegoU32 GetMask0x03() { return m_flags & (c_bit1 | c_bit2); }