mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 00:14:22 +00:00
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:
@@ -17,7 +17,7 @@ struct LegoEdge {
|
||||
Vector3* CWVertex(LegoWEEdge& p_face);
|
||||
Vector3* CCWVertex(LegoWEEdge& p_face);
|
||||
|
||||
LegoResult FUN_1002ddc0(LegoWEEdge& p_face, Vector3& p_point);
|
||||
LegoResult GetFaceNormal(LegoWEEdge& p_face, Vector3& p_point);
|
||||
|
||||
// FUNCTION: BETA10 0x10184170
|
||||
LegoWEEdge* GetFaceA() { return m_faceA; }
|
||||
|
12
LEGO1/lego/sources/geom/legoorientededge.cpp
Normal file
12
LEGO1/lego/sources/geom/legoorientededge.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "legoorientededge.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoOrientedEdge, 0x40)
|
||||
|
||||
// FUNCTION: LEGO1 0x1009a630
|
||||
// FUNCTION: BETA10 0x10183050
|
||||
LegoOrientedEdge::LegoOrientedEdge()
|
||||
{
|
||||
m_flags = 0;
|
||||
m_dir.Clear();
|
||||
m_length = 0.0f;
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
#ifndef __LEGOUNKNOWN100DB7F4_H
|
||||
#define __LEGOUNKNOWN100DB7F4_H
|
||||
#ifndef __LEGOORIENTEDEDGE_H
|
||||
#define __LEGOORIENTEDEDGE_H
|
||||
|
||||
#include "legoedge.h"
|
||||
#include "legowegedge.h"
|
||||
@@ -9,31 +9,31 @@
|
||||
|
||||
// VTABLE: LEGO1 0x100db7f4
|
||||
// SIZE 0x40
|
||||
struct LegoUnknown100db7f4 : public LegoEdge {
|
||||
struct LegoOrientedEdge : public LegoEdge {
|
||||
public:
|
||||
enum {
|
||||
c_bit1 = 0x01,
|
||||
c_bit2 = 0x02,
|
||||
c_bit3 = 0x04,
|
||||
c_bit4 = 0x08
|
||||
c_hasFaceA = 0x04,
|
||||
c_hasFaceB = 0x08
|
||||
};
|
||||
|
||||
LegoUnknown100db7f4();
|
||||
LegoOrientedEdge();
|
||||
|
||||
// FUNCTION: LEGO1 0x1002ddc0
|
||||
// FUNCTION: BETA10 0x100372a0
|
||||
LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point) const
|
||||
LegoResult GetFaceNormal(LegoWEEdge& p_face, Vector3& p_point) const
|
||||
{
|
||||
if (p_f.IsEqual(m_faceA)) {
|
||||
p_point[0] = -m_unk0x28[0];
|
||||
p_point[1] = -m_unk0x28[1];
|
||||
p_point[2] = -m_unk0x28[2];
|
||||
if (p_face.IsEqual(m_faceA)) {
|
||||
p_point[0] = -m_dir[0];
|
||||
p_point[1] = -m_dir[1];
|
||||
p_point[2] = -m_dir[2];
|
||||
}
|
||||
else {
|
||||
// clang-format off
|
||||
assert(p_f.IsEqual( m_faceB ));
|
||||
assert(p_face.IsEqual( m_faceB ));
|
||||
// clang-format on
|
||||
p_point = m_unk0x28;
|
||||
p_point = m_dir;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x100bd540
|
||||
LegoFloat DistanceBetweenMidpoints(const LegoUnknown100db7f4& p_other)
|
||||
LegoFloat DistanceBetweenMidpoints(const LegoOrientedEdge& p_other)
|
||||
{
|
||||
Mx3DPointFloat point1(*m_pointA);
|
||||
Mx3DPointFloat point2(*p_other.m_pointA);
|
||||
@@ -99,22 +99,22 @@ public:
|
||||
inline LegoU32 FUN_10048c40(const Vector3& p_position);
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1009a6c0
|
||||
// LegoUnknown100db7f4::`scalar deleting destructor'
|
||||
// LegoOrientedEdge::`scalar deleting destructor'
|
||||
|
||||
LegoU16 m_flags; // 0x24
|
||||
Mx3DPointFloat m_unk0x28; // 0x28
|
||||
float m_unk0x3c; // 0x3c
|
||||
LegoU16 m_flags; // 0x24
|
||||
Mx3DPointFloat m_dir; // 0x28
|
||||
float m_length; // 0x3c
|
||||
};
|
||||
|
||||
// FUNCTION: LEGO1 0x10048c40
|
||||
// FUNCTION: BETA10 0x1001cc90
|
||||
inline LegoU32 LegoUnknown100db7f4::FUN_10048c40(const Vector3& p_position)
|
||||
inline LegoU32 LegoOrientedEdge::FUN_10048c40(const Vector3& p_position)
|
||||
{
|
||||
LegoFloat localc, local10;
|
||||
LegoU32 result = FALSE;
|
||||
|
||||
if (m_unk0x28[0] > 0.001 || m_unk0x28[0] < -0.001) {
|
||||
localc = (p_position[0] - (*m_pointA)[0]) / m_unk0x28[0];
|
||||
if (m_dir[0] > 0.001 || m_dir[0] < -0.001) {
|
||||
localc = (p_position[0] - (*m_pointA)[0]) / m_dir[0];
|
||||
|
||||
if (localc < 0 || localc > 1) {
|
||||
return FALSE;
|
||||
@@ -128,8 +128,8 @@ inline LegoU32 LegoUnknown100db7f4::FUN_10048c40(const Vector3& p_position)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_unk0x28[1] > 0.001 || m_unk0x28[1] < -0.001) {
|
||||
local10 = (p_position[1] - (*m_pointA)[1]) / m_unk0x28[1];
|
||||
if (m_dir[1] > 0.001 || m_dir[1] < -0.001) {
|
||||
local10 = (p_position[1] - (*m_pointA)[1]) / m_dir[1];
|
||||
|
||||
if (result) {
|
||||
if (localc > local10 + 0.001 || localc < local10 - 0.001) {
|
||||
@@ -147,8 +147,8 @@ inline LegoU32 LegoUnknown100db7f4::FUN_10048c40(const Vector3& p_position)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_unk0x28[2] > 0.001 || m_unk0x28[2] < -0.001) {
|
||||
local10 = (p_position[2] - (*m_pointA)[2]) / m_unk0x28[2];
|
||||
if (m_dir[2] > 0.001 || m_dir[2] < -0.001) {
|
||||
local10 = (p_position[2] - (*m_pointA)[2]) / m_dir[2];
|
||||
|
||||
if (result) {
|
||||
if (localc > local10 + 0.001 || localc < local10 - 0.001) {
|
||||
@@ -168,4 +168,4 @@ inline LegoU32 LegoUnknown100db7f4::FUN_10048c40(const Vector3& p_position)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif // __LEGOUNKNOWN100DB7F4_H
|
||||
#endif // __LEGOORIENTEDEDGE_H
|
@@ -1,12 +0,0 @@
|
||||
#include "legounkown100db7f4.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoUnknown100db7f4, 0x40)
|
||||
|
||||
// FUNCTION: LEGO1 0x1009a630
|
||||
// FUNCTION: BETA10 0x10183050
|
||||
LegoUnknown100db7f4::LegoUnknown100db7f4()
|
||||
{
|
||||
m_flags = 0;
|
||||
m_unk0x28.Clear();
|
||||
m_unk0x3c = 0.0f;
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "legoweedge.h"
|
||||
|
||||
#include "legounkown100db7f4.h"
|
||||
#include "legoorientededge.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoWEEdge, 0x0c)
|
||||
|
||||
@@ -23,8 +23,8 @@ LegoWEEdge::~LegoWEEdge()
|
||||
LegoS32 LegoWEEdge::VTable0x04()
|
||||
{
|
||||
for (LegoS32 i = 0; i < m_numEdges; i++) {
|
||||
LegoUnknown100db7f4* e1 = m_edges[i];
|
||||
LegoUnknown100db7f4* e2 = (m_numEdges - i) == 1 ? m_edges[0] : m_edges[i + 1];
|
||||
LegoOrientedEdge* e1 = m_edges[i];
|
||||
LegoOrientedEdge* e2 = (m_numEdges - i) == 1 ? m_edges[0] : m_edges[i + 1];
|
||||
|
||||
if (e2->m_pointA == e1->m_pointA) {
|
||||
e1->m_faceA = this;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include "decomp.h"
|
||||
#include "misc/legotypes.h"
|
||||
|
||||
struct LegoUnknown100db7f4;
|
||||
struct LegoOrientedEdge;
|
||||
|
||||
// might be a struct with public members
|
||||
// VTABLE: LEGO1 0x100db7c0
|
||||
@@ -20,12 +20,12 @@ public:
|
||||
LegoU8 GetNumEdges() { return m_numEdges; }
|
||||
|
||||
// FUNCTION: BETA10 0x1001cc30
|
||||
LegoUnknown100db7f4** GetEdges() { return m_edges; }
|
||||
LegoOrientedEdge** GetEdges() { return m_edges; }
|
||||
|
||||
// FUNCTION: BETA10 0x100373f0
|
||||
LegoU32 IsEqual(LegoWEEdge* p_other) { return this == p_other; }
|
||||
|
||||
void SetEdges(LegoUnknown100db7f4** p_edges, LegoU8 p_numEdges)
|
||||
void SetEdges(LegoOrientedEdge** p_edges, LegoU8 p_numEdges)
|
||||
{
|
||||
m_edges = p_edges;
|
||||
m_numEdges = p_numEdges;
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
// LegoWEEdge::`scalar deleting destructor'
|
||||
|
||||
protected:
|
||||
LegoU8 m_numEdges; // 0x04
|
||||
LegoUnknown100db7f4** m_edges; // 0x08
|
||||
LegoU8 m_numEdges; // 0x04
|
||||
LegoOrientedEdge** m_edges; // 0x08
|
||||
};
|
||||
|
||||
#endif // __LEGOWEEDGE_H
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "legowegedge.h"
|
||||
|
||||
#include "legounkown100db7f4.h"
|
||||
#include "legoorientededge.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -81,7 +81,7 @@ LegoS32 LegoWEGEdge::VTable0x04()
|
||||
m_edgeNormals = new Mx4DPointFloat[m_numEdges];
|
||||
assert(m_edgeNormals);
|
||||
|
||||
LegoUnknown100db7f4* edge;
|
||||
LegoOrientedEdge* edge;
|
||||
LegoS32 i;
|
||||
|
||||
for (i = 0; i < m_numEdges; i++) {
|
||||
@@ -118,27 +118,27 @@ LegoS32 LegoWEGEdge::VTable0x04()
|
||||
|
||||
for (i = 0; i < m_numEdges; i++) {
|
||||
edge = m_edges[i];
|
||||
Vector3& local5c = edge->m_unk0x28;
|
||||
Vector3& local5c = edge->m_dir;
|
||||
|
||||
if (edge->m_unk0x3c == 0) {
|
||||
if (edge->m_length == 0) {
|
||||
local5c = *m_edges[i]->m_pointB;
|
||||
local5c -= *m_edges[i]->m_pointA;
|
||||
edge->m_unk0x3c = local5c.LenSquared();
|
||||
edge->m_length = local5c.LenSquared();
|
||||
|
||||
if (edge->m_unk0x3c <= 0.0f) {
|
||||
if (edge->m_length <= 0.0f) {
|
||||
assert(0);
|
||||
if (result == 0) {
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
|
||||
edge->m_unk0x3c = sqrt((double) edge->m_unk0x3c);
|
||||
local5c /= edge->m_unk0x3c;
|
||||
edge->m_length = sqrt((double) edge->m_length);
|
||||
local5c /= edge->m_length;
|
||||
}
|
||||
|
||||
Mx3DPointFloat local58;
|
||||
Vector3 local64(&m_edgeNormals[i][0]);
|
||||
edge->FUN_1002ddc0(*this, local58);
|
||||
edge->GetFaceNormal(*this, local58);
|
||||
local64.EqualsCross(local58, m_unk0x14);
|
||||
|
||||
m_edgeNormals[i][3] = -local64.Dot(*m_edges[i]->m_pointA, local64);
|
||||
@@ -147,7 +147,7 @@ LegoS32 LegoWEGEdge::VTable0x04()
|
||||
}
|
||||
|
||||
if (edge->GetFaceA() != NULL && edge->GetFaceB() != NULL) {
|
||||
edge->SetFlags(LegoUnknown100db7f4::c_bit1 | LegoUnknown100db7f4::c_bit2);
|
||||
edge->SetFlags(LegoOrientedEdge::c_bit1 | LegoOrientedEdge::c_bit2);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user