mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 00:14:22 +00:00
Clear unknowns in LegoAnimPresenter
and related classes (#1565)
* Clear unknowns in `LegoAnimPresenter` and related classes * Update LEGO1/lego/legoomni/include/legoanimpresenter.h --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
@@ -348,7 +348,7 @@ LegoResult LegoTranslationKey::Read(LegoStorage* p_storage)
|
||||
}
|
||||
|
||||
if (m_x > 1e-05F || m_x < -1e-05F || m_y > 1e-05F || m_y < -1e-05F || m_z > 1e-05F || m_z < -1e-05F) {
|
||||
m_flags |= c_bit1;
|
||||
m_flags |= c_active;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
@@ -415,7 +415,7 @@ LegoResult LegoRotationKey::Read(LegoStorage* p_storage)
|
||||
}
|
||||
|
||||
if (m_angle != 1.0F) {
|
||||
m_flags |= c_bit1;
|
||||
m_flags |= c_active;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
@@ -480,7 +480,7 @@ LegoResult LegoScaleKey::Read(LegoStorage* p_storage)
|
||||
}
|
||||
|
||||
if (m_x > 1.00001 || m_x < 0.99999 || m_y > 1.00001 || m_y < 0.99999 || m_z > 1.00001 || m_z < 0.99999) {
|
||||
m_flags |= c_bit1;
|
||||
m_flags |= c_active;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
@@ -522,7 +522,7 @@ LegoAnimNodeData::LegoAnimNodeData()
|
||||
|
||||
m_name = NULL;
|
||||
m_translationKeys = NULL;
|
||||
m_unk0x20 = 0;
|
||||
m_roiIndex = 0;
|
||||
m_rotationKeys = NULL;
|
||||
m_unk0x22 = 0;
|
||||
m_scaleKeys = NULL;
|
||||
@@ -785,7 +785,7 @@ inline void LegoAnimNodeData::GetTranslation(
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
if (!p_translationKeys[i].TestBit1()) {
|
||||
if (!p_translationKeys[i].IsActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -794,7 +794,7 @@ inline void LegoAnimNodeData::GetTranslation(
|
||||
z = p_translationKeys[i].GetZ();
|
||||
break;
|
||||
case 2:
|
||||
if (!p_translationKeys[i].TestBit1() && !p_translationKeys[i + 1].TestBit1()) {
|
||||
if (!p_translationKeys[i].IsActive() && !p_translationKeys[i + 1].IsActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -841,7 +841,7 @@ inline void LegoAnimNodeData::GetTranslation(
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
if (p_rotationKeys[i].TestBit1()) {
|
||||
if (p_rotationKeys[i].IsActive()) {
|
||||
p_matrix.FromQuaternion(Mx4DPointFloat(
|
||||
p_rotationKeys[i].GetX(),
|
||||
p_rotationKeys[i].GetY(),
|
||||
@@ -854,19 +854,19 @@ inline void LegoAnimNodeData::GetTranslation(
|
||||
Mx4DPointFloat a;
|
||||
MxQuaternionTransformer b;
|
||||
|
||||
if (p_rotationKeys[i].TestBit1() || p_rotationKeys[i + 1].TestBit1()) {
|
||||
if (p_rotationKeys[i].IsActive() || p_rotationKeys[i + 1].IsActive()) {
|
||||
a[0] = p_rotationKeys[i].GetX();
|
||||
a[1] = p_rotationKeys[i].GetY();
|
||||
a[2] = p_rotationKeys[i].GetZ();
|
||||
a[3] = p_rotationKeys[i].GetAngle();
|
||||
|
||||
if (p_rotationKeys[i + 1].TestBit3()) {
|
||||
if (p_rotationKeys[i + 1].ShouldSkipInterpolation()) {
|
||||
p_matrix.FromQuaternion(a);
|
||||
return;
|
||||
}
|
||||
|
||||
Mx4DPointFloat c;
|
||||
if (p_rotationKeys[i + 1].TestBit2()) {
|
||||
if (p_rotationKeys[i + 1].ShouldNegateRotation()) {
|
||||
c[0] = -p_rotationKeys[i + 1].GetX();
|
||||
c[1] = -p_rotationKeys[i + 1].GetY();
|
||||
c[2] = -p_rotationKeys[i + 1].GetZ();
|
||||
@@ -920,7 +920,7 @@ inline void LegoAnimNodeData::GetScale(
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a0990
|
||||
LegoBool LegoAnimNodeData::FUN_100a0990(LegoFloat p_time)
|
||||
LegoBool LegoAnimNodeData::GetVisibility(LegoFloat p_time)
|
||||
{
|
||||
LegoU32 i, n;
|
||||
LegoU32 index = GetMorphIndex();
|
||||
@@ -935,7 +935,7 @@ LegoBool LegoAnimNodeData::FUN_100a0990(LegoFloat p_time)
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
result = m_morphKeys[i].GetUnknown0x08();
|
||||
result = m_morphKeys[i].IsVisible();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@ undefined4 LegoAnim::GetActorUnknown0x04(LegoU32 p_index)
|
||||
// FUNCTION: BETA10 0x1018027c
|
||||
LegoMorphKey::LegoMorphKey()
|
||||
{
|
||||
m_unk0x08 = 0;
|
||||
m_visible = FALSE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a0f70
|
||||
@@ -1183,7 +1183,7 @@ LegoResult LegoMorphKey::Read(LegoStorage* p_storage)
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result = p_storage->Read(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) {
|
||||
if ((result = p_storage->Read(&m_visible, sizeof(LegoU8))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1200,7 +1200,7 @@ LegoResult LegoMorphKey::Write(LegoStorage* p_storage)
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result = p_storage->Write(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) {
|
||||
if ((result = p_storage->Write(&m_visible, sizeof(LegoU8))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -11,9 +11,9 @@ class Matrix4;
|
||||
class LegoAnimKey {
|
||||
public:
|
||||
enum Flags {
|
||||
c_bit1 = 0x01,
|
||||
c_bit2 = 0x02,
|
||||
c_bit3 = 0x04
|
||||
c_active = 0x01,
|
||||
c_negateRotation = 0x02,
|
||||
c_skipInterpolation = 0x04
|
||||
};
|
||||
|
||||
LegoAnimKey();
|
||||
@@ -25,18 +25,18 @@ public:
|
||||
// FUNCTION: BETA10 0x100738a0
|
||||
void SetTime(MxS32 p_time) { m_time = p_time; }
|
||||
|
||||
LegoU32 TestBit1() { return m_flags & c_bit1; }
|
||||
LegoU32 TestBit2() { return m_flags & c_bit2; }
|
||||
LegoU32 TestBit3() { return m_flags & c_bit3; }
|
||||
LegoU32 IsActive() { return m_flags & c_active; }
|
||||
LegoU32 ShouldNegateRotation() { return m_flags & c_negateRotation; }
|
||||
LegoU32 ShouldSkipInterpolation() { return m_flags & c_skipInterpolation; }
|
||||
|
||||
// FUNCTION: BETA10 0x100739a0
|
||||
void FUN_100739a0(MxS32 p_param)
|
||||
{
|
||||
if (p_param) {
|
||||
m_flags |= c_bit1;
|
||||
m_flags |= c_active;
|
||||
}
|
||||
else {
|
||||
m_flags &= ~c_bit1;
|
||||
m_flags &= ~c_active;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,13 +127,13 @@ public:
|
||||
LegoMorphKey();
|
||||
LegoResult Read(LegoStorage* p_storage);
|
||||
LegoResult Write(LegoStorage* p_storage);
|
||||
LegoBool GetUnknown0x08() { return m_unk0x08; }
|
||||
LegoBool IsVisible() { return m_visible; }
|
||||
|
||||
// FUNCTION: BETA10 0x100738d0
|
||||
void SetUnknown0x08(LegoBool p_unk0x08) { m_unk0x08 = p_unk0x08; }
|
||||
void SetVisible(LegoBool p_visible) { m_visible = p_visible; }
|
||||
|
||||
protected:
|
||||
LegoBool m_unk0x08; // 0x08
|
||||
LegoBool m_visible; // 0x08
|
||||
};
|
||||
|
||||
// SIZE 0x0c
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
|
||||
void SetName(LegoChar* p_name);
|
||||
LegoResult CreateLocalTransform(LegoFloat p_time, Matrix4& p_matrix);
|
||||
LegoBool FUN_100a0990(LegoFloat p_time);
|
||||
LegoBool GetVisibility(LegoFloat p_time);
|
||||
|
||||
// FUNCTION: BETA10 0x100595d0
|
||||
LegoChar* GetName() { return m_name; }
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
LegoU32 GetMorphIndex() { return m_morphIndex; }
|
||||
|
||||
// FUNCTION: BETA10 0x1005abc0
|
||||
LegoU16 GetUnknown0x20() { return m_unk0x20; }
|
||||
LegoU16 GetROIIndex() { return m_roiIndex; }
|
||||
|
||||
// FUNCTION: BETA10 0x1005d5c0
|
||||
LegoU16 GetUnknown0x22() { return m_unk0x22; }
|
||||
@@ -214,7 +214,7 @@ public:
|
||||
void SetNumMorphKeys(LegoU16 p_numMorphKeys) { m_numMorphKeys = p_numMorphKeys; }
|
||||
|
||||
// FUNCTION: BETA10 0x10059600
|
||||
void SetUnknown0x20(LegoU16 p_unk0x20) { m_unk0x20 = p_unk0x20; }
|
||||
void SetROIIndex(LegoU16 p_roiIndex) { m_roiIndex = p_roiIndex; }
|
||||
|
||||
// FUNCTION: BETA10 0x1005f2e0
|
||||
void SetUnknown0x22(LegoU16 p_unk0x22) { m_unk0x22 = p_unk0x22; }
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1005d580
|
||||
LegoBool FUN_100a0990(LegoTime p_time) { return FUN_100a0990((LegoFloat) p_time); }
|
||||
LegoBool GetVisibility(LegoTime p_time) { return GetVisibility((LegoFloat) p_time); }
|
||||
|
||||
inline static void GetTranslation(
|
||||
LegoU16 p_numTranslationKeys,
|
||||
@@ -279,7 +279,7 @@ protected:
|
||||
LegoRotationKey* m_rotationKeys; // 0x14
|
||||
LegoScaleKey* m_scaleKeys; // 0x18
|
||||
LegoMorphKey* m_morphKeys; // 0x1c
|
||||
LegoU16 m_unk0x20; // 0x20
|
||||
LegoU16 m_roiIndex; // 0x20
|
||||
LegoU16 m_unk0x22; // 0x22
|
||||
LegoU32 m_translationIndex; // 0x24
|
||||
LegoU32 m_rotationIndex; // 0x28
|
||||
|
@@ -337,7 +337,7 @@ done:
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a8cb0
|
||||
LegoResult LegoROI::FUN_100a8cb0(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix)
|
||||
LegoResult LegoROI::CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix)
|
||||
{
|
||||
p_matrix.SetIdentity();
|
||||
p_data->CreateLocalTransform(p_time, p_matrix);
|
||||
@@ -379,27 +379,32 @@ LegoROI* LegoROI::FindChildROI(const LegoChar* p_name, LegoROI* p_roi)
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a8da0
|
||||
LegoResult LegoROI::FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi)
|
||||
LegoResult LegoROI::ApplyAnimationTransformation(
|
||||
LegoTreeNode* p_node,
|
||||
const Matrix4& p_matrix,
|
||||
LegoTime p_time,
|
||||
LegoROI* p_parentROI
|
||||
)
|
||||
{
|
||||
MxMatrix mat;
|
||||
LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData();
|
||||
const LegoChar* name = data->GetName();
|
||||
LegoROI* roi = FindChildROI(name, p_roi);
|
||||
LegoROI* roi = FindChildROI(name, p_parentROI);
|
||||
|
||||
if (roi == NULL) {
|
||||
roi = FindChildROI(name, this);
|
||||
}
|
||||
|
||||
if (roi != NULL) {
|
||||
FUN_100a8cb0(data, p_time, mat);
|
||||
CreateLocalTransform(data, p_time, mat);
|
||||
roi->m_local2world.Product(mat, p_matrix);
|
||||
roi->UpdateWorldData();
|
||||
|
||||
LegoBool und = data->FUN_100a0990(p_time);
|
||||
LegoBool und = data->GetVisibility(p_time);
|
||||
roi->SetVisibility(und);
|
||||
|
||||
for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {
|
||||
FUN_100a8da0(p_node->GetChild(i), roi->m_local2world, p_time, roi);
|
||||
ApplyAnimationTransformation(p_node->GetChild(i), roi->m_local2world, p_time, roi);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -416,14 +421,14 @@ void LegoROI::FUN_100a8e80(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_t
|
||||
MxMatrix mat;
|
||||
|
||||
LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData();
|
||||
FUN_100a8cb0(data, p_time, mat);
|
||||
CreateLocalTransform(data, p_time, mat);
|
||||
|
||||
LegoROI* roi = p_roiMap[data->GetUnknown0x20()];
|
||||
LegoROI* roi = p_roiMap[data->GetROIIndex()];
|
||||
if (roi != NULL) {
|
||||
roi->m_local2world.Product(mat, p_matrix);
|
||||
roi->UpdateWorldData();
|
||||
|
||||
LegoBool und = data->FUN_100a0990(p_time);
|
||||
LegoBool und = data->GetVisibility(p_time);
|
||||
roi->SetVisibility(und);
|
||||
|
||||
for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {
|
||||
@@ -447,9 +452,9 @@ void LegoROI::FUN_100a8fd0(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_t
|
||||
MxMatrix mat;
|
||||
|
||||
LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData();
|
||||
FUN_100a8cb0(data, p_time, mat);
|
||||
CreateLocalTransform(data, p_time, mat);
|
||||
|
||||
LegoROI* roi = p_roiMap[data->GetUnknown0x20()];
|
||||
LegoROI* roi = p_roiMap[data->GetROIIndex()];
|
||||
if (roi != NULL) {
|
||||
roi->m_local2world.Product(mat, p_matrix);
|
||||
|
||||
@@ -474,9 +479,9 @@ LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time)
|
||||
MxMatrix mat;
|
||||
|
||||
mat = m_local2world;
|
||||
mat.SetIdentity();
|
||||
mat.SetIdentity(); // this clears the matrix, assignment above is redundant
|
||||
|
||||
return FUN_100a8da0(root, mat, p_time, this);
|
||||
return ApplyAnimationTransformation(root, mat, p_time, this);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a9170
|
||||
|
@@ -32,7 +32,12 @@ public:
|
||||
LegoStorage* p_storage
|
||||
);
|
||||
LegoROI* FindChildROI(const LegoChar* p_name, LegoROI* p_roi);
|
||||
LegoResult FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi);
|
||||
LegoResult ApplyAnimationTransformation(
|
||||
LegoTreeNode* p_node,
|
||||
const Matrix4& p_matrix,
|
||||
LegoTime p_time,
|
||||
LegoROI* p_roi
|
||||
);
|
||||
static void FUN_100a8e80(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_time, LegoROI** p_roiMap);
|
||||
static void FUN_100a8fd0(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_time, LegoROI** p_roiMap);
|
||||
LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time);
|
||||
@@ -51,7 +56,7 @@ public:
|
||||
void ClearMeshOffset();
|
||||
void SetDisplayBB(int p_displayBB);
|
||||
|
||||
static LegoResult FUN_100a8cb0(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix);
|
||||
static LegoResult CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix);
|
||||
static void FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name);
|
||||
static void configureLegoROI(int p_roi);
|
||||
static void SetColorOverride(ColorOverride p_colorOverride);
|
||||
|
Reference in New Issue
Block a user