Improve matches in ROI classes (#608)

* Improve matches in ROI classes

* More function implementations

* Fix name

* Fix vtables

* Add annotation
This commit is contained in:
Christian Semmler 2024-03-01 12:19:41 -05:00 committed by GitHub
parent e609924e4c
commit ec29f2633d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 89 additions and 54 deletions

View file

@ -38,22 +38,6 @@ int g_roiConfig = 100;
// GLOBAL: LEGO1 0x101013ac
ROIHandler g_someHandlerFunction = NULL;
// FUNCTION: LEGO1 0x100a46a0
void LegoROI::WrappedSetLocalTransform(Matrix4& p_transform)
{
SetLocalTransform(p_transform);
}
// STUB: LEGO1 0x100a46b0
void LegoROI::FUN_100a46b0(Matrix4& p_transform)
{
}
// STUB: LEGO1 0x100a58f0
void LegoROI::FUN_100a58f0(const Matrix4& p_transform)
{
}
// FUNCTION: LEGO1 0x100a81c0
void LegoROI::configureLegoROI(int p_roiConfig)
{
@ -61,7 +45,7 @@ void LegoROI::configureLegoROI(int p_roiConfig)
}
// FUNCTION: LEGO1 0x100a81d0
LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL), m_unk0xe0(-1)
LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL)
{
m_unk0xd4 = NULL;
m_name = NULL;
@ -69,7 +53,7 @@ LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL), m_unk0x
}
// FUNCTION: LEGO1 0x100a82d0
LegoROI::LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList) : ViewROI(p_renderer, p_lodList), m_unk0xe0(-1)
LegoROI::LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList) : ViewROI(p_renderer, p_lodList)
{
m_unk0xd4 = NULL;
m_name = NULL;

View file

@ -44,10 +44,6 @@ class LegoROI : public ViewROI {
);
static unsigned char ColorAliasLookup(char* p_param, float& p_red, float& p_green, float& p_blue, float& p_other);
void WrappedSetLocalTransform(Matrix4& p_transform);
void FUN_100a46b0(Matrix4& p_transform);
void FUN_100a58f0(const Matrix4& p_transform);
inline const char* GetName() const { return m_name; }
inline LegoEntity* GetUnknown0x104() { return m_unk0x104; }
@ -57,7 +53,6 @@ class LegoROI : public ViewROI {
// LegoROI::`scalar deleting destructor'
private:
int m_unk0xe0; // 0xe0
LegoChar* m_name; // 0xe4
BoundingSphere m_sphere; // 0xe8
undefined4 m_unk0x100; // 0x100

View file

@ -19,6 +19,9 @@ class Mx3DPointFloat : public Vector3 {
inline float GetY() { return m_data[1]; }
inline float GetZ() { return m_data[2]; }
inline float& operator[](size_t idx) { return m_data[idx]; }
inline const float& operator[](size_t idx) const { return m_data[idx]; }
// FUNCTION: LEGO1 0x100343a0
inline Mx3DPointFloat(const Mx3DPointFloat& p_other) : Vector3(m_elements) { EqualsImpl(p_other.m_data); }

View file

@ -10,6 +10,9 @@ class MxMatrix : public Matrix4 {
inline MxMatrix() : Matrix4(m_elements) {}
inline MxMatrix(const MxMatrix& p_matrix) : Matrix4(m_elements) { Equals(p_matrix); }
float* operator[](size_t idx) { return m_data[idx]; }
const float* operator[](size_t idx) const { return m_data[idx]; }
// FUNCTION: LEGO1 0x10002850
void operator=(const Matrix4& p_matrix) override { Equals(p_matrix); } // vtable+0x28

View file

@ -5,6 +5,7 @@
#include "mxstl/stlcompat.h"
#include "mxtypes.h"
// SIZE 0x10
class MxTickleClient {
public:
MxTickleClient(MxCore* p_client, MxTime p_interval);
@ -33,10 +34,11 @@ class MxTickleClient {
typedef list<MxTickleClient*> MxTickleClientPtrList;
// VTABLE: LEGO1 0x100d86d8
// SIZE 0x14
class MxTickleManager : public MxCore {
public:
inline MxTickleManager() {}
~MxTickleManager() override; // vtable+0x00 (scalar deleting destructor)
~MxTickleManager() override;
MxResult Tickle() override; // vtable+0x08
virtual void RegisterClient(MxCore* p_client, MxTime p_interval); // vtable+0x14

View file

@ -16,8 +16,35 @@ OrientableROI::OrientableROI()
ZEROVEC3(m_world_velocity);
IDENTMAT4(m_local2world);
m_unk0xd4 = 0;
m_unk0xd8 |= c_bit1 | c_bit2;
m_unk0xd4 = NULL;
ToggleUnknown0xd8(TRUE);
}
// Maybe an overload based on MxMatrix type
// FUNCTION: LEGO1 0x100a46a0
void OrientableROI::WrappedSetLocalTransform(const Matrix4& p_transform)
{
SetLocalTransform(p_transform);
}
// STUB: LEGO1 0x100a46b0
void OrientableROI::FUN_100a46b0(Matrix4& p_transform)
{
// TODO
}
// Maybe an overload based on MxMatrix type
// FUNCTION: LEGO1 0x100a5090
void OrientableROI::WrappedVTable0x24(const Matrix4& p_transform)
{
VTable0x24(p_transform);
}
// FUNCTION: LEGO1 0x100a58f0
void OrientableROI::FUN_100a58f0(const Matrix4& p_transform)
{
m_local2world = p_transform;
ToggleUnknown0xd8(TRUE);
}
// FUNCTION: LEGO1 0x100a5910
@ -30,13 +57,13 @@ void OrientableROI::VTable0x1c()
// FUNCTION: LEGO1 0x100a5930
void OrientableROI::SetLocalTransform(const Matrix4& p_transform)
{
reinterpret_cast<Matrix4&>(m_local2world) = p_transform;
m_local2world = p_transform;
UpdateWorldBoundingVolumes();
UpdateWorldVelocity();
}
// FUNCTION: LEGO1 0x100a5960
void OrientableROI::VTable0x24(const MxMatrix& p_transform)
void OrientableROI::VTable0x24(const Matrix4& p_transform)
{
MxMatrix l_matrix(m_local2world);
m_local2world.Product(p_transform, l_matrix);
@ -45,7 +72,7 @@ void OrientableROI::VTable0x24(const MxMatrix& p_transform)
}
// FUNCTION: LEGO1 0x100a59b0
void OrientableROI::UpdateWorldData(const MxMatrix& p_transform)
void OrientableROI::UpdateWorldData(const Matrix4& p_transform)
{
MxMatrix l_matrix(m_local2world);
m_local2world.Product(l_matrix, p_transform);
@ -61,6 +88,12 @@ void OrientableROI::UpdateWorldData(const MxMatrix& p_transform)
}
}
// FUNCTION: LEGO1 0x100a5a30
void OrientableROI::FUN_100a5a30(const Vector3& p_world_velocity)
{
m_world_velocity = p_world_velocity;
}
// FUNCTION: LEGO1 0x100a5a50
void OrientableROI::UpdateWorldVelocity()
{

View file

@ -5,6 +5,8 @@
#include "mxgeometry/mxmatrix.h"
#include "roi.h"
#include <windows.h>
// VTABLE: LEGO1 0x100dbc08
// SIZE 0xdc
class OrientableROI : public ROI {
@ -19,32 +21,43 @@ class OrientableROI : public ROI {
const float* GetWorldVelocity() const override; // vtable+0x08
const BoundingBox& GetWorldBoundingBox() const override; // vtable+0x0c
const BoundingSphere& GetWorldBoundingSphere() const override; // vtable+0x10
// FUNCTION: LEGO1 0x100a5db0
virtual void VTable0x14() { VTable0x1c(); } // vtable+0x14
virtual void UpdateWorldBoundingVolumes() = 0; // vtable+0x18
virtual void VTable0x1c(); // vtable+0x1c
virtual void SetLocalTransform(const Matrix4& p_transform); // vtable+0x20
virtual void VTable0x24(const MxMatrix& p_transform); // vtable+0x24
virtual void UpdateWorldData(const MxMatrix& p_transform); // vtable+0x28
virtual void VTable0x24(const Matrix4& p_transform); // vtable+0x24
virtual void UpdateWorldData(const Matrix4& p_transform); // vtable+0x28
virtual void UpdateWorldVelocity(); // vtable+0x2c
void WrappedSetLocalTransform(const Matrix4& p_transform);
void FUN_100a46b0(Matrix4& p_transform);
void WrappedVTable0x24(const Matrix4& p_transform);
void FUN_100a58f0(const Matrix4& p_transform);
void FUN_100a5a30(const Vector3& p_world_velocity);
const MxMatrix& GetLocal2World() const { return m_local2world; }
const float* GetWorldPosition() const { return m_local2world[3]; }
const float* GetWorldDirection() const { return m_local2world[2]; }
const float* GetWorldUp() const { return m_local2world[1]; }
OrientableROI* GetUnknown0xd4() const { return m_unk0xd4; }
void ToggleUnknown0xd8(BOOL p_enable)
{
if (p_enable) {
m_unk0xd8 |= c_bit1 | c_bit2;
}
else {
m_unk0xd8 &= ~c_bit1;
}
}
protected:
MxMatrix m_local2world; // 0x10
BoundingBox m_world_bounding_box; // 0x58
// Unclear whether the following vectors are:
// 1) Part of m_world_bounding_box;
// 2) A second BoundingBox;
// 3) Standalone vectors
Mx3DPointFloat m_unk0x80; // 0x80
Mx3DPointFloat m_unk0x94; // 0x94
BoundingBox m_unk0x80; // 0x80
BoundingSphere m_world_bounding_sphere; // 0xa8
Mx3DPointFloat m_world_velocity; // 0xc0
OrientableROI* m_unk0xd4; // 0xd4

View file

@ -15,10 +15,10 @@
// SIZE 0x28
class BoundingBox {
public:
const Mx3DPointFloat& Min() const { return min; }
Mx3DPointFloat& Min() { return min; }
const Mx3DPointFloat& Max() const { return max; }
Mx3DPointFloat& Max() { return max; }
const Vector3& Min() const { return min; }
Vector3& Min() { return min; }
const Vector3& Max() const { return max; }
Vector3& Max() { return max; }
private:
Mx3DPointFloat min; // 0x00
@ -31,8 +31,8 @@ class BoundingBox {
// SIZE 0x18
class BoundingSphere {
public:
const Mx3DPointFloat& Center() const { return center; }
Mx3DPointFloat& Center() { return center; }
const Vector3& Center() const { return center; }
Vector3& Center() { return center; }
const float& Radius() const { return radius; }
float& Radius() { return radius; }

View file

@ -4,7 +4,7 @@
#include <vec.h>
DECOMP_SIZE_ASSERT(ViewROI, 0xe0)
DECOMP_SIZE_ASSERT(ViewROI, 0xe4)
// GLOBAL: LEGO1 0x101013d8
undefined g_unk101013d8 = 0;
@ -28,7 +28,7 @@ Tgl::Group* ViewROI::GetGeometry()
}
// FUNCTION: LEGO1 0x100a9ee0
void ViewROI::UpdateWorldData(const MxMatrix& parent2world)
void ViewROI::UpdateWorldData(const Matrix4& parent2world)
{
OrientableROI::UpdateWorldData(parent2world);
@ -42,7 +42,7 @@ void ViewROI::UpdateWorldData(const MxMatrix& parent2world)
}
// STUB: LEGO1 0x100a9fc0
void ViewROI::VTable0x24(const MxMatrix& p_transform)
void ViewROI::VTable0x24(const Matrix4& p_transform)
{
// TODO
}

View file

@ -13,13 +13,14 @@
*/
// VTABLE: LEGO1 0x100dbe70
// SIZE 0xe0
// SIZE 0xe4
class ViewROI : public OrientableROI {
public:
inline ViewROI(Tgl::Renderer* pRenderer, ViewLODList* lodList)
{
SetLODList(lodList);
geometry = pRenderer->CreateGroup();
m_unk0xe0 = -1;
}
// FUNCTION: LEGO1 0x100a9e20
@ -51,16 +52,17 @@ class ViewROI : public OrientableROI {
float IntrinsicImportance() const override; // vtable+0x04
void VTable0x1c() override; // vtable+0x1c
void SetLocalTransform(const Matrix4& p_transform) override; // vtable+0x20
void VTable0x24(const MxMatrix& p_transform) override; // vtable+0x24
void VTable0x24(const Matrix4& p_transform) override; // vtable+0x24
virtual const Tgl::Group* GetGeometry() const; // vtable+0x34
virtual Tgl::Group* GetGeometry(); // vtable+0x30
static undefined SetUnk101013d8(undefined p_flag);
protected:
void UpdateWorldData(const MxMatrix& parent2world) override;
void UpdateWorldData(const Matrix4& parent2world) override; // vtable+0x28
Tgl::Group* geometry; // 0xdc
int m_unk0xe0; // 0xe0
};
// SYNTHETIC: LEGO1 0x100aa250