Add more annotations, improve match

This commit is contained in:
Christian Semmler 2024-12-06 12:13:19 -07:00
parent 174a7aa5b0
commit 7297e2675e
7 changed files with 136 additions and 121 deletions

View File

@ -184,6 +184,15 @@ class LegoPathController : public MxCore {
// TEMPLATE: LEGO1 0x100451a0 // TEMPLATE: LEGO1 0x100451a0
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::~_Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathControl // _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::~_Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathControl
// TEMPLATE: LEGO1 0x10045270
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::iterator::_Inc
// TEMPLATE: LEGO1 0x100452b0
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::erase
// TEMPLATE: LEGO1 0x10045700
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Erase
// TEMPLATE: LEGO1 0x100457e0 // TEMPLATE: LEGO1 0x100457e0
// Set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare>::~Set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare> // Set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare>::~Set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare>
@ -236,7 +245,7 @@ class LegoPathController : public MxCore {
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,Le // _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,Le
// TEMPLATE: LEGO1 0x10049160 // TEMPLATE: LEGO1 0x10049160
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::erase // ?erase@?$_Tree@PAULegoPathCtrlEdge@@PAU1@U_Kfn@?$set@PAULegoPathCtrlEdge@@ULegoPathCtrlEdgeCompare@@V?$allocator@PAULegoPathCtrlEdge@@@@@@ULegoPathCtrlEdgeCompare@@V?$allocator@PAULegoPathCtrlEdge@@@@@@QAEIABQAULegoPathCtrlEdge@@@Z
// TEMPLATE: LEGO1 0x10049290 // TEMPLATE: LEGO1 0x10049290
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::find // _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::find
@ -244,6 +253,9 @@ class LegoPathController : public MxCore {
// TEMPLATE: LEGO1 0x100492f0 // TEMPLATE: LEGO1 0x100492f0
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Copy // _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Copy
// TEMPLATE: LEGO1 0x10049370
// _Tree<LegoPathCtrlEdge *,LegoPathCtrlEdge *,set<LegoPathCtrlEdge *,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Kfn,LegoPathCtrlEdgeCompare,allocator<LegoPathCtrlEdge *> >::_Ubound
// TEMPLATE: LEGO1 0x10049410 // TEMPLATE: LEGO1 0x10049410
// list<LegoBEWithFloat,allocator<LegoBEWithFloat> >::insert // list<LegoBEWithFloat,allocator<LegoBEWithFloat> >::insert

View File

@ -2553,7 +2553,7 @@ MxBool LegoAnimationManager::FUN_10064120(LegoLocation::Boundary* p_boundary, Mx
while (local2c--) { while (local2c--) {
if (local34 != NULL) { 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_bool2 || FUN_10064010(boundary, local8, destScale))) {
p_boundary->m_srcScale = p_boundary->m_destScale = destScale; p_boundary->m_srcScale = p_boundary->m_destScale = destScale;
p_boundary->m_name = boundary->GetName(); p_boundary->m_name = boundary->GetName();

View File

@ -92,7 +92,7 @@ void LegoPathBoundary::SwitchBoundary(
{ {
LegoUnknown100db7f4* e = p_edge; 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); LegoPathBoundary* newBoundary = (LegoPathBoundary*) p_edge->OtherFace(p_boundary);
if (newBoundary == NULL) { if (newBoundary == NULL) {
@ -102,7 +102,7 @@ void LegoPathBoundary::SwitchBoundary(
MxS32 local10 = 0; MxS32 local10 = 0;
MxU8 userNavFlag; MxU8 userNavFlag;
if (e->Unknown(*newBoundary, 1)) { if (e->BETA_1004a830(*newBoundary, 1)) {
userNavFlag = p_actor->GetUserNavFlag(); userNavFlag = p_actor->GetUserNavFlag();
} }
else { else {
@ -113,7 +113,7 @@ void LegoPathBoundary::SwitchBoundary(
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary); p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary);
LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(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++; local10++;
} }
} while (p_edge != e); } while (p_edge != e);
@ -141,7 +141,7 @@ void LegoPathBoundary::SwitchBoundary(
LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(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))) {
local8--; local8--;
} }
} }

View File

@ -753,142 +753,140 @@ MxResult LegoPathController::FUN_10048310(
if (p_newBoundary == p_oldBoundary) { if (p_newBoundary == p_oldBoundary) {
p_grec->SetBit1(TRUE); p_grec->SetBit1(TRUE);
return SUCCESS;
} }
else {
list<LegoBEWithFloat> boundaryList;
list<LegoBEWithFloat>::iterator boundaryListIt;
LegoBEWithFloatSet boundarySet; list<LegoBEWithFloat> boundaryList;
LegoBEWithFloatSet::iterator boundarySetItA; list<LegoBEWithFloat>::iterator boundaryListIt;
LegoBEWithFloatSet::iterator boundarySetItB;
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++) { p_grec->SetBit1(FALSE);
LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) p_oldBoundary->GetEdges()[i];
if (edge->GetMask0x03()) { for (MxS32 i = 0; i < p_oldBoundary->GetNumEdges(); i++) {
LegoPathBoundary* otherFace = (LegoPathBoundary*) edge->OtherFace(p_oldBoundary); LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) p_oldBoundary->GetEdges()[i];
if (otherFace != NULL && edge->Unknown(*otherFace, p_mask)) { if (edge->GetMask0x03()) {
if (p_newBoundary == otherFace) { LegoPathBoundary* otherFace = (LegoPathBoundary*) edge->OtherFace(p_oldBoundary);
float dist = edge->DistanceToMidpoint(p_oldPosition) + edge->DistanceToMidpoint(p_newPosition);
if (dist < local14) { if (otherFace != NULL && edge->BETA_1004a830(*otherFace, p_mask)) {
local14 = dist; if (p_newBoundary == otherFace) {
p_grec->erase(p_grec->begin(), p_grec->end()); float dist;
p_grec->SetBit1(TRUE); if ((dist = edge->DistanceToMidpoint(p_oldPosition) + edge->DistanceToMidpoint(p_newPosition)) <
p_grec->push_back(LegoBoundaryEdge(edge, p_oldBoundary)); 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 { else {
boundaryList.push_back( for (MxS32 i = 0; i < bOther->GetNumEdges(); i++) {
LegoBEWithFloat(edge, p_oldBoundary, edge->DistanceToMidpoint(p_oldPosition)) LegoPathCtrlEdge* edge = (LegoPathCtrlEdge*) bOther->GetEdges()[i];
);
boundarySet.insert(&boundaryList.back());
}
}
}
pathCtrlEdgeSet.erase(edge); if (edge->GetMask0x03()) {
} if (pathCtrlEdgeSet.find(edge) != pathCtrlEdgeSet.end()) {
shouldRemove = FALSE;
if (!p_grec->GetBit1()) { float dist;
while (pathCtrlEdgeSet.size() > 0) { if ((dist = edge->DistanceBetweenMidpoints(*e) + (*boundarySetItA)->m_unk0x0c) <
LegoBEWithFloat edgeWithFloat; local70) {
MxFloat local70 = 999999.0f; local70 = dist;
edgeWithFloat = LegoBEWithFloat(edge, bOther, *boundarySetItA, dist);
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);
}
} }
} }
} }
} }
} }
}
if (shouldRemove) { if (shouldRemove) {
boundarySet.erase(boundarySetItA); boundarySet.erase(boundarySetItA);
} }
if (boundarySetItB == boundarySet.end()) {
break;
}
if (boundarySetItB != boundarySet.end()) {
boundarySetItA = boundarySetItB; boundarySetItA = boundarySetItB;
boundarySetItB++; boundarySetItB++;
} }
else {
if (edgeWithFloat.m_edge == NULL) {
break; break;
} }
}
if (edgeWithFloat.m_edge != NULL) {
pathCtrlEdgeSet.erase(edgeWithFloat.m_edge); pathCtrlEdgeSet.erase(edgeWithFloat.m_edge);
boundaryList.push_back(edgeWithFloat); boundaryList.push_back(edgeWithFloat);
boundarySet.insert(&boundaryList.back()); boundarySet.insert(&boundaryList.back());
} }
else {
break;
}
} }
}
if (!p_grec->GetBit1()) { if (p_grec->GetBit1()) {
return FAILURE;
}
if (p_grec->size() > 0) { if (p_grec->size() > 0) {
LegoPathCtrlEdge* edge = p_grec->front().m_edge; LegoPathCtrlEdge* edge = p_grec->front().m_edge;
@ -902,7 +900,7 @@ MxResult LegoPathController::FUN_10048310(
if (edge->FUN_10048c40(p_newPosition)) { if (edge->FUN_10048c40(p_newPosition)) {
if (edge->OtherFace(p_grec->back().m_boundary) != NULL && 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->m_boundary = p_grec->back().m_boundary;
p_grec->pop_back(); p_grec->pop_back();
} }
@ -912,9 +910,11 @@ MxResult LegoPathController::FUN_10048310(
if (p_param9 != NULL) { if (p_param9 != NULL) {
*p_param9 = local14; *p_param9 = local14;
} }
return SUCCESS;
} }
return SUCCESS; return FAILURE;
} }
// STUB: LEGO1 0x10048c40 // STUB: LEGO1 0x10048c40

View File

@ -24,15 +24,14 @@ struct LegoUnknown100db7f4 : public LegoEdge {
// FUNCTION: BETA10 0x100372a0 // FUNCTION: BETA10 0x100372a0
LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point) 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[0] = -m_unk0x28.index_operator(0);
p_point[1] = -m_unk0x28.index_operator(1); p_point[1] = -m_unk0x28.index_operator(1);
p_point[2] = -m_unk0x28.index_operator(2); p_point[2] = -m_unk0x28.index_operator(2);
} }
else { else {
// clang-format off // 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 // clang-format on
p_point = m_unk0x28; p_point = m_unk0x28;
} }
@ -41,16 +40,20 @@ struct LegoUnknown100db7f4 : public LegoEdge {
} }
// FUNCTION: BETA10 0x1004a830 // 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) || assert(p_face.IsEqual(m_faceA) || p_face.IsEqual(m_faceB));
(p_face.IsEqual(*m_faceA) && (m_flags & c_bit2) && (p_face.GetMask0x03() & p_mask) == 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);
} }
// FUNCTION: BETA10 0x100b53b0 // 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 // FUNCTION: BETA10 0x1001cbe0

View File

@ -22,9 +22,8 @@ class LegoWEEdge {
// FUNCTION: BETA10 0x1001cc30 // FUNCTION: BETA10 0x1001cc30
LegoUnknown100db7f4** GetEdges() { return m_edges; } 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 // 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) void SetEdges(LegoUnknown100db7f4** p_edges, LegoU8 p_numEdges)
{ {

View File

@ -62,6 +62,7 @@ class LegoWEGEdge : public LegoWEEdge {
} }
} }
// FUNCTION: BETA10 0x1004a980
LegoU8 GetMask0x03() { return m_flags & (c_bit1 | c_bit2); } LegoU8 GetMask0x03() { return m_flags & (c_bit1 | c_bit2); }
// SYNTHETIC: LEGO1 0x1009a7e0 // SYNTHETIC: LEGO1 0x1009a7e0