diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index df1bb21c..43674fee 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -48,7 +48,14 @@ class LegoPathActor : public LegoActor { Vector3& p_point4 ); // vtable+0x80 virtual void VTable0x84(); // vtable+0x84 - virtual void VTable0x88(); // vtable+0x88 + virtual MxResult VTable0x88( + LegoPathBoundary* p_boundary, + float p_time, + LegoEdge& p_edge1, + float p_scale1, + LegoEdge& p_edge2, + float p_scale2 + ); // vtable+0x88 virtual void VTable0x8c(); // vtable+0x8c // FUNCTION: LEGO1 0x10002d40 @@ -110,7 +117,7 @@ class LegoPathActor : public LegoActor { LegoUnknown m_unk0x8c; // 0x8c MxU32 m_state; // 0xdc LegoEdge* m_destEdge; // 0xe0 - undefined4 m_unk0xe4; // 0xe4 + MxFloat m_unk0xe4; // 0xe4 undefined m_unk0xe8; // 0xe8 undefined m_unk0xe9; // 0xe9 MxBool m_userNavFlag; // 0xea diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index 763059f5..8a8a5759 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -6,14 +6,20 @@ #include "mxstl/stlcompat.h" #include "mxtypes.h" -struct LegoPathBoundaryComparator { - MxBool operator()(const undefined*, const undefined*) const { return 0; } +class LegoPathActor; + +struct LegoPathActorSetCompare { + MxU32 operator()(const LegoPathActor* p_lhs, const LegoPathActor* p_rhs) const + { + return (MxS32) p_lhs < (MxS32) p_rhs; + } }; struct LegoAnimPresenterSetCompare { - MxBool operator()(const LegoAnimPresenter*, const LegoAnimPresenter*) const { return 0; } + MxBool operator()(const LegoAnimPresenter* p_lhs, const LegoAnimPresenter* p_rhs) const { return 0; } }; +typedef set LegoPathActorSet; typedef set LegoAnimPresenterSet; // VTABLE: LEGO1 0x100d8618 @@ -22,16 +28,28 @@ class LegoPathBoundary : public LegoWEGEdge { public: LegoPathBoundary(); - // STUB: LEGO1 0x10047a80 - // LegoPathBoundary::`scalar deleting destructor' + MxResult AddActor(LegoPathActor* p_actor); + inline LegoAnimPresenterSet* GetUnknown0x64() { return &m_unk0x64; } + // STUB: LEGO1 0x10047a80 + // LegoPathBoundary::`scalar deleting destructor' + private: - map m_unk0x54; // 0x54 - LegoAnimPresenterSet m_unk0x64; // 0x64 + LegoPathActorSet m_unk0x54; // 0x54 + LegoAnimPresenterSet m_unk0x64; // 0x64 }; // clang-format off +// TEMPLATE: LEGO1 0x10045d80 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::iterator::_Dec + +// TEMPLATE: LEGO1 0x10045dd0 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::_Insert + +// GLOBAL: LEGO1 0x100f11a4 +// _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::_Nil + // GLOBAL: LEGO1 0x100f3200 // _Tree >::_Kfn,LegoAnimPresenterSetCompare,allocator >::_Nil // clang-format on diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 48b3ceaf..f061dbed 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -52,10 +52,79 @@ MxResult LegoPathActor::VTable0x80(Vector3& p_point1, Vector3& p_point2, Vector3 return FAILURE; } -// STUB: LEGO1 0x1002d9c0 -void LegoPathActor::VTable0x88() +// FUNCTION: LEGO1 0x1002d9c0 +MxResult LegoPathActor::VTable0x88( + LegoPathBoundary* p_boundary, + float p_time, + LegoEdge& p_srcEdge, + float p_srcScale, + LegoEdge& p_dstEdge, + float p_dstScale +) { - // TODO + Vector3* v1 = p_srcEdge.GetOpposingPoint(p_boundary); + Vector3* v2 = p_srcEdge.GetPoint(p_boundary); + Vector3* v3 = p_dstEdge.GetOpposingPoint(p_boundary); + Vector3* v4 = p_dstEdge.GetPoint(p_boundary); + Mx3DPointFloat p1, p2, p3, p4, p5; + p1 = *v2; + ((Vector3&) p1).Sub(v1); + ((Vector3&) p1).Mul(p_srcScale); + ((Vector3&) p1).Add(v1); + p2 = *v4; + ((Vector3&) p2).Sub(v3); + ((Vector3&) p2).Mul(p_dstScale); + ((Vector3&) p2).Add(v3); + m_boundary = p_boundary; + m_destEdge = &p_dstEdge; + m_unk0xe4 = p_dstScale; + m_lastTime = p_time; + m_actorTime = p_time; + m_unk0x7c = 0; + p_dstEdge.FUN_1002ddc0(m_boundary, p3); + p4 = p2; + ((Vector3&) p4).Sub(&p1); + float len = ((Vector3&) p4).LenSquared(); + if (len > 0) { + len = sqrtf(len); + if (len > 0) { + p4.Div(len); + } + } + MxMatrix matrix; + Vector3 pos(matrix[3]); + Vector3 dir(matrix[2]); + Vector3 up(matrix[1]); + Vector3 right(matrix[0]); + matrix.SetIdentity(); + pos = p1; + dir = p4; + up = *m_boundary->GetUnknown0x14(); + if (!m_cameraFlag || !m_userNavFlag) { + ((Vector3&) dir).Mul(-1.0f); + } + right.EqualsCross(&up, &dir); + m_roi->FUN_100a46b0(matrix); + if (m_cameraFlag && m_userNavFlag) { + m_boundary->AddActor(this); + FUN_10010c30(); + } + else { + ((Vector3&) p5).EqualsCrossImpl(p_boundary->GetUnknown0x14()->GetData(), p3.GetData()); + float len2 = ((Vector3&) p5).LenSquared(); + if (len2 > 0) { + len2 = sqrtf(len2); + if (len2 > 0) { + p5.Div(len2); + } + } + if (VTable0x80(p1, p4, p2, p5) != SUCCESS) { + return FAILURE; + } + m_boundary->AddActor(this); + } + m_unk0xec = m_roi->GetLocal2World(); + return SUCCESS; } // STUB: LEGO1 0x1002de10 diff --git a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp index 641ece72..19afed47 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp @@ -1,6 +1,7 @@ #include "legopathboundary.h" #include "decomp.h" +#include "legopathactor.h" DECOMP_SIZE_ASSERT(LegoPathBoundary, 0x74) @@ -8,3 +9,11 @@ DECOMP_SIZE_ASSERT(LegoPathBoundary, 0x74) LegoPathBoundary::LegoPathBoundary() { } + +// FUNCTION: LEGO1 0x100573f0 +MxResult LegoPathBoundary::AddActor(LegoPathActor* p_actor) +{ + m_unk0x54.insert(p_actor); + p_actor->SetBoundary(this); + return SUCCESS; +} diff --git a/LEGO1/lego/sources/geom/legoedge.cpp b/LEGO1/lego/sources/geom/legoedge.cpp index 63e988c0..478e5830 100644 --- a/LEGO1/lego/sources/geom/legoedge.cpp +++ b/LEGO1/lego/sources/geom/legoedge.cpp @@ -4,6 +4,14 @@ DECOMP_SIZE_ASSERT(LegoEdge, 0x24) +// TODO Based on the offset, this should be in the header, but as a stub it's getting inlined when there... +// STUB: LEGO1 0x1002ddc0 +LegoResult LegoEdge::FUN_1002ddc0(LegoWEEdge* p_face, Vector3& p_point) +{ + // TODO + return SUCCESS; +} + // FUNCTION: LEGO1 0x1009a470 LegoEdge::LegoEdge() { diff --git a/LEGO1/lego/sources/geom/legoedge.h b/LEGO1/lego/sources/geom/legoedge.h index 81396dc4..a3b71b64 100644 --- a/LEGO1/lego/sources/geom/legoedge.h +++ b/LEGO1/lego/sources/geom/legoedge.h @@ -1,6 +1,7 @@ #ifndef __LEGOEDGE_H #define __LEGOEDGE_H +#include "misc/legotypes.h" #include "realtime/vector.h" class LegoWEEdge; @@ -16,6 +17,8 @@ struct LegoEdge { Vector3* GetOpposingPoint(LegoWEEdge* face); Vector3* GetPoint(LegoWEEdge* face); + LegoResult FUN_1002ddc0(LegoWEEdge* p_face, Vector3& p_point); + // SYNTHETIC: LEGO1 0x1009a4a0 // LegoEdge::`scalar deleting destructor' diff --git a/LEGO1/lego/sources/geom/legowegedge.h b/LEGO1/lego/sources/geom/legowegedge.h index c2838123..34a285b3 100644 --- a/LEGO1/lego/sources/geom/legowegedge.h +++ b/LEGO1/lego/sources/geom/legowegedge.h @@ -15,6 +15,7 @@ class LegoWEGEdge : public LegoWEEdge { LegoResult VTable0x04() override; // vtable+0x04 inline LegoU32 GetFlag0x10() { return m_unk0x0c & 0x10 ? FALSE : TRUE; } + inline Mx4DPointFloat* GetUnknown0x14() { return &m_unk0x14; } inline Mx4DPointFloat* GetEdgeNormal(int index) { return &m_edgeNormals[index]; } // SYNTHETIC: LEGO1 0x1009a7e0