diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index d534e0b2..5450841d 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -184,6 +184,15 @@ class LegoPathController : public MxCore { // TEMPLATE: LEGO1 0x100451a0 // _Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::~_Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::iterator::_Inc + +// TEMPLATE: LEGO1 0x100452b0 +// _Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::erase + +// TEMPLATE: LEGO1 0x10045700 +// _Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::_Erase + // TEMPLATE: LEGO1 0x100457e0 // Set::~Set @@ -236,7 +245,7 @@ class LegoPathController : public MxCore { // _Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::_Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::erase +// ?erase@?$_Tree@PAULegoPathCtrlEdge@@PAU1@U_Kfn@?$set@PAULegoPathCtrlEdge@@ULegoPathCtrlEdgeCompare@@V?$allocator@PAULegoPathCtrlEdge@@@@@@ULegoPathCtrlEdgeCompare@@V?$allocator@PAULegoPathCtrlEdge@@@@@@QAEIABQAULegoPathCtrlEdge@@@Z // TEMPLATE: LEGO1 0x10049290 // _Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::find @@ -244,6 +253,9 @@ class LegoPathController : public MxCore { // TEMPLATE: LEGO1 0x100492f0 // _Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::_Copy +// TEMPLATE: LEGO1 0x10049370 +// _Tree >::_Kfn,LegoPathCtrlEdgeCompare,allocator >::_Ubound + // TEMPLATE: LEGO1 0x10049410 // list >::insert diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 1b885e70..b60a5381 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -2553,7 +2553,7 @@ MxBool LegoAnimationManager::FUN_10064120(LegoLocation::Boundary* p_boundary, Mx while (local2c--) { if (local34 != NULL) { - if (local34->Unknown(*boundary, LegoWEGEdge::c_bit1) && FUN_10064010(boundary, local34, destScale) && + if (local34->BETA_1004a830(*boundary, LegoWEGEdge::c_bit1) && FUN_10064010(boundary, local34, destScale) && (!p_bool2 || FUN_10064010(boundary, local8, destScale))) { p_boundary->m_srcScale = p_boundary->m_destScale = destScale; p_boundary->m_name = boundary->GetName(); diff --git a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp index 297aa223..d72ee168 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp @@ -92,7 +92,7 @@ void LegoPathBoundary::SwitchBoundary( { LegoUnknown100db7f4* e = p_edge; - if (p_edge->Unknown2(*p_boundary)) { + if (p_edge->BETA_100b53b0(*p_boundary)) { LegoPathBoundary* newBoundary = (LegoPathBoundary*) p_edge->OtherFace(p_boundary); if (newBoundary == NULL) { @@ -102,7 +102,7 @@ void LegoPathBoundary::SwitchBoundary( MxS32 local10 = 0; MxU8 userNavFlag; - if (e->Unknown(*newBoundary, 1)) { + if (e->BETA_1004a830(*newBoundary, 1)) { userNavFlag = p_actor->GetUserNavFlag(); } else { @@ -113,7 +113,7 @@ void LegoPathBoundary::SwitchBoundary( p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary); LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(newBoundary); - if (p_edge->GetMask0x03() && (userNavFlag || p_edge->Unknown(*local20, 1))) { + if (p_edge->GetMask0x03() && (userNavFlag || p_edge->BETA_1004a830(*local20, 1))) { local10++; } } while (p_edge != e); @@ -141,7 +141,7 @@ void LegoPathBoundary::SwitchBoundary( LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(newBoundary); - if (p_edge->GetMask0x03() && (userNavFlag || p_edge->Unknown(*local20, 1))) { + if (p_edge->GetMask0x03() && (userNavFlag || p_edge->BETA_1004a830(*local20, 1))) { local8--; } } diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index ab96069e..86c89917 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -753,142 +753,140 @@ MxResult LegoPathController::FUN_10048310( if (p_newBoundary == p_oldBoundary) { p_grec->SetBit1(TRUE); + return SUCCESS; } - else { - list boundaryList; - list::iterator boundaryListIt; - LegoBEWithFloatSet boundarySet; - LegoBEWithFloatSet::iterator boundarySetItA; - LegoBEWithFloatSet::iterator boundarySetItB; + list boundaryList; + list::iterator boundaryListIt; - LegoPathCtrlEdgeSet pathCtrlEdgeSet(m_pfsE); + LegoBEWithFloatSet boundarySet; + LegoBEWithFloatSet::iterator boundarySetItA; + LegoBEWithFloatSet::iterator boundarySetItB; - MxFloat local14 = 999999.0f; + LegoPathCtrlEdgeSet pathCtrlEdgeSet(m_pfsE); - p_grec->SetBit1(FALSE); + MxFloat local14 = 999999.0f; - for (MxS32 i = 0; i < p_oldBoundary->GetNumEdges(); i++) { - LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) p_oldBoundary->GetEdges()[i]; + p_grec->SetBit1(FALSE); - if (edge->GetMask0x03()) { - LegoPathBoundary* otherFace = (LegoPathBoundary*) edge->OtherFace(p_oldBoundary); + for (MxS32 i = 0; i < p_oldBoundary->GetNumEdges(); i++) { + LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) p_oldBoundary->GetEdges()[i]; - if (otherFace != NULL && edge->Unknown(*otherFace, p_mask)) { - if (p_newBoundary == otherFace) { - float dist = edge->DistanceToMidpoint(p_oldPosition) + edge->DistanceToMidpoint(p_newPosition); + if (edge->GetMask0x03()) { + LegoPathBoundary* otherFace = (LegoPathBoundary*) edge->OtherFace(p_oldBoundary); - if (dist < local14) { - local14 = dist; - p_grec->erase(p_grec->begin(), p_grec->end()); - p_grec->SetBit1(TRUE); - p_grec->push_back(LegoBoundaryEdge(edge, p_oldBoundary)); + if (otherFace != NULL && edge->BETA_1004a830(*otherFace, p_mask)) { + if (p_newBoundary == otherFace) { + float dist; + if ((dist = edge->DistanceToMidpoint(p_oldPosition) + edge->DistanceToMidpoint(p_newPosition)) < + local14) { + local14 = dist; + p_grec->erase(p_grec->begin(), p_grec->end()); + p_grec->SetBit1(TRUE); + p_grec->push_back(LegoBoundaryEdge(edge, p_oldBoundary)); + } + } + else { + boundaryList.push_back(LegoBEWithFloat(edge, p_oldBoundary, edge->DistanceToMidpoint(p_oldPosition)) + ); + boundarySet.insert(&boundaryList.back()); + } + } + } + + pathCtrlEdgeSet.erase(edge); + } + + if (!p_grec->GetBit1()) { + while (pathCtrlEdgeSet.size() > 0) { + LegoBEWithFloat edgeWithFloat; + MxFloat local70 = 999999.0f; + + boundarySetItA = boundarySetItB = boundarySet.begin(); + + if (boundarySetItB != boundarySet.end()) { + boundarySetItB++; + } + + while (boundarySetItA != boundarySet.end()) { + MxU32 shouldRemove = TRUE; + + LegoUnknown100db7f4* e = (*boundarySetItA)->m_edge; + LegoPathBoundary* b = (*boundarySetItA)->m_boundary; + assert(e && b); + + LegoPathBoundary* bOther = (LegoPathBoundary*) e->OtherFace(b); + assert(bOther); + + if (e->BETA_1004a830(*bOther, p_mask)) { + if (bOther == p_newBoundary) { + shouldRemove = FALSE; + + LegoBEWithFloat* pfs = *boundarySetItA; + assert(pfs); + + float dist; + if ((dist = pfs->m_edge->DistanceToMidpoint(p_newPosition) + pfs->m_unk0x0c) < local70) { + local70 = dist; + edgeWithFloat.m_edge = NULL; + + if (dist < local14) { + 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 { - boundaryList.push_back( - LegoBEWithFloat(edge, p_oldBoundary, edge->DistanceToMidpoint(p_oldPosition)) - ); - boundarySet.insert(&boundaryList.back()); - } - } - } + for (MxS32 i = 0; i < bOther->GetNumEdges(); i++) { + LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) bOther->GetEdges()[i]; - pathCtrlEdgeSet.erase(edge); - } + if (edge->GetMask0x03()) { + if (pathCtrlEdgeSet.find(edge) != pathCtrlEdgeSet.end()) { + shouldRemove = FALSE; - if (!p_grec->GetBit1()) { - while (pathCtrlEdgeSet.size() > 0) { - LegoBEWithFloat edgeWithFloat; - MxFloat local70 = 999999.0f; - - boundarySetItA = boundarySetItB = boundarySet.begin(); - - if (boundarySetItB != boundarySet.end()) { - boundarySetItB++; - } - - while (boundarySetItA != boundarySet.end()) { - MxU32 shouldRemove = TRUE; - - LegoUnknown100db7f4* e = (*boundarySetItA)->m_edge; - LegoPathBoundary* b = (*boundarySetItA)->m_boundary; - assert(e && b); - - LegoPathBoundary* bOther = (LegoPathBoundary*) e->OtherFace(b); - assert(bOther); - - if (e->Unknown(*bOther, p_mask)) { - if (bOther == p_newBoundary) { - shouldRemove = FALSE; - - LegoBEWithFloat* pfs = *boundarySetItA; - assert(pfs); - - float dist = pfs->m_edge->DistanceToMidpoint(p_newPosition) + pfs->m_unk0x0c; - - if (dist < local70) { - local70 = dist; - edgeWithFloat.m_edge = NULL; - - if (dist < local14) { - 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 { - for (MxS32 i = 0; i < bOther->GetNumEdges(); i++) { - LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) bOther->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 = LegoBEWithFloat(edge, bOther, *boundarySetItA, dist); - } + float dist; + if ((dist = edge->DistanceBetweenMidpoints(*e) + (*boundarySetItA)->m_unk0x0c) < + local70) { + local70 = dist; + edgeWithFloat = LegoBEWithFloat(edge, bOther, *boundarySetItA, dist); } } } } } + } - if (shouldRemove) { - boundarySet.erase(boundarySetItA); - } - - if (boundarySetItB == boundarySet.end()) { - break; - } + if (shouldRemove) { + boundarySet.erase(boundarySetItA); + } + if (boundarySetItB != boundarySet.end()) { boundarySetItA = boundarySetItB; boundarySetItB++; } - - if (edgeWithFloat.m_edge == NULL) { + else { break; } + } + if (edgeWithFloat.m_edge != NULL) { pathCtrlEdgeSet.erase(edgeWithFloat.m_edge); boundaryList.push_back(edgeWithFloat); boundarySet.insert(&boundaryList.back()); } + else { + break; + } } + } - if (!p_grec->GetBit1()) { - return FAILURE; - } - + if (p_grec->GetBit1()) { if (p_grec->size() > 0) { LegoPathCtrlEdge* edge = p_grec->front().m_edge; @@ -902,7 +900,7 @@ MxResult LegoPathController::FUN_10048310( if (edge->FUN_10048c40(p_newPosition)) { if (edge->OtherFace(p_grec->back().m_boundary) != NULL && - edge->OtherFace(p_grec->back().m_boundary)->IsEqual(*p_newBoundary)) { + edge->OtherFace(p_grec->back().m_boundary)->IsEqual(p_newBoundary)) { p_grec->m_boundary = p_grec->back().m_boundary; p_grec->pop_back(); } @@ -912,9 +910,11 @@ MxResult LegoPathController::FUN_10048310( if (p_param9 != NULL) { *p_param9 = local14; } + + return SUCCESS; } - return SUCCESS; + return FAILURE; } // STUB: LEGO1 0x10048c40 diff --git a/LEGO1/lego/sources/geom/legounkown100db7f4.h b/LEGO1/lego/sources/geom/legounkown100db7f4.h index f8de433d..38de039e 100644 --- a/LEGO1/lego/sources/geom/legounkown100db7f4.h +++ b/LEGO1/lego/sources/geom/legounkown100db7f4.h @@ -24,15 +24,14 @@ struct LegoUnknown100db7f4 : public LegoEdge { // FUNCTION: BETA10 0x100372a0 LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point) { - if (p_f.IsEqual(*m_faceA)) { + if (p_f.IsEqual(m_faceA)) { p_point[0] = -m_unk0x28.index_operator(0); p_point[1] = -m_unk0x28.index_operator(1); p_point[2] = -m_unk0x28.index_operator(2); } else { // clang-format off - // FIXME: There is no * dereference in the original assertion - assert(p_f.IsEqual( *m_faceB )); + assert(p_f.IsEqual( m_faceB )); // clang-format on p_point = m_unk0x28; } @@ -41,16 +40,20 @@ struct LegoUnknown100db7f4 : public LegoEdge { } // FUNCTION: BETA10 0x1004a830 - LegoU32 Unknown(LegoWEGEdge& p_face, LegoU8 p_mask) + LegoU32 BETA_1004a830(LegoWEGEdge& p_face, LegoU8 p_mask) { - return (p_face.IsEqual(*m_faceB) && (m_flags & c_bit1) && (p_face.GetMask0x03() & p_mask) == p_mask) || - (p_face.IsEqual(*m_faceA) && (m_flags & c_bit2) && (p_face.GetMask0x03() & p_mask) == p_mask); + assert(p_face.IsEqual(m_faceA) || p_face.IsEqual(m_faceB)); + return (p_face.IsEqual(m_faceB) && (m_flags & c_bit1) && (p_face.GetMask0x03() & p_mask) == p_mask) || + (p_face.IsEqual(m_faceA) && (m_flags & c_bit2) && (p_face.GetMask0x03() & p_mask) == p_mask); } // FUNCTION: BETA10 0x100b53b0 - LegoU32 Unknown2(LegoWEGEdge& p_face) + LegoU32 BETA_100b53b0(LegoWEGEdge& p_face) { - return (p_face.IsEqual(*m_faceA) && (m_flags & c_bit1)) || (p_face.IsEqual(*m_faceB) && (m_flags & c_bit2)); + // clang-format off + assert(p_face.IsEqual( m_faceA ) || p_face.IsEqual( m_faceB )); + // clang-format on + return (p_face.IsEqual(m_faceA) && (m_flags & c_bit1)) || (p_face.IsEqual(m_faceB) && (m_flags & c_bit2)); } // FUNCTION: BETA10 0x1001cbe0 diff --git a/LEGO1/lego/sources/geom/legoweedge.h b/LEGO1/lego/sources/geom/legoweedge.h index e8436427..bc0f6c3c 100644 --- a/LEGO1/lego/sources/geom/legoweedge.h +++ b/LEGO1/lego/sources/geom/legoweedge.h @@ -22,9 +22,8 @@ class LegoWEEdge { // FUNCTION: BETA10 0x1001cc30 LegoUnknown100db7f4** GetEdges() { return m_edges; } - // TODO: The assertion at BETA10 0x10037352 suggests that this function might take a pointer instead of a reference // FUNCTION: BETA10 0x100373f0 - LegoU32 IsEqual(LegoWEEdge& p_other) { return this == &p_other; } + LegoU32 IsEqual(LegoWEEdge* p_other) { return this == p_other; } void SetEdges(LegoUnknown100db7f4** p_edges, LegoU8 p_numEdges) { diff --git a/LEGO1/lego/sources/geom/legowegedge.h b/LEGO1/lego/sources/geom/legowegedge.h index 728d7ade..be388c2d 100644 --- a/LEGO1/lego/sources/geom/legowegedge.h +++ b/LEGO1/lego/sources/geom/legowegedge.h @@ -62,6 +62,7 @@ class LegoWEGEdge : public LegoWEEdge { } } + // FUNCTION: BETA10 0x1004a980 LegoU8 GetMask0x03() { return m_flags & (c_bit1 | c_bit2); } // SYNTHETIC: LEGO1 0x1009a7e0