Refactor LegoUnknown100db7f4 to LegoOrientedEdge (#1515)

* Refactor `LegoUnknown100db7f4` to `LegoOrientedEdge`

* Update LEGO1/lego/sources/geom/legoorientededge.h

* Update legopathcontroller.h

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Florian Kaiser
2025-05-25 08:09:24 +02:00
committed by GitHub
parent 8e54a20d7d
commit 804632b13f
24 changed files with 158 additions and 166 deletions

View File

@@ -1,7 +1,7 @@
#include "legopathactor.h"
#include "define.h"
#include "geom/legounkown100db7f4.h"
#include "geom/legoorientededge.h"
#include "legocachesoundmanager.h"
#include "legocameracontroller.h"
#include "legonamedplane.h"
@@ -95,7 +95,7 @@ MxResult LegoPathActor::VTable0x88(
float p_time,
LegoEdge& p_srcEdge,
float p_srcScale,
LegoUnknown100db7f4& p_destEdge,
LegoOrientedEdge& p_destEdge,
float p_destScale
)
{
@@ -122,7 +122,7 @@ MxResult LegoPathActor::VTable0x88(
m_unk0x7c = 0;
m_lastTime = p_time;
m_actorTime = p_time;
p_destEdge.FUN_1002ddc0(*p_boundary, p3);
p_destEdge.GetFaceNormal(*p_boundary, p3);
p4 = p2;
p4 -= p1;
@@ -172,7 +172,7 @@ MxResult LegoPathActor::VTable0x84(
float p_time,
Vector3& p_p1,
Vector3& p_p4,
LegoUnknown100db7f4& p_destEdge,
LegoOrientedEdge& p_destEdge,
float p_destScale
)
{
@@ -192,7 +192,7 @@ MxResult LegoPathActor::VTable0x84(
m_unk0x7c = 0;
m_lastTime = p_time;
m_actorTime = p_time;
p_destEdge.FUN_1002ddc0(*p_boundary, p3);
p_destEdge.GetFaceNormal(*p_boundary, p3);
MxMatrix matrix;
Vector3 pos(matrix[3]);
@@ -442,7 +442,7 @@ void LegoPathActor::Animate(float p_time)
// FUNCTION: LEGO1 0x1002e8b0
// FUNCTION: BETA10 0x100af2f7
void LegoPathActor::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4)
void LegoPathActor::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoOrientedEdge*& p_edge, float& p_unk0xe4)
{
assert(m_boundary);
m_boundary->SwitchBoundary(this, p_boundary, p_edge, p_unk0xe4);
@@ -516,7 +516,7 @@ inline MxU32 LegoPathActor::FUN_1002edd0(
LegoS32 numEdges = p_boundary->GetNumEdges();
for (MxS32 i = 0; i < numEdges; i++) {
LegoUnknown100db7f4* edge = p_boundary->GetEdges()[i];
LegoOrientedEdge* edge = p_boundary->GetEdges()[i];
LegoPathBoundary* boundary = (LegoPathBoundary*) edge->OtherFace(p_boundary);
if (boundary != NULL) {
@@ -652,7 +652,7 @@ MxResult LegoPathActor::VTable0x9c()
LERP3(local34, v1, v2, m_unk0xe4);
m_destEdge->FUN_1002ddc0(*m_boundary, local78);
m_destEdge->GetFaceNormal(*m_boundary, local78);
local48.EqualsCross(*m_boundary->GetUnknown0x14(), local78);
local48.Unitize();
}

View File

@@ -1,7 +1,7 @@
#include "legopathboundary.h"
#include "decomp.h"
#include "geom/legounkown100db7f4.h"
#include "geom/legoorientededge.h"
#include "legolocomotionanimpresenter.h"
#include "legopathactor.h"
#include "legopathstruct.h"
@@ -86,11 +86,11 @@ void LegoPathBoundary::FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPa
void LegoPathBoundary::SwitchBoundary(
LegoPathActor* p_actor,
LegoPathBoundary*& p_boundary,
LegoUnknown100db7f4*& p_edge,
LegoOrientedEdge*& p_edge,
float& p_unk0xe4
)
{
LegoUnknown100db7f4* e = p_edge;
LegoOrientedEdge* e = p_edge;
if (p_edge->BETA_100b53b0(*p_boundary)) {
LegoPathBoundary* newBoundary = (LegoPathBoundary*) p_edge->OtherFace(p_boundary);
@@ -110,7 +110,7 @@ void LegoPathBoundary::SwitchBoundary(
}
do {
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary);
p_edge = (LegoOrientedEdge*) p_edge->GetCounterclockwiseEdge(*newBoundary);
LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(newBoundary);
if (p_edge->GetMask0x03() && (userNavFlag || p_edge->BETA_1004a830(*local20, 1))) {
@@ -133,10 +133,10 @@ void LegoPathBoundary::SwitchBoundary(
while (local8 > 0) {
if (localc) {
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary);
p_edge = (LegoOrientedEdge*) p_edge->GetCounterclockwiseEdge(*newBoundary);
}
else {
p_edge = (LegoUnknown100db7f4*) p_edge->GetClockwiseEdge(*newBoundary);
p_edge = (LegoOrientedEdge*) p_edge->GetClockwiseEdge(*newBoundary);
}
LegoPathBoundary* local20 = (LegoPathBoundary*) p_edge->OtherFace(newBoundary);
@@ -147,8 +147,8 @@ void LegoPathBoundary::SwitchBoundary(
}
if (p_edge == e) {
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary);
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*newBoundary);
p_edge = (LegoOrientedEdge*) p_edge->GetCounterclockwiseEdge(*newBoundary);
p_edge = (LegoOrientedEdge*) p_edge->GetCounterclockwiseEdge(*newBoundary);
}
if (p_boundary != newBoundary) {
@@ -162,7 +162,7 @@ void LegoPathBoundary::SwitchBoundary(
}
else {
do {
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*p_boundary);
p_edge = (LegoOrientedEdge*) p_edge->GetCounterclockwiseEdge(*p_boundary);
if (p_edge->GetMask0x03()) {
break;
@@ -170,8 +170,8 @@ void LegoPathBoundary::SwitchBoundary(
} while (p_edge != e);
if (p_edge == e) {
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*p_boundary);
p_edge = (LegoUnknown100db7f4*) p_edge->GetCounterclockwiseEdge(*p_boundary);
p_edge = (LegoOrientedEdge*) p_edge->GetCounterclockwiseEdge(*p_boundary);
p_edge = (LegoOrientedEdge*) p_edge->GetCounterclockwiseEdge(*p_boundary);
}
p_unk0xe4 = 1.0 - p_unk0xe4;
@@ -185,17 +185,17 @@ MxU32 LegoPathBoundary::Intersect(
Vector3& p_point1,
Vector3& p_point2,
Vector3& p_point3,
LegoUnknown100db7f4*& p_edge
LegoOrientedEdge*& p_edge
)
{
LegoUnknown100db7f4* e = NULL;
LegoOrientedEdge* e = NULL;
float localc;
MxU32 local10 = 0;
float len = 0.0f;
Mx3DPointFloat vec;
for (MxS32 i = 0; i < m_numEdges; i++) {
LegoUnknown100db7f4* edge = (LegoUnknown100db7f4*) m_edges[i];
LegoOrientedEdge* edge = (LegoOrientedEdge*) m_edges[i];
if (p_point2.Dot(m_edgeNormals[i], p_point2) + m_edgeNormals[i][3] <= -1e-07) {
if (local10 == 0) {
@@ -240,17 +240,17 @@ MxU32 LegoPathBoundary::Intersect(
local50 = p_point2;
local50 -= *local5c;
e->FUN_1002ddc0(*this, local70);
e->GetFaceNormal(*this, local70);
float local58 = local50.Dot(local50, local70);
LegoUnknown100db7f4* local54 = NULL;
LegoOrientedEdge* local54 = NULL;
if (local58 < 0.0f) {
Mx3DPointFloat local84;
for (LegoUnknown100db7f4* local88 = (LegoUnknown100db7f4*) e->GetClockwiseEdge(*this); e != local88;
local88 = (LegoUnknown100db7f4*) local88->GetClockwiseEdge(*this)) {
local88->FUN_1002ddc0(*this, local84);
for (LegoOrientedEdge* local88 = (LegoOrientedEdge*) e->GetClockwiseEdge(*this); e != local88;
local88 = (LegoOrientedEdge*) local88->GetClockwiseEdge(*this)) {
local88->GetFaceNormal(*this, local84);
if (local84.Dot(local84, local70) <= 0.9) {
break;
@@ -262,7 +262,7 @@ MxU32 LegoPathBoundary::Intersect(
float local8c = locala4.Dot(locala4, local84);
if (local8c > local58 && local8c < local88->m_unk0x3c) {
if (local8c > local58 && local8c < local88->m_length) {
local54 = local88;
local58 = local8c;
local70 = local84;
@@ -271,13 +271,12 @@ MxU32 LegoPathBoundary::Intersect(
}
}
else {
if (e->m_unk0x3c < local58) {
if (e->m_length < local58) {
Mx3DPointFloat localbc;
for (LegoUnknown100db7f4* locala8 = (LegoUnknown100db7f4*) e->GetCounterclockwiseEdge(*this);
e != locala8;
locala8 = (LegoUnknown100db7f4*) locala8->GetCounterclockwiseEdge(*this)) {
locala8->FUN_1002ddc0(*this, localbc);
for (LegoOrientedEdge* locala8 = (LegoOrientedEdge*) e->GetCounterclockwiseEdge(*this); e != locala8;
locala8 = (LegoOrientedEdge*) locala8->GetCounterclockwiseEdge(*this)) {
locala8->GetFaceNormal(*this, localbc);
if (localbc.Dot(localbc, local70) <= 0.9) {
break;
@@ -305,7 +304,7 @@ MxU32 LegoPathBoundary::Intersect(
if (local58 <= 0.0f) {
if (!e->GetMask0x03()) {
p_edge = (LegoUnknown100db7f4*) e->GetClockwiseEdge(*this);
p_edge = (LegoOrientedEdge*) e->GetClockwiseEdge(*this);
}
else {
p_edge = e;
@@ -314,7 +313,7 @@ MxU32 LegoPathBoundary::Intersect(
p_point3 = *local5c;
return 2;
}
else if (local58 > 0.0f && e->m_unk0x3c > local58) {
else if (local58 > 0.0f && e->m_length > local58) {
p_point3 = local70;
p_point3 *= local58;
p_point3 += *local5c;
@@ -325,7 +324,7 @@ MxU32 LegoPathBoundary::Intersect(
p_point3 = *e->CCWVertex(*this);
if (!e->GetMask0x03()) {
p_edge = (LegoUnknown100db7f4*) e->GetCounterclockwiseEdge(*this);
p_edge = (LegoOrientedEdge*) e->GetCounterclockwiseEdge(*this);
}
else {
p_edge = e;

View File

@@ -224,7 +224,7 @@ MxResult LegoPathController::PlaceActor(
float time = Timer()->GetTime();
MxResult result =
p_actor->VTable0x88(pBoundary, time, *pSrcE, p_srcScale, (LegoUnknown100db7f4&) *pDestE, p_destScale);
p_actor->VTable0x88(pBoundary, time, *pSrcE, p_srcScale, (LegoOrientedEdge&) *pDestE, p_destScale);
if (result != SUCCESS) {
assert(0);
@@ -284,15 +284,14 @@ MxResult LegoPathController::PlaceActor(
}
for (MxS32 j = 0; j < boundary->GetNumEdges(); j++) {
LegoUnknown100db7f4* edge = (LegoUnknown100db7f4*) boundary->GetEdges()[j];
LegoOrientedEdge* edge = (LegoOrientedEdge*) boundary->GetEdges()[j];
if (edge->GetMask0x03()) {
Mx3DPointFloat vec;
if (((LegoUnknown100db7f4*) edge->GetClockwiseEdge(*boundary))->FUN_1002ddc0(*boundary, vec) == SUCCESS &&
if (((LegoOrientedEdge*) edge->GetClockwiseEdge(*boundary))->GetFaceNormal(*boundary, vec) == SUCCESS &&
vec.Dot(vec, p_direction) < 0.0f) {
edge =
(LegoUnknown100db7f4*) edge->GetCounterclockwiseEdge(*boundary)->GetCounterclockwiseEdge(*boundary);
edge = (LegoOrientedEdge*) edge->GetCounterclockwiseEdge(*boundary)->GetCounterclockwiseEdge(*boundary);
}
if (!edge->GetMask0x03()) {
@@ -567,7 +566,7 @@ MxResult LegoPathController::ReadEdges(LegoStorage* p_storage)
}
edge.m_pointB = &m_unk0x10[s];
if (edge.m_flags & LegoUnknown100db7f4::c_bit3) {
if (edge.m_flags & LegoOrientedEdge::c_hasFaceA) {
if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) {
return FAILURE;
}
@@ -584,7 +583,7 @@ MxResult LegoPathController::ReadEdges(LegoStorage* p_storage)
edge.m_cwA = &m_edges[s];
}
if (edge.m_flags & LegoUnknown100db7f4::c_bit4) {
if (edge.m_flags & LegoOrientedEdge::c_hasFaceB) {
if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) {
return FAILURE;
}
@@ -601,11 +600,11 @@ MxResult LegoPathController::ReadEdges(LegoStorage* p_storage)
edge.m_cwB = &m_edges[s];
}
if (ReadVector(p_storage, edge.m_unk0x28) != SUCCESS) {
if (ReadVector(p_storage, edge.m_dir) != SUCCESS) {
return FAILURE;
}
if (p_storage->Read(&edge.m_unk0x3c, sizeof(float)) != SUCCESS) {
if (p_storage->Read(&edge.m_length, sizeof(float)) != SUCCESS) {
return FAILURE;
}
}
@@ -629,7 +628,7 @@ MxResult LegoPathController::ReadBoundaries(LegoStorage* p_storage)
boundary.m_edgeNormals = new Mx4DPointFloat[numE];
LegoUnknown100db7f4** edges = new LegoUnknown100db7f4*[numE];
LegoOrientedEdge** edges = new LegoOrientedEdge*[numE];
boundary.SetEdges(edges, numE);
for (j = 0; j < numE; j++) {
@@ -818,7 +817,7 @@ MxResult LegoPathController::FUN_10048310(
while (boundarySetItA != boundarySet.end()) {
MxU32 shouldRemove = TRUE;
LegoUnknown100db7f4* e = (*boundarySetItA)->m_edge;
LegoOrientedEdge* e = (*boundarySetItA)->m_edge;
LegoPathBoundary* b = (*boundarySetItA)->m_boundary;
assert(e && b);
@@ -935,7 +934,7 @@ MxS32 LegoPathController::FUN_1004a240(
Vector3& p_v1,
Vector3& p_v2,
float p_f1,
LegoUnknown100db7f4*& p_edge,
LegoOrientedEdge*& p_edge,
LegoPathBoundary*& p_boundary
)
{
@@ -956,7 +955,7 @@ MxS32 LegoPathController::FUN_1004a240(
p_v1 -= *p_edge->CWVertex(*p_boundary);
p_v1 *= p_f1;
p_v1 += *p_edge->CWVertex(*p_boundary);
p_edge->FUN_1002ddc0(*p_boundary, vec);
p_edge->GetFaceNormal(*p_boundary, vec);
p_v2.EqualsCross(*p_boundary->GetUnknown0x14(), vec);
return 0;
}