Refactor/Implement/Match LegoEdge (#786)

* Refactor/Implement/Match LegoEdge

* Reorder annotation

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Nathan M Gilbert 2024-04-09 05:25:24 -04:00 committed by GitHub
parent 5cf04bc3c3
commit 507cd0cff4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 103 additions and 22 deletions

View file

@ -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

View file

@ -109,7 +109,7 @@ class LegoPathActor : public LegoActor {
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

View file

@ -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;
}

View file

@ -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

View file

@ -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;

View file

@ -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 @@ class LegoWEEdge {
// LegoWEEdge::`scalar deleting destructor'
protected:
LegoU8 m_numEdges; // 0x04
Edge** m_edges; // 0x08
LegoU8 m_numEdges; // 0x04
LegoEdge** m_edges; // 0x08
};
#endif // __LEGOWEEDGE_H