diff --git a/LEGO1/lego/legoomni/include/legopathstruct.h b/LEGO1/lego/legoomni/include/legopathstruct.h index fd752050..174ad7b8 100644 --- a/LEGO1/lego/legoomni/include/legopathstruct.h +++ b/LEGO1/lego/legoomni/include/legopathstruct.h @@ -5,6 +5,7 @@ #include "mxatom.h" #include "mxtypes.h" +class LegoPathActor; class LegoWorld; // VTABLE: LEGO1 0x100d7d9c @@ -35,7 +36,7 @@ struct LegoPathStruct : public LegoPathStructBase { // FUNCTION: LEGO1 0x10047470 ~LegoPathStruct() override {} - void VTable0x04(undefined4, undefined4, undefined4); // vtable+0x04 + virtual void VTable0x04(LegoPathActor*, undefined4, undefined4); // vtable+0x04 inline void SetWorld(LegoWorld* p_world) { m_world = p_world; } inline void SetAtomId(const MxAtomId& p_atomId) { m_atomId = p_atomId; } diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 3aee0c1a..ce297e26 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -2139,8 +2139,8 @@ MxBool LegoAnimationManager::FUN_10063fb0(LegoLocation::Boundary* p_boundary, Le MxBool LegoAnimationManager::FUN_10064010(LegoPathBoundary* p_boundary, LegoUnknown100db7f4* p_edge, float p_destScale) { Mx3DPointFloat p1; - Vector3* v1 = p_edge->GetOpposingPoint(p_boundary); - Vector3* v2 = p_edge->GetPoint(p_boundary); + Vector3* v1 = p_edge->GetOpposingPoint(*p_boundary); + Vector3* v2 = p_edge->CCWVertex(*p_boundary); p1 = *v2; ((Vector3&) p1).Sub(v1); @@ -2196,7 +2196,7 @@ MxBool LegoAnimationManager::FUN_10064120(LegoLocation::Boundary* p_boundary, Mx e = local50; do { - e = (LegoUnknown100db7f4*) e->GetCounterclockwiseEdge(boundary); + e = (LegoUnknown100db7f4*) e->GetCounterclockwiseEdge(*boundary); if (e->GetMask0x03()) { break; } @@ -2237,10 +2237,10 @@ MxBool LegoAnimationManager::FUN_10064120(LegoLocation::Boundary* p_boundary, Mx do { if (p_bool1) { - local34 = (LegoUnknown100db7f4*) local34->GetCounterclockwiseEdge(boundary); + local34 = (LegoUnknown100db7f4*) local34->GetCounterclockwiseEdge(*boundary); } else { - local34 = (LegoUnknown100db7f4*) local34->GetClockwiseEdge(boundary); + local34 = (LegoUnknown100db7f4*) local34->GetClockwiseEdge(*boundary); } } while (!local34->GetMask0x03() && local34 != local50); diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 390f185e..0d1f8438 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -90,10 +90,10 @@ MxResult LegoPathActor::VTable0x88( float p_destScale ) { - Vector3* v1 = p_srcEdge.GetOpposingPoint(p_boundary); - Vector3* v2 = p_srcEdge.GetPoint(p_boundary); - Vector3* v3 = p_destEdge.GetOpposingPoint(p_boundary); - Vector3* v4 = p_destEdge.GetPoint(p_boundary); + Vector3* v1 = p_srcEdge.GetOpposingPoint(*p_boundary); + Vector3* v2 = p_srcEdge.CCWVertex(*p_boundary); + Vector3* v3 = p_destEdge.GetOpposingPoint(*p_boundary); + Vector3* v4 = p_destEdge.CCWVertex(*p_boundary); Mx3DPointFloat p1, p2, p3, p4, p5; @@ -167,8 +167,8 @@ MxResult LegoPathActor::VTable0x84( float p_destScale ) { - Vector3* v3 = p_destEdge.GetOpposingPoint(p_boundary); - Vector3* v4 = p_destEdge.GetPoint(p_boundary); + Vector3* v3 = p_destEdge.GetOpposingPoint(*p_boundary); + Vector3* v4 = p_destEdge.CCWVertex(*p_boundary); Mx3DPointFloat p2, p3, p5; diff --git a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp index c4a5cacb..593c9955 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp @@ -3,6 +3,7 @@ #include "decomp.h" #include "geom/legounkown100db7f4.h" #include "legopathactor.h" +#include "legopathstruct.h" DECOMP_SIZE_ASSERT(LegoPathBoundary, 0x74) @@ -40,9 +41,43 @@ MxResult LegoPathBoundary::RemoveActor(LegoPathActor* p_actor) return SUCCESS; } -// STUB: LEGO1 0x100575b0 +// FUNCTION: LEGO1 0x100575b0 +// FUNCTION: BETA10 0x100b1598 void LegoPathBoundary::FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPathActor* p_actor) { + Vector3* ccwV = NULL; + + if (m_unk0x48 > 0 && m_unk0x50 != NULL) { + ccwV = m_edges[0]->CCWVertex(*this); + Mx3DPointFloat v; + + v = p_point1; + ((Vector3&) v).Sub(ccwV); + float dot1 = v.Dot(&v, m_unk0x50); + + v = p_point2; + ((Vector3&) v).Sub(ccwV); + float dot2 = v.Dot(&v, m_unk0x50); + + if (dot2 > dot1) { + for (MxS32 i = 0; i < m_unk0x48; i++) { + LegoPathStruct* s = m_unk0x4c[i].m_unk0x00; + + if (m_unk0x4c[i].m_unk0x08 >= dot1 && m_unk0x4c[i].m_unk0x08 < dot2) { + s->VTable0x04(p_actor, 1, m_unk0x4c[i].m_unk0x04); + } + } + } + else if (dot2 < dot1) { + for (MxS32 i = 0; i < m_unk0x48; i++) { + LegoPathStruct* s = m_unk0x4c[i].m_unk0x00; + + if (m_unk0x4c[i].m_unk0x08 >= dot2 && m_unk0x4c[i].m_unk0x08 < dot1) { + s->VTable0x04(p_actor, 0, m_unk0x4c[i].m_unk0x04); + } + } + } + } } // FUNCTION: LEGO1 0x10057950 @@ -98,7 +133,7 @@ MxU32 LegoPathBoundary::Intersect( Mx3DPointFloat local50; Mx3DPointFloat local70; - Vector3* local5c = e->GetOpposingPoint(this); + Vector3* local5c = e->GetOpposingPoint(*this); p_point3 = vec; p_point3.Mul(localc); @@ -115,15 +150,15 @@ MxU32 LegoPathBoundary::Intersect( if (local58 < 0.0f) { Mx3DPointFloat local84; - for (LegoUnknown100db7f4* local88 = (LegoUnknown100db7f4*) e->GetClockwiseEdge(this); e != local88; - local88 = (LegoUnknown100db7f4*) local88->GetClockwiseEdge(this)) { + for (LegoUnknown100db7f4* local88 = (LegoUnknown100db7f4*) e->GetClockwiseEdge(*this); e != local88; + local88 = (LegoUnknown100db7f4*) local88->GetClockwiseEdge(*this)) { local88->FUN_1002ddc0(*this, local84); if (local84.Dot(&local84, &local70) <= 0.9) { break; } - Vector3* local90 = local88->GetOpposingPoint(this); + Vector3* local90 = local88->GetOpposingPoint(*this); Mx3DPointFloat locala4(p_point3); ((Vector3&) locala4).Sub(local90); @@ -141,16 +176,16 @@ MxU32 LegoPathBoundary::Intersect( if (e->m_unk0x3c < local58) { Mx3DPointFloat localbc; - for (LegoUnknown100db7f4* locala8 = (LegoUnknown100db7f4*) e->GetCounterclockwiseEdge(this); + for (LegoUnknown100db7f4* locala8 = (LegoUnknown100db7f4*) e->GetCounterclockwiseEdge(*this); e != locala8; - locala8 = (LegoUnknown100db7f4*) locala8->GetCounterclockwiseEdge(this)) { + locala8 = (LegoUnknown100db7f4*) locala8->GetCounterclockwiseEdge(*this)) { locala8->FUN_1002ddc0(*this, localbc); if (localbc.Dot(&localbc, &local70) <= 0.9) { break; } - Vector3* localc4 = locala8->GetOpposingPoint(this); + Vector3* localc4 = locala8->GetOpposingPoint(*this); Mx3DPointFloat locald8(p_point3); ((Vector3&) locald8).Sub(localc4); @@ -172,7 +207,7 @@ MxU32 LegoPathBoundary::Intersect( if (local58 <= 0.0f) { if (!e->GetMask0x03()) { - p_edge = e->GetClockwiseEdge(this); + p_edge = e->GetClockwiseEdge(*this); } else { p_edge = e; @@ -189,10 +224,10 @@ MxU32 LegoPathBoundary::Intersect( return 1; } else { - p_point3 = *e->GetPoint(this); + p_point3 = *e->CCWVertex(*this); if (!e->GetMask0x03()) { - p_edge = e->GetCounterclockwiseEdge(this); + p_edge = e->GetCounterclockwiseEdge(*this); } else { p_edge = e; diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index a5f1797d..3d3d6c62 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -279,10 +279,10 @@ MxResult LegoPathController::FUN_10046050( if (edge->GetMask0x03()) { Mx3DPointFloat vec; - if (((LegoUnknown100db7f4*) edge->GetClockwiseEdge(boundary))->FUN_1002ddc0(*boundary, vec) == SUCCESS && + if (((LegoUnknown100db7f4*) edge->GetClockwiseEdge(*boundary))->FUN_1002ddc0(*boundary, vec) == SUCCESS && vec.Dot(&vec, &p_direction) < 0.0f) { edge = - (LegoUnknown100db7f4*) edge->GetCounterclockwiseEdge(boundary)->GetCounterclockwiseEdge(boundary); + (LegoUnknown100db7f4*) edge->GetCounterclockwiseEdge(*boundary)->GetCounterclockwiseEdge(*boundary); } if (!edge->GetMask0x03()) { diff --git a/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp b/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp index 2cbf51c4..5b694042 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp @@ -5,7 +5,7 @@ DECOMP_SIZE_ASSERT(LegoPathStruct, 0x14) // STUB: LEGO1 0x1001b700 // FUNCTION: BETA10 0x100c26c5 -void LegoPathStruct::VTable0x04(undefined4, undefined4, undefined4) +void LegoPathStruct::VTable0x04(LegoPathActor*, undefined4, undefined4) { // TODO } diff --git a/LEGO1/lego/sources/geom/legoedge.cpp b/LEGO1/lego/sources/geom/legoedge.cpp index 63e988c0..1788a0d7 100644 --- a/LEGO1/lego/sources/geom/legoedge.cpp +++ b/LEGO1/lego/sources/geom/legoedge.cpp @@ -23,12 +23,12 @@ LegoEdge::~LegoEdge() } // FUNCTION: LEGO1 0x1009a4d0 -LegoEdge* LegoEdge::GetClockwiseEdge(LegoWEEdge* p_face) +LegoEdge* LegoEdge::GetClockwiseEdge(LegoWEEdge& p_face) { - if (p_face == m_faceA) { + if (&p_face == m_faceA) { return m_cwA; } - else if (p_face == m_faceB) { + else if (&p_face == m_faceB) { return m_cwB; } else { @@ -37,12 +37,12 @@ LegoEdge* LegoEdge::GetClockwiseEdge(LegoWEEdge* p_face) } // FUNCTION: LEGO1 0x1009a4f0 -LegoEdge* LegoEdge::GetCounterclockwiseEdge(LegoWEEdge* p_face) +LegoEdge* LegoEdge::GetCounterclockwiseEdge(LegoWEEdge& p_face) { - if (p_face == m_faceA) { + if (&p_face == m_faceA) { return m_ccwA; } - else if (p_face == m_faceB) { + else if (&p_face == m_faceB) { return m_ccwB; } else { @@ -51,13 +51,13 @@ LegoEdge* LegoEdge::GetCounterclockwiseEdge(LegoWEEdge* p_face) } // FUNCTION: LEGO1 0x1009a510 -Vector3* LegoEdge::GetOpposingPoint(LegoWEEdge* p_face) +Vector3* LegoEdge::GetOpposingPoint(LegoWEEdge& p_face) { - return p_face == m_faceA ? m_pointB : m_pointA; + return &p_face == m_faceA ? m_pointB : m_pointA; } // FUNCTION: LEGO1 0x1009a530 -Vector3* LegoEdge::GetPoint(LegoWEEdge* p_face) +Vector3* LegoEdge::CCWVertex(LegoWEEdge& p_face) { - return p_face == m_faceB ? m_pointB : m_pointA; + return &p_face == m_faceB ? m_pointB : m_pointA; } diff --git a/LEGO1/lego/sources/geom/legoedge.h b/LEGO1/lego/sources/geom/legoedge.h index da440e71..0f238c37 100644 --- a/LEGO1/lego/sources/geom/legoedge.h +++ b/LEGO1/lego/sources/geom/legoedge.h @@ -12,12 +12,12 @@ struct LegoEdge { LegoEdge(); virtual ~LegoEdge(); // vtable+0x00 - LegoEdge* GetClockwiseEdge(LegoWEEdge* face); - LegoEdge* GetCounterclockwiseEdge(LegoWEEdge* face); - Vector3* GetOpposingPoint(LegoWEEdge* face); - Vector3* GetPoint(LegoWEEdge* face); + LegoEdge* GetClockwiseEdge(LegoWEEdge& p_face); + LegoEdge* GetCounterclockwiseEdge(LegoWEEdge& p_face); + Vector3* GetOpposingPoint(LegoWEEdge& p_face); + Vector3* CCWVertex(LegoWEEdge& p_face); - LegoResult FUN_1002ddc0(LegoWEEdge* p_face, Vector3& p_point); + 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 9ec06692..906ec015 100644 --- a/LEGO1/lego/sources/geom/legowegedge.h +++ b/LEGO1/lego/sources/geom/legowegedge.h @@ -27,12 +27,12 @@ class LegoWEGEdge : public LegoWEEdge { { m_unk0x00 = NULL; m_unk0x04 = 0; - m_unk0x08 = 0; + m_unk0x08 = 0.0f; } LegoPathStruct* m_unk0x00; // 0x00 undefined4 m_unk0x04; // 0x04 - undefined4 m_unk0x08; // 0x08 + float m_unk0x08; // 0x08 }; LegoWEGEdge();