From 507cd0cff4437ec3c93a15cb7de3d171de7c3ebb Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Tue, 9 Apr 2024 05:25:24 -0400 Subject: [PATCH] Refactor/Implement/Match LegoEdge (#786) * Refactor/Implement/Match LegoEdge * Reorder annotation --------- Co-authored-by: Christian Semmler --- CMakeLists.txt | 1 + LEGO1/lego/legoomni/include/legopathactor.h | 2 +- LEGO1/lego/sources/geom/legoedge.cpp | 63 +++++++++++++++++++++ LEGO1/lego/sources/geom/legoedge.h | 32 +++++++++++ LEGO1/lego/sources/geom/legoweedge.cpp | 5 +- LEGO1/lego/sources/geom/legoweedge.h | 22 ++----- 6 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 LEGO1/lego/sources/geom/legoedge.cpp create mode 100644 LEGO1/lego/sources/geom/legoedge.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c7abac57..37d29eb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,7 @@ target_link_libraries(roi PRIVATE viewmanager Vec::Vec) add_library(geom STATIC LEGO1/lego/sources/geom/legobox.cpp + LEGO1/lego/sources/geom/legoedge.cpp LEGO1/lego/sources/geom/legomesh.cpp LEGO1/lego/sources/geom/legosphere.cpp LEGO1/lego/sources/geom/legovertex.cpp diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 0baddf60..df1bb21c 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -109,7 +109,7 @@ protected: LegoPathBoundary* m_boundary; // 0x88 LegoUnknown m_unk0x8c; // 0x8c MxU32 m_state; // 0xdc - Edge* m_destEdge; // 0xe0 + LegoEdge* m_destEdge; // 0xe0 undefined4 m_unk0xe4; // 0xe4 undefined m_unk0xe8; // 0xe8 undefined m_unk0xe9; // 0xe9 diff --git a/LEGO1/lego/sources/geom/legoedge.cpp b/LEGO1/lego/sources/geom/legoedge.cpp new file mode 100644 index 00000000..63e988c0 --- /dev/null +++ b/LEGO1/lego/sources/geom/legoedge.cpp @@ -0,0 +1,63 @@ +#include "legoedge.h" + +#include "decomp.h" + +DECOMP_SIZE_ASSERT(LegoEdge, 0x24) + +// FUNCTION: LEGO1 0x1009a470 +LegoEdge::LegoEdge() +{ + m_faceA = NULL; + m_faceB = NULL; + m_ccwA = NULL; + m_cwA = NULL; + m_ccwB = NULL; + m_cwB = NULL; + m_pointA = NULL; + m_pointB = NULL; +} + +// FUNCTION: LEGO1 0x1009a4c0 +LegoEdge::~LegoEdge() +{ +} + +// FUNCTION: LEGO1 0x1009a4d0 +LegoEdge* LegoEdge::GetClockwiseEdge(LegoWEEdge* p_face) +{ + if (p_face == m_faceA) { + return m_cwA; + } + else if (p_face == m_faceB) { + return m_cwB; + } + else { + return NULL; + } +} + +// FUNCTION: LEGO1 0x1009a4f0 +LegoEdge* LegoEdge::GetCounterclockwiseEdge(LegoWEEdge* p_face) +{ + if (p_face == m_faceA) { + return m_ccwA; + } + else if (p_face == m_faceB) { + return m_ccwB; + } + else { + return NULL; + } +} + +// FUNCTION: LEGO1 0x1009a510 +Vector3* LegoEdge::GetOpposingPoint(LegoWEEdge* p_face) +{ + return p_face == m_faceA ? m_pointB : m_pointA; +} + +// FUNCTION: LEGO1 0x1009a530 +Vector3* LegoEdge::GetPoint(LegoWEEdge* p_face) +{ + 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 new file mode 100644 index 00000000..81396dc4 --- /dev/null +++ b/LEGO1/lego/sources/geom/legoedge.h @@ -0,0 +1,32 @@ +#ifndef __LEGOEDGE_H +#define __LEGOEDGE_H + +#include "realtime/vector.h" + +class LegoWEEdge; + +// VTABLE: LEGO1 0x100db7b8 +// SIZE 0x24 +struct LegoEdge { + LegoEdge(); + virtual ~LegoEdge(); // vtable+0x00 + + LegoEdge* GetClockwiseEdge(LegoWEEdge* face); + LegoEdge* GetCounterclockwiseEdge(LegoWEEdge* face); + Vector3* GetOpposingPoint(LegoWEEdge* face); + Vector3* GetPoint(LegoWEEdge* face); + + // SYNTHETIC: LEGO1 0x1009a4a0 + // LegoEdge::`scalar deleting destructor' + + LegoWEEdge* m_faceA; // 0x04 + LegoWEEdge* m_faceB; // 0x08 + LegoEdge* m_ccwA; // 0x0c + LegoEdge* m_cwA; // 0x10 + LegoEdge* m_ccwB; // 0x14 + LegoEdge* m_cwB; // 0x18 + Vector3* m_pointA; // 0x1c + Vector3* m_pointB; // 0x20 +}; + +#endif // __LEGOEDGE_H diff --git a/LEGO1/lego/sources/geom/legoweedge.cpp b/LEGO1/lego/sources/geom/legoweedge.cpp index ac2ee6b3..c03a5e3f 100644 --- a/LEGO1/lego/sources/geom/legoweedge.cpp +++ b/LEGO1/lego/sources/geom/legoweedge.cpp @@ -1,6 +1,5 @@ #include "legoweedge.h" -DECOMP_SIZE_ASSERT(Edge, 0x24) DECOMP_SIZE_ASSERT(LegoWEEdge, 0x0c) // FUNCTION: LEGO1 0x1009a550 @@ -22,8 +21,8 @@ LegoWEEdge::~LegoWEEdge() LegoResult LegoWEEdge::VTable0x04() { for (LegoS32 i = 0; i < m_numEdges; i++) { - Edge* e1 = m_edges[i]; - Edge* e2 = (m_numEdges - i) == 1 ? m_edges[0] : m_edges[i + 1]; + LegoEdge* e1 = m_edges[i]; + LegoEdge* e2 = (m_numEdges - i) == 1 ? m_edges[0] : m_edges[i + 1]; if (e2->m_pointA == e1->m_pointA) { e1->m_faceA = this; diff --git a/LEGO1/lego/sources/geom/legoweedge.h b/LEGO1/lego/sources/geom/legoweedge.h index ce947f83..9320db74 100644 --- a/LEGO1/lego/sources/geom/legoweedge.h +++ b/LEGO1/lego/sources/geom/legoweedge.h @@ -2,29 +2,15 @@ #define __LEGOWEEDGE_H #include "decomp.h" +#include "legoedge.h" #include "misc/legotypes.h" -class LegoWEEdge; - -// SIZE 0x24 -struct Edge { - undefined4 m_unk0x00; // 0x00 - LegoWEEdge* m_faceA; // 0x04 - LegoWEEdge* m_faceB; // 0x08 - Edge* m_ccwA; // 0x0c - Edge* m_cwA; // 0x10 - Edge* m_ccwB; // 0x14 - Edge* m_cwB; // 0x18 - undefined* m_pointA; // 0x1c - undefined* m_pointB; // 0x20 -}; - // VTABLE: LEGO1 0x100db7c0 // SIZE 0x0c class LegoWEEdge { public: LegoWEEdge(); - virtual ~LegoWEEdge(); + virtual ~LegoWEEdge(); // vtable+0x00 virtual LegoResult VTable0x04(); // vtable+0x04 @@ -34,8 +20,8 @@ public: // LegoWEEdge::`scalar deleting destructor' protected: - LegoU8 m_numEdges; // 0x04 - Edge** m_edges; // 0x08 + LegoU8 m_numEdges; // 0x04 + LegoEdge** m_edges; // 0x08 }; #endif // __LEGOWEEDGE_H