Implement LegoROI::Read and geom library (#627)

* Implement LegoROI::Read and geom library

* Match

* Match

* Fixes

* Fix
This commit is contained in:
Christian Semmler
2024-03-05 12:38:53 -05:00
committed by GitHub
parent ec1fcce08c
commit f6e44b1c1b
12 changed files with 451 additions and 28 deletions

View File

@@ -0,0 +1,19 @@
#include "legobox.h"
#include "decomp.h"
#include "misc/legoutil.h"
DECOMP_SIZE_ASSERT(LegoBox, 0x18)
// FUNCTION: LEGO1 0x100d3740
LegoResult LegoBox::Read(LegoStorage* p_storage)
{
LegoResult result;
if ((result = m_min.Read(p_storage)) != SUCCESS) {
return result;
}
if ((result = m_max.Read(p_storage)) != SUCCESS) {
return result;
}
return SUCCESS;
}

View File

@@ -0,0 +1,32 @@
#ifndef __LEGOBOX_H
#define __LEGOBOX_H
#include "legovertex.h"
// SIZE 0x18
class LegoBox {
public:
LegoVertex& GetMin() { return m_min; }
void SetMin(LegoVertex& p_min) { m_min = p_min; }
LegoVertex& GetMax() { return m_max; }
void SetMax(LegoVertex& p_max) { m_max = p_max; }
// LegoVertex GetCenter()
// {
// return LegoVertex(
// (m_min.GetX() + m_max.GetX()) / 2,
// (m_min.GetY() + m_max.GetY()) / 2,
// (m_min.GetZ() + m_max.GetZ()) / 2
// );
// }
LegoFloat GetDX() { return m_max.GetX() - m_min.GetX(); }
LegoFloat GetDY() { return m_max.GetY() - m_min.GetY(); }
LegoFloat GetDZ() { return m_max.GetZ() - m_min.GetZ(); }
LegoBool IsEmpty() { return m_min.IsOrigin() && m_max.IsOrigin(); }
LegoResult Read(LegoStorage* p_storage);
protected:
LegoVertex m_min; // 0x00
LegoVertex m_max; // 0x0c
};
#endif // __LEGOBOX_H

View File

@@ -0,0 +1,19 @@
#include "legosphere.h"
#include "decomp.h"
#include "misc/legostorage.h"
DECOMP_SIZE_ASSERT(LegoSphere, 0x10)
// FUNCTION: LEGO1 0x100d3770
LegoResult LegoSphere::Read(LegoStorage* p_storage)
{
LegoResult result;
if ((result = m_center.Read(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_radius, sizeof(m_radius))) != SUCCESS) {
return result;
}
return SUCCESS;
}

View File

@@ -0,0 +1,21 @@
#ifndef __LEGOSPHERE_H
#define __LEGOSPHERE_H
#include "legovertex.h"
// SIZE 0x10
class LegoSphere {
public:
LegoSphere() { m_radius = 0.0F; }
LegoVertex& GetCenter() { return m_center; }
void SetCenter(LegoVertex& p_center) { m_center = p_center; }
LegoFloat GetRadius() { return m_radius; }
void SetRadius(LegoFloat p_radius) { m_radius = p_radius; }
LegoResult Read(LegoStorage* p_storage);
protected:
LegoVertex m_center; // 0x00
LegoFloat m_radius; // 0x0c
};
#endif // __LEGOSPHERE_H

View File

@@ -0,0 +1,30 @@
#include "legovertex.h"
#include "decomp.h"
#include "misc/legostorage.h"
DECOMP_SIZE_ASSERT(LegoVertex, 0x0c)
// FUNCTION: LEGO1 0x100d37b0
LegoVertex::LegoVertex()
{
m_coordinates[0] = 0.0F;
m_coordinates[1] = 0.0F;
m_coordinates[2] = 0.0F;
}
// FUNCTION: LEGO1 0x100d37c0
LegoResult LegoVertex::Read(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Read(&m_coordinates[0], sizeof(m_coordinates[0]))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_coordinates[1], sizeof(m_coordinates[1]))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_coordinates[2], sizeof(m_coordinates[2]))) != SUCCESS) {
return result;
}
return SUCCESS;
}

View File

@@ -0,0 +1,30 @@
#ifndef __LEGOVERTEX_H
#define __LEGOVERTEX_H
#include "misc/legotypes.h"
class LegoStorage;
// SIZE 0x0c
class LegoVertex {
public:
LegoVertex();
LegoFloat GetCoordinate(LegoU32 p_i) { return m_coordinates[p_i]; }
void SetCoordinate(LegoU32 p_i, LegoFloat p_coordinate) { m_coordinates[p_i] = p_coordinate; }
LegoFloat GetX() { return m_coordinates[0]; }
void SetX(LegoFloat p_x) { m_coordinates[0] = p_x; }
LegoFloat GetY() { return m_coordinates[1]; }
void SetY(LegoFloat p_y) { m_coordinates[1] = p_y; }
LegoFloat GetZ() { return m_coordinates[2]; }
void SetZ(LegoFloat p_z) { m_coordinates[2] = p_z; }
LegoBool IsOrigin() { return m_coordinates[0] == 0.0 && m_coordinates[1] == 0.0 && m_coordinates[2] == 0.0; }
LegoResult Read(LegoStorage* p_storage);
LegoFloat& operator[](int i) { return m_coordinates[i]; }
LegoFloat operator[](int i) const { return m_coordinates[i]; }
protected:
LegoFloat m_coordinates[3]; // 0x00
};
#endif // __LEGOVERTEX_H