Implement LegoAnimScene::FUN_1009f490 (#1032)

* Implement LegoAnimScene::FUN_1009f490

* Update legoanim.cpp

* Update legoanim.cpp

* Update legoanim.cpp
This commit is contained in:
Christian Semmler 2024-06-13 17:53:45 -04:00 committed by GitHub
parent dd1c11a933
commit e1a97cab2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 98 additions and 11 deletions

View file

@ -18,7 +18,7 @@ DECOMP_SIZE_ASSERT(LegoAnim, 0x18)
// FUNCTION: LEGO1 0x1009f000
LegoUnknownKey::LegoUnknownKey()
{
m_unk0x08 = 0;
m_z = 0.0f;
}
// FUNCTION: LEGO1 0x1009f020
@ -30,7 +30,7 @@ LegoResult LegoUnknownKey::Read(LegoStorage* p_storage)
return result;
}
result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08));
result = p_storage->Read(&m_z, sizeof(m_z));
return result == SUCCESS ? SUCCESS : result;
}
@ -136,11 +136,88 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
return result;
}
// STUB: LEGO1 0x1009f490
undefined4 LegoAnimScene::FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix)
// FUNCTION: LEGO1 0x1009f490
// FUNCTION: BETA10 0x10181a83
LegoResult LegoAnimScene::FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix)
{
// TODO
return 0;
MxMatrix localb0;
MxMatrix local4c;
Vector3 local5c(localb0[0]);
Vector3 local68(localb0[1]);
Vector3 local54(localb0[2]);
Vector3 localb8(localb0[3]);
Mx3DPointFloat localcc;
localb0.SetIdentity();
LegoU32 local60;
if (m_unk0x08 != 0) {
local60 = GetUnknown0x18();
LegoAnimNodeData::GetTranslation(m_unk0x08, m_unk0x0c, p_time, localb0, local60);
SetUnknown0x18(local60);
localcc = localb8;
localb8.Clear();
}
if (m_unk0x00 != 0) {
local60 = GetUnknown0x1c();
LegoAnimNodeData::GetTranslation(m_unk0x00, m_unk0x04, p_time, localb0, local60);
SetUnknown0x1c(local60);
}
local54 = localcc;
((Vector3&) local54).Sub(localb8);
if (local54.Unitize() == 0) {
local5c.EqualsCross(&local68, &local54);
if (local5c.Unitize() == 0) {
local68.EqualsCross(&local54, &local5c);
localcc = p_matrix[3];
((Vector3&) localcc).Add(localb0[3]);
p_matrix[3][0] = p_matrix[3][1] = p_matrix[3][2] = localb0[3][0] = localb0[3][1] = localb0[3][2] = 0;
if (m_unk0x10 != 0) {
LegoU32 locald0 = -1;
LegoU32 locald8;
locald0 = GetUnknown0x20();
LegoU32 localdc =
LegoAnimNodeData::FindKeys(p_time, m_unk0x10, m_unk0x14, sizeof(*m_unk0x14), locald8, locald0);
SetUnknown0x20(locald0);
switch (localdc) {
case 1:
p_matrix.RotateZ(m_unk0x14[locald8].GetZ());
break;
case 2:
// Seems to be unused
LegoFloat z = LegoAnimNodeData::Interpolate(
p_time,
m_unk0x14[locald8],
m_unk0x14[locald8].GetZ(),
m_unk0x14[locald8 + 1],
m_unk0x14[locald8 + 1].GetZ()
);
p_matrix.RotateZ(m_unk0x14[locald8].GetZ());
break;
}
}
local4c = p_matrix;
p_matrix.Product(local4c.GetData(), localb0.GetData());
p_matrix[3][0] = localcc[0];
p_matrix[3][1] = localcc[1];
p_matrix[3][2] = localcc[2];
}
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009f900

View file

@ -103,8 +103,10 @@ class LegoUnknownKey : public LegoAnimKey {
LegoUnknownKey();
LegoResult Read(LegoStorage* p_storage);
inline LegoFloat GetZ() { return m_z; }
protected:
undefined4 m_unk0x08; // 0x08
LegoFloat m_z; // 0x08
};
// VTABLE: LEGO1 0x100db8c8
@ -212,7 +214,15 @@ class LegoAnimScene {
LegoAnimScene();
~LegoAnimScene();
LegoResult Read(LegoStorage* p_storage);
undefined4 FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix);
LegoResult FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix);
inline LegoU32 GetUnknown0x18() { return m_unk0x18; }
inline LegoU32 GetUnknown0x1c() { return m_unk0x1c; }
inline LegoU32 GetUnknown0x20() { return m_unk0x20; }
inline void SetUnknown0x18(LegoU32 p_unk0x18) { m_unk0x18 = p_unk0x18; }
inline void SetUnknown0x1c(LegoU32 p_unk0x1c) { m_unk0x1c = p_unk0x1c; }
inline void SetUnknown0x20(LegoU32 p_unk0x20) { m_unk0x20 = p_unk0x20; }
private:
LegoU16 m_unk0x00; // 0x00
@ -221,9 +231,9 @@ class LegoAnimScene {
LegoTranslationKey* m_unk0x0c; // 0x0c
LegoU16 m_unk0x10; // 0x10
LegoUnknownKey* m_unk0x14; // 0x14
undefined4 m_unk0x18; // 0x18
undefined4 m_unk0x1c; // 0x1c
undefined4 m_unk0x20; // 0x20
LegoU32 m_unk0x18; // 0x18
LegoU32 m_unk0x1c; // 0x1c
LegoU32 m_unk0x20; // 0x20
};
// VTABLE: LEGO1 0x100db8d8