Consistent naming for Matrix

This commit is contained in:
Christian Semmler 2023-11-17 09:30:17 -05:00 committed by Nathan M Gilbert
parent bcf25e49ef
commit 981c471d42
9 changed files with 47 additions and 47 deletions

View File

@ -32,8 +32,8 @@ class Helicopter : public IslePathActor {
virtual ~Helicopter() override; // vtable+0x0 virtual ~Helicopter() override; // vtable+0x0
protected: protected:
MatrixData m_unk160; Matrix4Data m_unk160;
MatrixData m_unk1a8; Matrix4Data m_unk1a8;
undefined4 m_unk1f0; undefined4 m_unk1f0;
Vector4Data m_unk1f4; Vector4Data m_unk1f4;
Vector4Data m_unk20c; Vector4Data m_unk20c;

View File

@ -7,65 +7,65 @@
#include <memory.h> #include <memory.h>
DECOMP_SIZE_ASSERT(Matrix4, 0x40); DECOMP_SIZE_ASSERT(Matrix4, 0x40);
DECOMP_SIZE_ASSERT(MatrixImpl, 0x8); DECOMP_SIZE_ASSERT(Matrix4Impl, 0x8);
DECOMP_SIZE_ASSERT(MatrixData, 0x48); DECOMP_SIZE_ASSERT(Matrix4Data, 0x48);
// OFFSET: LEGO1 0x10002320 // OFFSET: LEGO1 0x10002320
void MatrixImpl::EqualsMatrixData(const Matrix4& p_matrix) void Matrix4Impl::EqualsMatrixData(const Matrix4& p_matrix)
{ {
*m_data = p_matrix; *m_data = p_matrix;
} }
// OFFSET: LEGO1 0x10002340 // OFFSET: LEGO1 0x10002340
void MatrixImpl::EqualsMatrixImpl(const MatrixImpl* p_other) void Matrix4Impl::EqualsMatrixImpl(const Matrix4Impl* p_other)
{ {
*m_data = *p_other->m_data; *m_data = *p_other->m_data;
} }
// OFFSET: LEGO1 0x10002360 // OFFSET: LEGO1 0x10002360
void MatrixImpl::AnotherSetData(Matrix4& p_data) void Matrix4Impl::AnotherSetData(Matrix4& p_data)
{ {
m_data = &p_data; m_data = &p_data;
} }
// OFFSET: LEGO1 0x10002370 // OFFSET: LEGO1 0x10002370
void MatrixImpl::SetData(Matrix4& p_data) void Matrix4Impl::SetData(Matrix4& p_data)
{ {
m_data = &p_data; m_data = &p_data;
} }
// OFFSET: LEGO1 0x10002380 // OFFSET: LEGO1 0x10002380
const Matrix4* MatrixImpl::GetData() const const Matrix4* Matrix4Impl::GetData() const
{ {
return m_data; return m_data;
} }
// OFFSET: LEGO1 0x10002390 // OFFSET: LEGO1 0x10002390
Matrix4* MatrixImpl::GetData() Matrix4* Matrix4Impl::GetData()
{ {
return m_data; return m_data;
} }
// OFFSET: LEGO1 0x100023a0 // OFFSET: LEGO1 0x100023a0
const float* MatrixImpl::Element(int p_row, int p_col) const const float* Matrix4Impl::Element(int p_row, int p_col) const
{ {
return &(*m_data)[p_row][p_col]; return &(*m_data)[p_row][p_col];
} }
// OFFSET: LEGO1 0x100023c0 // OFFSET: LEGO1 0x100023c0
float* MatrixImpl::Element(int p_row, int p_col) float* Matrix4Impl::Element(int p_row, int p_col)
{ {
return &(*m_data)[p_row][p_col]; return &(*m_data)[p_row][p_col];
} }
// OFFSET: LEGO1 0x100023e0 // OFFSET: LEGO1 0x100023e0
void MatrixImpl::Clear() void Matrix4Impl::Clear()
{ {
memset(m_data, 0, 16 * sizeof(float)); memset(m_data, 0, 16 * sizeof(float));
} }
// OFFSET: LEGO1 0x100023f0 // OFFSET: LEGO1 0x100023f0
void MatrixImpl::SetIdentity() void Matrix4Impl::SetIdentity()
{ {
Clear(); Clear();
(*m_data)[0][0] = 1.0f; (*m_data)[0][0] = 1.0f;
@ -75,7 +75,7 @@ void MatrixImpl::SetIdentity()
} }
// OFFSET: LEGO1 0x10002430 // OFFSET: LEGO1 0x10002430
MatrixImpl* MatrixImpl::operator+=(const Matrix4& p_matrix) Matrix4Impl* Matrix4Impl::operator+=(const Matrix4& p_matrix)
{ {
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
((float*) m_data)[i] += ((float*) &p_matrix)[i]; ((float*) m_data)[i] += ((float*) &p_matrix)[i];
@ -85,7 +85,7 @@ MatrixImpl* MatrixImpl::operator+=(const Matrix4& p_matrix)
// Matches but instructions are significantly out of order. Probably not wrong // Matches but instructions are significantly out of order. Probably not wrong
// code given that the very similar SetTranslation does match. // code given that the very similar SetTranslation does match.
// OFFSET: LEGO1 0x10002460 // OFFSET: LEGO1 0x10002460
void MatrixImpl::TranslateBy(const float* p_x, const float* p_y, const float* p_z) void Matrix4Impl::TranslateBy(const float* p_x, const float* p_y, const float* p_z)
{ {
((float*) m_data)[12] += *p_x; ((float*) m_data)[12] += *p_x;
((float*) m_data)[13] += *p_y; ((float*) m_data)[13] += *p_y;
@ -93,7 +93,7 @@ void MatrixImpl::TranslateBy(const float* p_x, const float* p_y, const float* p_
} }
// OFFSET: LEGO1 0x100024a0 // OFFSET: LEGO1 0x100024a0
void MatrixImpl::SetTranslation(const float* p_x, const float* p_y, const float* p_z) void Matrix4Impl::SetTranslation(const float* p_x, const float* p_y, const float* p_z)
{ {
(*m_data)[3][0] = *p_x; (*m_data)[3][0] = *p_x;
(*m_data)[3][1] = *p_y; (*m_data)[3][1] = *p_y;
@ -101,7 +101,7 @@ void MatrixImpl::SetTranslation(const float* p_x, const float* p_y, const float*
} }
// OFFSET: LEGO1 0x100024d0 // OFFSET: LEGO1 0x100024d0
void MatrixImpl::EqualsDataProduct(const Matrix4& p_a, const Matrix4& p_b) void Matrix4Impl::EqualsDataProduct(const Matrix4& p_a, const Matrix4& p_b)
{ {
float* cur = (float*) m_data; float* cur = (float*) m_data;
for (int row = 0; row < 4; ++row) { for (int row = 0; row < 4; ++row) {
@ -116,7 +116,7 @@ void MatrixImpl::EqualsDataProduct(const Matrix4& p_a, const Matrix4& p_b)
} }
// OFFSET: LEGO1 0x10002530 // OFFSET: LEGO1 0x10002530
void MatrixImpl::EqualsMxProduct(const MatrixImpl* p_a, const MatrixImpl* p_b) void Matrix4Impl::EqualsMxProduct(const Matrix4Impl* p_a, const Matrix4Impl* p_b)
{ {
EqualsDataProduct(*p_a->m_data, *p_b->m_data); EqualsDataProduct(*p_a->m_data, *p_b->m_data);
} }
@ -125,7 +125,7 @@ void MatrixImpl::EqualsMxProduct(const MatrixImpl* p_a, const MatrixImpl* p_b)
// be manually worked out. Included since I at least figured out what it was // be manually worked out. Included since I at least figured out what it was
// doing with rotateIndex and what overall operation it's trying to do. // doing with rotateIndex and what overall operation it's trying to do.
// OFFSET: LEGO1 0x10002550 STUB // OFFSET: LEGO1 0x10002550 STUB
void MatrixImpl::ToQuaternion(Vector4Impl* p_outQuat) void Matrix4Impl::ToQuaternion(Vector4Impl* p_outQuat)
{ {
/* /*
float trace = m_data[0] + m_data[5] + m_data[10]; float trace = m_data[0] + m_data[5] + m_data[10];
@ -168,19 +168,19 @@ void MatrixImpl::ToQuaternion(Vector4Impl* p_outQuat)
// No idea what this function is doing and it will be hard to tell until // No idea what this function is doing and it will be hard to tell until
// we have a confirmed usage site. // we have a confirmed usage site.
// OFFSET: LEGO1 0x10002710 STUB // OFFSET: LEGO1 0x10002710 STUB
int MatrixImpl::FUN_10002710(const Vector3Impl* p_vec) int Matrix4Impl::FUN_10002710(const Vector3Impl* p_vec)
{ {
return -1; return -1;
} }
// OFFSET: LEGO1 0x10002850 // OFFSET: LEGO1 0x10002850
void MatrixImpl::operator=(const MatrixImpl& p_other) void Matrix4Impl::operator=(const Matrix4Impl& p_other)
{ {
EqualsMatrixImpl(&p_other); EqualsMatrixImpl(&p_other);
} }
// OFFSET: LEGO1 0x10002860 // OFFSET: LEGO1 0x10002860
void MatrixData::operator=(const MatrixData& p_other) void Matrix4Data::operator=(const Matrix4Data& p_other)
{ {
EqualsMatrixImpl(&p_other); EqualsMatrixImpl(&p_other);
} }

View File

@ -33,12 +33,12 @@ class Matrix4 {
// VTABLE 0x100d4350 // VTABLE 0x100d4350
// SIZE 0x8 // SIZE 0x8
class MatrixImpl { class Matrix4Impl {
public: public:
inline MatrixImpl(Matrix4& p_data) : m_data(&p_data) {} inline Matrix4Impl(Matrix4& p_data) : m_data(&p_data) {}
// vtable + 0x00 // vtable + 0x00
virtual void EqualsMatrixImpl(const MatrixImpl* p_other); virtual void EqualsMatrixImpl(const Matrix4Impl* p_other);
virtual void EqualsMatrixData(const Matrix4& p_matrix); virtual void EqualsMatrixData(const Matrix4& p_matrix);
virtual void SetData(Matrix4& p_data); virtual void SetData(Matrix4& p_data);
virtual void AnotherSetData(Matrix4& p_data); virtual void AnotherSetData(Matrix4& p_data);
@ -52,13 +52,13 @@ class MatrixImpl {
// vtable + 0x20 // vtable + 0x20
virtual void Clear(); virtual void Clear();
virtual void SetIdentity(); virtual void SetIdentity();
virtual void operator=(const MatrixImpl& p_other); virtual void operator=(const Matrix4Impl& p_other);
virtual MatrixImpl* operator+=(const Matrix4& p_matrix); virtual Matrix4Impl* operator+=(const Matrix4& p_matrix);
// vtable + 0x30 // vtable + 0x30
virtual void TranslateBy(const float* p_x, const float* p_y, const float* p_z); virtual void TranslateBy(const float* p_x, const float* p_y, const float* p_z);
virtual void SetTranslation(const float* p_x, const float* p_y, const float* p_z); virtual void SetTranslation(const float* p_x, const float* p_y, const float* p_z);
virtual void EqualsMxProduct(const MatrixImpl* p_a, const MatrixImpl* p_b); virtual void EqualsMxProduct(const Matrix4Impl* p_a, const Matrix4Impl* p_b);
virtual void EqualsDataProduct(const Matrix4& p_a, const Matrix4& p_b); virtual void EqualsDataProduct(const Matrix4& p_a, const Matrix4& p_b);
// vtable + 0x40 // vtable + 0x40
@ -73,16 +73,16 @@ class MatrixImpl {
// VTABLE 0x100d4300 // VTABLE 0x100d4300
// SIZE 0x48 // SIZE 0x48
class MatrixData : public MatrixImpl { class Matrix4Data : public Matrix4Impl {
public: public:
inline MatrixData() : MatrixImpl(m) {} inline Matrix4Data() : Matrix4Impl(m) {}
inline MatrixData(MatrixData& p_other) : MatrixImpl(m) { m = *p_other.m_data; } inline Matrix4Data(Matrix4Data& p_other) : Matrix4Impl(m) { m = *p_other.m_data; }
inline Matrix4& GetMatrix() { return *m_data; } inline Matrix4& GetMatrix() { return *m_data; }
// No idea why there's another equals. Maybe to some other type like the // No idea why there's another equals. Maybe to some other type like the
// DirectX Retained Mode Matrix type which is also a float* alias? // DirectX Retained Mode Matrix type which is also a float* alias?
// vtable + 0x44 // vtable + 0x44
virtual void operator=(const MatrixData& p_other); virtual void operator=(const Matrix4Data& p_other);
Matrix4 m; Matrix4 m;
}; };

View File

@ -12,26 +12,26 @@ void OrientableROI::VTable0x1c()
} }
// OFFSET: LEGO1 0x100a5930 // OFFSET: LEGO1 0x100a5930
void OrientableROI::SetLocalTransform(const MatrixImpl& p_transform) void OrientableROI::SetLocalTransform(const Matrix4Impl& p_transform)
{ {
reinterpret_cast<MatrixImpl&>(m_local2world) = p_transform; reinterpret_cast<Matrix4Impl&>(m_local2world) = p_transform;
UpdateWorldBoundingVolumes(); UpdateWorldBoundingVolumes();
UpdateWorldVelocity(); UpdateWorldVelocity();
} }
// OFFSET: LEGO1 0x100a5960 // OFFSET: LEGO1 0x100a5960
void OrientableROI::VTable0x24(const MatrixData& p_transform) void OrientableROI::VTable0x24(const Matrix4Data& p_transform)
{ {
MatrixData l_matrix(m_local2world); Matrix4Data l_matrix(m_local2world);
m_local2world.EqualsMxProduct(&p_transform, &l_matrix); m_local2world.EqualsMxProduct(&p_transform, &l_matrix);
UpdateWorldBoundingVolumes(); UpdateWorldBoundingVolumes();
UpdateWorldVelocity(); UpdateWorldVelocity();
} }
// OFFSET: LEGO1 0x100a59b0 // OFFSET: LEGO1 0x100a59b0
void OrientableROI::UpdateWorldData(const MatrixData& p_transform) void OrientableROI::UpdateWorldData(const Matrix4Data& p_transform)
{ {
MatrixData l_matrix(m_local2world); Matrix4Data l_matrix(m_local2world);
m_local2world.EqualsMxProduct(&l_matrix, &p_transform); m_local2world.EqualsMxProduct(&l_matrix, &p_transform);
UpdateWorldBoundingVolumes(); UpdateWorldBoundingVolumes();
UpdateWorldVelocity(); UpdateWorldVelocity();

View File

@ -31,14 +31,14 @@ class OrientableROI : public ROI {
public: public:
virtual void VTable0x1c(); virtual void VTable0x1c();
// vtable + 0x20 // vtable + 0x20
virtual void SetLocalTransform(const MatrixImpl& p_transform); virtual void SetLocalTransform(const Matrix4Impl& p_transform);
virtual void VTable0x24(const MatrixData& p_transform); virtual void VTable0x24(const Matrix4Data& p_transform);
virtual void UpdateWorldData(const MatrixData& p_transform); virtual void UpdateWorldData(const Matrix4Data& p_transform);
virtual void UpdateWorldVelocity(); virtual void UpdateWorldVelocity();
protected: protected:
char m_unkc; char m_unkc;
MatrixData m_local2world; // 0x10 Matrix4Data m_local2world; // 0x10
BoundingBox m_world_bounding_box; // 0x58 BoundingBox m_world_bounding_box; // 0x58
BoundingSphere m_world_bounding_sphere; // 0xa8 BoundingSphere m_world_bounding_sphere; // 0xa8
Vector3Data m_world_velocity; // 0xc0 Vector3Data m_world_velocity; // 0xc0

View File

@ -5,7 +5,7 @@ void CalcLocalTransform(
const Vector3Impl& p_posVec, const Vector3Impl& p_posVec,
const Vector3Impl& p_dirVec, const Vector3Impl& p_dirVec,
const Vector3Impl& p_upVec, const Vector3Impl& p_upVec,
MatrixImpl& p_outMatrix Matrix4Impl& p_outMatrix
) )
{ {
float x_axis[3], y_axis[3], z_axis[3]; float x_axis[3], y_axis[3], z_axis[3];

View File

@ -13,7 +13,7 @@ void CalcLocalTransform(
const Vector3Impl& p_posVec, const Vector3Impl& p_posVec,
const Vector3Impl& p_dirVec, const Vector3Impl& p_dirVec,
const Vector3Impl& p_upVec, const Vector3Impl& p_upVec,
MatrixImpl& p_outMatrix Matrix4Impl& p_outMatrix
); );
#endif // REALTIME_H #endif // REALTIME_H

View File

@ -23,7 +23,7 @@ Tgl::Group* ViewROI::GetGeometry()
} }
// OFFSET: LEGO1 0x100a9ee0 // OFFSET: LEGO1 0x100a9ee0
void ViewROI::UpdateWorldData(const MatrixData& parent2world) void ViewROI::UpdateWorldData(const Matrix4Data& parent2world)
{ {
OrientableROI::UpdateWorldData(parent2world); OrientableROI::UpdateWorldData(parent2world);
if (geometry) { if (geometry) {

View File

@ -41,7 +41,7 @@ class ViewROI : public OrientableROI {
protected: protected:
Tgl::Group* geometry; Tgl::Group* geometry;
void UpdateWorldData(const MatrixData& parent2world); void UpdateWorldData(const Matrix4Data& parent2world);
}; };
#endif // VIEWROI_H #endif // VIEWROI_H