Implement OrientableROI::FUN_100a46b0 (#640)

* Implement OrientableROI::FUN_100a46b0

* Fix
This commit is contained in:
Christian Semmler 2024-03-08 21:52:42 -05:00 committed by GitHub
parent 32ae9f3803
commit fb800db862
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 13 deletions

View file

@ -388,8 +388,8 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param)
p_param.SetROI(roi);
if (roi && roi->GetUnknown0x0c() == 1) {
for (OrientableROI* oroi = roi->GetUnknown0xd4(); oroi; oroi = oroi->GetUnknown0xd4()) {
roi = (LegoROI*) oroi;
for (OrientableROI* parent = roi->GetParentROI(); parent; parent = parent->GetParentROI()) {
roi = (LegoROI*) parent;
}
LegoEntity* entity = roi->GetEntity();

View file

@ -69,7 +69,7 @@ void LegoROI::configureLegoROI(int p_roiConfig)
// FUNCTION: LEGO1 0x100a81d0
LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL)
{
m_unk0xd4 = NULL;
m_parentROI = NULL;
m_name = NULL;
m_entity = NULL;
}
@ -77,7 +77,7 @@ LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL)
// FUNCTION: LEGO1 0x100a82d0
LegoROI::LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList) : ViewROI(p_renderer, p_lodList)
{
m_unk0xd4 = NULL;
m_parentROI = NULL;
m_name = NULL;
m_entity = NULL;
}
@ -124,7 +124,7 @@ LegoResult LegoROI::Read(
LegoSphere sphere;
LegoBox box;
m_unk0xd4 = p_unk0xd4;
m_parentROI = p_unk0xd4;
if (p_storage->Read(&length, sizeof(length)) != SUCCESS) {
goto done;

View file

@ -16,7 +16,7 @@ OrientableROI::OrientableROI()
ZEROVEC3(m_world_velocity);
IDENTMAT4(m_local2world);
m_unk0xd4 = NULL;
m_parentROI = NULL;
ToggleUnknown0xd8(TRUE);
}
@ -27,10 +27,36 @@ void OrientableROI::WrappedSetLocalTransform(const Matrix4& p_transform)
SetLocalTransform(p_transform);
}
// STUB: LEGO1 0x100a46b0
void OrientableROI::FUN_100a46b0(Matrix4& p_transform)
// FUNCTION: LEGO1 0x100a46b0
void OrientableROI::FUN_100a46b0(const Matrix4& p_transform)
{
// TODO
MxMatrix mat;
double local2world[4][4];
double local2parent[4][4];
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
local2world[i][j] = p_transform[i][j];
local2parent[i][j] = m_local2world[i][j];
}
}
double local_inverse[4][4];
INVERTMAT4d(local_inverse, local2parent);
double parent2world[4][4];
MXM4(parent2world, local_inverse, local2world);
unsigned int k, l;
for (k = 0; k < 4; k++) {
for (l = 0; l < 4; l++) {
mat[k][l] = parent2world[k][l];
}
}
UpdateWorldData(mat);
}
// Maybe an overload based on MxMatrix type
@ -43,7 +69,7 @@ void OrientableROI::WrappedVTable0x24(const Matrix4& p_transform)
// STUB: LEGO1 0x100a50a0
void OrientableROI::GetLocalTransform(Matrix4& p_transform)
{
// TODO
p_transform = m_local2world;
}
// FUNCTION: LEGO1 0x100a58f0

View file

@ -33,7 +33,7 @@ class OrientableROI : public ROI {
virtual void UpdateWorldVelocity(); // vtable+0x2c
void WrappedSetLocalTransform(const Matrix4& p_transform);
void FUN_100a46b0(Matrix4& p_transform);
void FUN_100a46b0(const Matrix4& p_transform);
void WrappedVTable0x24(const Matrix4& p_transform);
void GetLocalTransform(Matrix4& p_transform);
void FUN_100a58f0(const Matrix4& p_transform);
@ -43,7 +43,7 @@ class OrientableROI : public ROI {
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; }
OrientableROI* GetParentROI() const { return m_parentROI; }
void ToggleUnknown0xd8(BOOL p_enable)
{
@ -61,7 +61,7 @@ class OrientableROI : public ROI {
BoundingBox m_unk0x80; // 0x80
BoundingSphere m_world_bounding_sphere; // 0xa8
Mx3DPointFloat m_world_velocity; // 0xc0
OrientableROI* m_unk0xd4; // 0xd4
OrientableROI* m_parentROI; // 0xd4
undefined4 m_unk0xd8; // 0xd8
};