diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index 5450841d..1b1c9dd6 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -23,7 +23,7 @@ class Vector3; // VTABLE: LEGO1 0x100d7da8 // SIZE 0x40 struct LegoPathCtrlEdge : public LegoUnknown100db7f4 { - undefined4 FUN_10048c40(const Vector3&); + inline MxU32 FUN_10048c40(const Vector3& p_position); }; struct LegoPathCtrlEdgeCompare { diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 86c89917..03eec0b6 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -818,7 +818,10 @@ MxResult LegoPathController::FUN_10048310( LegoPathBoundary* bOther = (LegoPathBoundary*) e->OtherFace(b); assert(bOther); - if (e->BETA_1004a830(*bOther, p_mask)) { + if (!e->BETA_1004a830(*bOther, p_mask)) { + // This branch is empty, but present in the BETA - probably had comments only + } + else { if (bOther == p_newBoundary) { shouldRemove = FALSE; @@ -917,12 +920,66 @@ MxResult LegoPathController::FUN_10048310( return FAILURE; } -// STUB: LEGO1 0x10048c40 -// STUB: BETA10 0x1001cc90 -undefined4 LegoPathCtrlEdge::FUN_10048c40(const Vector3&) +// FUNCTION: LEGO1 0x10048c40 +// FUNCTION: BETA10 0x1001cc90 +inline MxU32 LegoPathCtrlEdge::FUN_10048c40(const Vector3& p_position) { - // TODO - return 0; + MxFloat localc, local10; + MxU32 result = FALSE; + + if (m_unk0x28[0] > 0.001 || m_unk0x28[0] < -0.001) { + localc = (p_position[0] - (*m_pointA)[0]) / m_unk0x28[0]; + + if (localc < 0 || localc > 1) { + return FALSE; + } + + result = TRUE; + } + else { + if (p_position[0] > (*m_pointA)[0] + 0.001 || p_position[0] < (*m_pointA)[0] - 0.001) { + return FALSE; + } + } + + if (m_unk0x28[1] > 0.001 || m_unk0x28[1] < -0.001) { + local10 = (p_position[1] - (*m_pointA)[1]) / m_unk0x28[1]; + + if (result) { + if (localc > local10 + 0.001 || localc < local10 - 0.001) { + return FALSE; + } + } + else { + result = TRUE; + localc = local10; + } + } + else { + if (p_position[1] > (*m_pointA)[1] + 0.001 || p_position[1] < (*m_pointA)[1] - 0.001) { + return FALSE; + } + } + + if (m_unk0x28[2] > 0.001 || m_unk0x28[2] < -0.001) { + local10 = (p_position[2] - (*m_pointA)[2]) / m_unk0x28[2]; + + if (result) { + if (localc > local10 + 0.001 || localc < local10 - 0.001) { + return FALSE; + } + } + else { + return TRUE; + } + } + else { + if (p_position[2] > (*m_pointA)[2] + 0.001 || p_position[2] < (*m_pointA)[2] - 0.001) { + return FALSE; + } + } + + return TRUE; } // FUNCTION: LEGO1 0x1004a240 diff --git a/LEGO1/lego/sources/geom/legounkown100db7f4.h b/LEGO1/lego/sources/geom/legounkown100db7f4.h index 38de039e..8387c5fa 100644 --- a/LEGO1/lego/sources/geom/legounkown100db7f4.h +++ b/LEGO1/lego/sources/geom/legounkown100db7f4.h @@ -74,7 +74,7 @@ struct LegoUnknown100db7f4 : public LegoEdge { ((Vector3&) point).Add(*m_pointB); ((Vector3&) point).Mul(0.5f); ((Vector3&) point).Sub(p_vec); - return sqrt(point.LenSquared()); + return sqrt((double) point.LenSquared()); } // FUNCTION: BETA10 0x100bd540 @@ -87,7 +87,7 @@ struct LegoUnknown100db7f4 : public LegoEdge { ((Vector3&) point2).Add(*p_other.m_pointB); ((Vector3&) point2).Mul(0.5f); ((Vector3&) point1).Sub(point2); - return sqrt(point1.LenSquared()); + return sqrt((double) point1.LenSquared()); } // FUNCTION: BETA10 0x1001cc60