From 36a6298419cd1a327e2737ab64f8a755c7145e3e Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 26 Mar 2024 10:30:14 -0400 Subject: [PATCH] Style changes and implement WEEdge --- CMakeLists.txt | 4 +- LEGO1/lego/legoomni/include/legoanimactor.h | 20 +++---- LEGO1/lego/legoomni/include/legopathactor.h | 2 +- .../lego/legoomni/include/legopathboundary.h | 9 ++-- .../legoomni/include/legopathcontroller.h | 22 ++++---- .../lego/legoomni/src/paths/legoanimactor.cpp | 20 +++---- LEGO1/lego/sources/geom/legoweedge.cpp | 53 +++++++++++++++++++ LEGO1/lego/sources/geom/legoweedge.h | 39 ++++++++++++++ LEGO1/lego/sources/geom/legowegedge.cpp | 44 +++++++++++++++ .../lego/sources/{misc => geom}/legowegedge.h | 15 ++++-- LEGO1/lego/sources/misc/legoweedge.cpp | 12 ----- LEGO1/lego/sources/misc/legoweedge.h | 45 ---------------- LEGO1/lego/sources/misc/legowegedge.cpp | 13 ----- tools/ncc/skip.yml | 3 ++ 14 files changed, 188 insertions(+), 113 deletions(-) create mode 100644 LEGO1/lego/sources/geom/legoweedge.cpp create mode 100644 LEGO1/lego/sources/geom/legoweedge.h create mode 100644 LEGO1/lego/sources/geom/legowegedge.cpp rename LEGO1/lego/sources/{misc => geom}/legowegedge.h (54%) delete mode 100644 LEGO1/lego/sources/misc/legoweedge.cpp delete mode 100644 LEGO1/lego/sources/misc/legoweedge.h delete mode 100644 LEGO1/lego/sources/misc/legowegedge.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index af7313d4..d7f18ad8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,8 +150,8 @@ add_library(geom STATIC LEGO1/lego/sources/geom/legomesh.cpp LEGO1/lego/sources/geom/legosphere.cpp LEGO1/lego/sources/geom/legovertex.cpp - "LEGO1/lego/sources/misc/legoweedge.cpp" - "LEGO1/lego/sources/misc/legowegedge.cpp" + LEGO1/lego/sources/geom/legoweedge.cpp + LEGO1/lego/sources/geom/legowegedge.cpp ) register_lego1_target(geom) set_property(TARGET geom PROPERTY ARCHIVE_OUTPUT_NAME "geom$<$:d>") diff --git a/LEGO1/lego/legoomni/include/legoanimactor.h b/LEGO1/lego/legoomni/include/legoanimactor.h index 289efaed..bc673b74 100644 --- a/LEGO1/lego/legoomni/include/legoanimactor.h +++ b/LEGO1/lego/legoomni/include/legoanimactor.h @@ -1,20 +1,20 @@ #ifndef LEGOANIMACTOR_H #define LEGOANIMACTOR_H +#include "anim/legoanim.h" #include "decomp.h" -#include "lego/sources/anim/legoanim.h" #include "legopathactor.h" // SIZE 0x20 struct LegoAnimActorStruct { - LegoAnimActorStruct(float p_float, LegoAnim* p_animTreePtr, LegoROI** p_roiMap, MxU32 p_numROIs); + LegoAnimActorStruct(float p_unk0x00, LegoAnim* p_AnimTreePtr, LegoROI** p_roiMap, MxU32 p_numROIs); ~LegoAnimActorStruct(); float GetDuration(); - float m_unk0x00; // 0x00 - LegoAnim* m_animTreePtr; // 0x04 - LegoROI** m_roiMap; // 0x08 - MxU32 m_numROIs; // 0x0c - vector m_unk0x10; // 0x10 + float m_unk0x00; // 0x00 + LegoAnim* m_AnimTreePtr; // 0x04 + LegoROI** m_roiMap; // 0x08 + MxU32 m_numROIs; // 0x0c + vector m_unk0x10; // 0x10 }; // VTABLE: LEGO1 0x100d5440 LegoPathActor @@ -45,7 +45,7 @@ class LegoAnimActor : public virtual LegoPathActor { virtual MxResult FUN_1001c1f0(float& p_out); virtual MxResult FUN_1001c360(float, Matrix4& p_transform); - virtual MxResult FUN_1001c450(LegoAnim* p_animTreePtr, float p_float, LegoROI** p_roiMap, MxU32 p_numROIs); + virtual MxResult FUN_1001c450(LegoAnim* p_AnimTreePtr, float p_unk0x00, LegoROI** p_roiMap, MxU32 p_numROIs); virtual void ClearMaps(); // SYNTHETIC: LEGO1 0x1000fb60 @@ -60,10 +60,10 @@ class LegoAnimActor : public virtual LegoPathActor { // Vector::~Vector // TEMPLATE: LEGO1 0x1001c010 -// vector >::~vector > +// vector >::~vector > // TEMPLATE: LEGO1 0x1001c050 -// Vector::~Vector +// Vector::~Vector // TEMPLATE: LEGO1 0x1001c7c0 // vector >::size diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 012585be..adff5952 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -95,7 +95,7 @@ class LegoPathActor : public LegoActor { // LegoPathActor::`scalar deleting destructor' protected: - MxFloat m_bADuration; // 0x78 + MxFloat m_BADuration; // 0x78 undefined4 m_unk0x7c; // 0x7c MxFloat m_unk0x80; // 0x80 MxFloat m_unk0x84; // 0x84 diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index dc9188b0..f61493e3 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -1,11 +1,12 @@ #ifndef LEGOPATHBOUNDARY_H #define LEGOPATHBOUNDARY_H -#include "misc/legowegedge.h" +#include "geom/legowegedge.h" #include "mxstl/stlcompat.h" +#include "mxtypes.h" struct LegoPathBoundaryComparator { - MxBool operator()(const void*, const void*) const { return 0; } + MxBool operator()(const undefined*, const undefined*) const { return 0; } }; // SIZE 0x74 @@ -14,8 +15,8 @@ class LegoPathBoundary : public LegoWEGEdge { LegoPathBoundary(); private: - map m_unk0x54; // 0x54 - map m_unk0x64; // 0x64 + map m_unk0x54; // 0x54 + map m_unk0x64; // 0x64 }; #endif // LEGOPATHBOUNDARY_H diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index d74356b3..4c69a157 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -9,7 +9,7 @@ class LegoPathBoundary; class LegoWorld; struct LegoPathControllerComparator { - MxBool operator()(void*, void*) const { return 0; } + MxBool operator()(undefined*, undefined*) const { return 0; } }; // VTABLE: LEGO1 0x100d7d60 @@ -46,16 +46,16 @@ class LegoPathController : public MxCore { void FUN_10046bb0(LegoWorld* p_world); private: - LegoPathBoundary* m_unk0x08; // 0x08 - undefined4 m_unk0x0c; // 0x0c - undefined4 m_unk0x10; // 0x10 - undefined4 m_unk0x14; // 0x14 - MxS16 m_numL; // 0x18 - MxS16 m_numE; // 0x1a - MxS16 m_numN; // 0x1c - MxS16 m_numT; // 0x1e - map m_pfsE; // 0x20 - map m_unk0x30; // 0x30 + LegoPathBoundary* m_unk0x08; // 0x08 + undefined4 m_unk0x0c; // 0x0c + undefined4 m_unk0x10; // 0x10 + undefined4 m_unk0x14; // 0x14 + MxS16 m_numL; // 0x18 + MxS16 m_numE; // 0x1a + MxS16 m_numN; // 0x1c + MxS16 m_numT; // 0x1e + map m_pfsE; // 0x20 + map m_unk0x30; // 0x30 }; #endif // LEGOPATHCONTROLLER_H diff --git a/LEGO1/lego/legoomni/src/paths/legoanimactor.cpp b/LEGO1/lego/legoomni/src/paths/legoanimactor.cpp index 9e061397..b9cf8fe4 100644 --- a/LEGO1/lego/legoomni/src/paths/legoanimactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoanimactor.cpp @@ -10,10 +10,10 @@ DECOMP_SIZE_ASSERT(LegoAnimActor, 0x174) DECOMP_SIZE_ASSERT(LegoAnimActorStruct, 0x20) // FUNCTION: LEGO1 0x1001bf80 -LegoAnimActorStruct::LegoAnimActorStruct(float p_float, LegoAnim* p_animTreePtr, LegoROI** p_roiMap, MxU32 p_numROIs) +LegoAnimActorStruct::LegoAnimActorStruct(float p_unk0x00, LegoAnim* p_AnimTreePtr, LegoROI** p_roiMap, MxU32 p_numROIs) { - m_unk0x00 = p_float; - m_animTreePtr = p_animTreePtr; + m_unk0x00 = p_unk0x00; + m_AnimTreePtr = p_AnimTreePtr; m_roiMap = p_roiMap; m_numROIs = p_numROIs; } @@ -29,7 +29,7 @@ LegoAnimActorStruct::~LegoAnimActorStruct() // FUNCTION: LEGO1 0x1001c130 float LegoAnimActorStruct::GetDuration() { - return m_animTreePtr->GetDuration(); + return m_AnimTreePtr->GetDuration(); } // FUNCTION: LEGO1 0x1001c140 @@ -45,8 +45,8 @@ LegoAnimActor::~LegoAnimActor() // FUNCTION: LEGO1 0x1001c1f0 MxResult LegoAnimActor::FUN_1001c1f0(float& p_out) { - p_out = m_unk0x80 - (float) m_animMaps[m_curAnim]->m_animTreePtr->GetDuration() * - ((int) (m_unk0x80 / (float) m_animMaps[m_curAnim]->m_animTreePtr->GetDuration())); + p_out = m_unk0x80 - (float) m_animMaps[m_curAnim]->m_AnimTreePtr->GetDuration() * + ((MxS32) (m_unk0x80 / (float) m_animMaps[m_curAnim]->m_AnimTreePtr->GetDuration())); return SUCCESS; } @@ -89,7 +89,7 @@ MxResult LegoAnimActor::FUN_1001c360(float p_float, Matrix4& p_transform) LegoROI** roiMap = anim->m_roiMap; MxU32 numROIs = anim->m_numROIs; if (m_boundary->GetFlag0x10()) { - LegoTreeNode* root = anim->m_animTreePtr->GetRoot(); + LegoTreeNode* root = anim->m_AnimTreePtr->GetRoot(); m_roi->SetVisibility(TRUE); for (MxU32 i = 0; i < numROIs; i++) { if (roiMap[i] && (roiMap[i] != m_roi)) { @@ -119,11 +119,11 @@ MxResult LegoAnimActor::FUN_1001c360(float p_float, Matrix4& p_transform) } // FUNCTION: LEGO1 0x1001c450 -MxResult LegoAnimActor::FUN_1001c450(LegoAnim* p_animTreePtr, float p_float, LegoROI** p_roiMap, MxU32 p_numROIs) +MxResult LegoAnimActor::FUN_1001c450(LegoAnim* p_animTreePtr, float p_unk0x00, LegoROI** p_roiMap, MxU32 p_numROIs) { - LegoAnimActorStruct* laas = new LegoAnimActorStruct(p_float, p_animTreePtr, p_roiMap, p_numROIs); + LegoAnimActorStruct* laas = new LegoAnimActorStruct(p_unk0x00, p_animTreePtr, p_roiMap, p_numROIs); for (vector::iterator it = m_animMaps.begin(); it != m_animMaps.end(); it++) { - if (p_float < (*it)->m_unk0x00) { + if (p_unk0x00 < (*it)->m_unk0x00) { m_animMaps.insert(it, laas); SetWorldSpeed(m_worldSpeed); return SUCCESS; diff --git a/LEGO1/lego/sources/geom/legoweedge.cpp b/LEGO1/lego/sources/geom/legoweedge.cpp new file mode 100644 index 00000000..922affd7 --- /dev/null +++ b/LEGO1/lego/sources/geom/legoweedge.cpp @@ -0,0 +1,53 @@ +#include "legoweedge.h" + +DECOMP_SIZE_ASSERT(Edge, 0x24) +DECOMP_SIZE_ASSERT(LegoWEEdge, 0x0c) + +// FUNCTION: LEGO1 0x1009a550 +LegoWEEdge::LegoWEEdge() +{ + m_edges = NULL; + m_numEdges = 0; +} + +// FUNCTION: LEGO1 0x1009a590 +LegoWEEdge::~LegoWEEdge() +{ + if (m_edges) { + delete m_edges; + } +} + +// FUNCTION: LEGO1 0x1009a5b0 +LegoResult LegoWEEdge::VTable0x04() +{ + for (int i = 0; i < m_numEdges; i++) { + Edge* e1 = m_edges[i]; + Edge* e2 = (m_numEdges - i) == 1 ? m_edges[0] : m_edges[i + 1]; + if (e2->m_pointA == e1->m_pointA) { + e1->m_faceA = this; + e2->m_faceB = this; + e1->m_ccwA = e2; + e2->m_cwB = e1; + } + else if (e2->m_pointB == e1->m_pointA) { + e1->m_faceA = this; + e2->m_faceA = this; + e1->m_ccwA = e2; + e2->m_cwA = e1; + } + else if (e1->m_pointB == e2->m_pointA) { + e1->m_faceB = this; + e2->m_faceB = this; + e1->m_ccwB = e2; + e2->m_cwB = e1; + } + else { + e1->m_faceB = this; + e2->m_faceA = this; + e1->m_ccwB = e2; + e2->m_cwA = e1; + } + } + return SUCCESS; +} diff --git a/LEGO1/lego/sources/geom/legoweedge.h b/LEGO1/lego/sources/geom/legoweedge.h new file mode 100644 index 00000000..eea83914 --- /dev/null +++ b/LEGO1/lego/sources/geom/legoweedge.h @@ -0,0 +1,39 @@ +#ifndef __LEGOWEEDGE_H +#define __LEGOWEEDGE_H + +#include "decomp.h" +#include "misc/legotypes.h" + +class LegoWEEdge; + +// SIZE 0x24 +struct Edge { +public: + 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 + void* m_pointA; // 0x1c + void* m_pointB; // 0x20 +}; + +// VTABLE: LEGO1 0x100db7c0 +// SIZE 0x0c +class LegoWEEdge { +public: + LegoWEEdge(); + virtual ~LegoWEEdge(); // vtable+0x00 + virtual LegoResult VTable0x04(); // vtable+0x04 + + // SYNTHETIC: LEGO1 0x1009a570 + // LegoWEEdge::`scalar deleting destructor' + +protected: + LegoU8 m_numEdges; // 0x04 + Edge** m_edges; // 0x08 +}; + +#endif // __LEGOWEEDGE_H diff --git a/LEGO1/lego/sources/geom/legowegedge.cpp b/LEGO1/lego/sources/geom/legowegedge.cpp new file mode 100644 index 00000000..7b2cfb0b --- /dev/null +++ b/LEGO1/lego/sources/geom/legowegedge.cpp @@ -0,0 +1,44 @@ +#include "legowegedge.h" + +DECOMP_SIZE_ASSERT(LegoWEGEdge, 0x54) + +// FUNCTION: LEGO1 0x1009a730 +LegoWEGEdge::LegoWEGEdge() +{ + m_unk0x0d = 0; + m_name = NULL; + m_unk0x14.Clear(); + m_edgeNormals = NULL; + m_unk0x0c = 0; + m_unk0x48 = 0; + m_unk0x4c = 0; + m_unk0x50 = 0; +} + +// FUNCTION: LEGO1 0x1009a800 +LegoWEGEdge::~LegoWEGEdge() +{ + if (m_edges) { + delete[] m_edges; + m_edges = NULL; + } + if (m_name) { + delete[] m_name; + } + if (m_edgeNormals) { + delete[] m_edgeNormals; + } + if (m_unk0x4c) { + delete m_unk0x4c; + } + if (m_unk0x50) { + delete m_unk0x50; + } +} + +// STUB: LEGO1 0x1009a8c0 +LegoResult LegoWEGEdge::VTable0x04() +{ + // TODO + return SUCCESS; +} diff --git a/LEGO1/lego/sources/misc/legowegedge.h b/LEGO1/lego/sources/geom/legowegedge.h similarity index 54% rename from LEGO1/lego/sources/misc/legowegedge.h rename to LEGO1/lego/sources/geom/legowegedge.h index eaf16ec8..8618f676 100644 --- a/LEGO1/lego/sources/misc/legowegedge.h +++ b/LEGO1/lego/sources/geom/legowegedge.h @@ -1,28 +1,33 @@ #ifndef __LEGOWEGEDGE_H #define __LEGOWEGEDGE_H +#include "decomp.h" #include "legoweedge.h" #include "mxgeometry/mxgeometry3d.h" -#include "mxtypes.h" +// VTABLE: LEGO1 0x100db7f8 // SIZE 0x54 class LegoWEGEdge : public LegoWEEdge { public: LegoWEGEdge(); + virtual ~LegoWEGEdge(); // vtable+0x00 + LegoResult VTable0x04() override; // vtable+0x04 + inline LegoBool GetFlag0x10() { return m_unk0x0c & 0x10 ? FALSE : TRUE; } - inline MxBool GetFlag0x10() { return m_unk0x0c & 0x10 ? FALSE : TRUE; } + // SYNTHETIC: LEGO1 0x1009a7e0 + // LegoWEGEdge::`scalar deleting destructor' private: LegoU8 m_unk0x0c; // 0x0c LegoU8 m_unk0x0d; // 0x0d - char* m_name; // 0x10 + LegoChar* m_name; // 0x10 Mx4DPointFloat m_unk0x14; // 0x14 Mx4DPointFloat* m_edgeNormals; // 0x2c Mx3DPointFloat m_unk0x30; // 0x30 LegoU32 m_unk0x44; // 0x44 LegoU8 m_unk0x48; // 0x48 - LegoU32 m_unk0x4c; // 0x4c - LegoU32 m_unk0x50; // 0x50 + undefined* m_unk0x4c; // 0x4c + undefined* m_unk0x50; // 0x50 }; #endif // __LEGOWEGEDGE_H diff --git a/LEGO1/lego/sources/misc/legoweedge.cpp b/LEGO1/lego/sources/misc/legoweedge.cpp deleted file mode 100644 index aeb28f71..00000000 --- a/LEGO1/lego/sources/misc/legoweedge.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "legoweedge.h" - -DECOMP_SIZE_ASSERT(Edge, 0x24) -DECOMP_SIZE_ASSERT(EdgePair, 0x08) -DECOMP_SIZE_ASSERT(LegoWEEdge, 0x0c) - -// FUNCTION: LEGO1 0x1009a550 -LegoWEEdge::LegoWEEdge() -{ - m_edges = NULL; - m_numEdges = 0; -} diff --git a/LEGO1/lego/sources/misc/legoweedge.h b/LEGO1/lego/sources/misc/legoweedge.h deleted file mode 100644 index 2ec7dfe0..00000000 --- a/LEGO1/lego/sources/misc/legoweedge.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __LEGOWEEDGE_H -#define __LEGOWEEDGE_H - -#include "decomp.h" -#include "legotypes.h" - -class LegoWEEdge; - -// SIZE 0x24 -class Edge { - virtual ~Edge() - { - // TODO - } - LegoWEEdge* m_faceA; // 0x04 - LegoWEEdge* m_faceB; // 0x08 - Edge* m_ccwA; // 0x0c - Edge* m_cwA; // 0x10 - Edge* m_ccwB; // 0x14 - Edge* m_cwB; // 0x18 - void* m_pointA; // 0x1c - void* m_pointB; // 0x20 -}; - -// SIZE 0x08 -struct EdgePair { - Edge* m_e1; // 0x00 - Edge* m_e2; // 0x04 -}; - -// SIZE 0x0c -class LegoWEEdge { -public: - LegoWEEdge(); - virtual ~LegoWEEdge() - { - // TODO - } - -private: - LegoU8 m_numEdges; // 0x04 - EdgePair* m_edges; // 0x08 -}; - -#endif // __LEGOWEEDGE_H diff --git a/LEGO1/lego/sources/misc/legowegedge.cpp b/LEGO1/lego/sources/misc/legowegedge.cpp deleted file mode 100644 index 1fce8a2b..00000000 --- a/LEGO1/lego/sources/misc/legowegedge.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "legowegedge.h" - -DECOMP_SIZE_ASSERT(LegoWEGEdge, 0x54) - -// FUNCTION: LEGO1 0x1009a730 -LegoWEGEdge::LegoWEGEdge() -{ - m_edgeNormals = NULL; - m_unk0x0c = 0; - m_unk0x48 = 0; - m_unk0x4c = 0; - m_unk0x50 = 0; -} diff --git a/tools/ncc/skip.yml b/tools/ncc/skip.yml index b33cec77..0c9a6441 100644 --- a/tools/ncc/skip.yml +++ b/tools/ncc/skip.yml @@ -21,3 +21,6 @@ delta_pos: "Allow original naming from 1996" rot_mat: "Allow original naming from 1996" new_pos: "Allow original naming from 1996" new_dir: "Allow original naming from 1996" +p_AnimTreePtr: "Allow original naming from beta" +m_AnimTreePtr: "Allow original naming from beta" +m_BADuration: "Allow original naming from beta" \ No newline at end of file