From 54421ebcdfe4c91d9a580ca4c5ef541045ab9fad Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 13 Apr 2024 12:05:43 -0400 Subject: [PATCH] Implement/match LegoAnimPresenter::FUN_1006b9a0 (#797) --- .../lego/legoomni/include/legoanimpresenter.h | 2 +- .../legoomni/src/video/legoanimpresenter.cpp | 34 +++++++++++++++++-- LEGO1/lego/sources/anim/legoanim.cpp | 7 ++++ LEGO1/lego/sources/anim/legoanim.h | 4 +++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index f802d6bf..bea266d9 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -92,7 +92,7 @@ class LegoAnimPresenter : public MxVideoPresenter { LegoBool FUN_1006aba0(); MxBool FUN_1006abb0(LegoTreeNode* p_node, LegoROI* p_roi); void FUN_1006ac90(); - void FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, MxMatrix& p_matrix); + void FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, Matrix4* p_matrix); void FUN_1006c8a0(MxBool p_bool); LegoAnim* m_anim; // 0x64 diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index d822a5f9..a784f7f8 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -523,7 +523,7 @@ void LegoAnimPresenter::PutFrame() time = 0; } - FUN_1006b9a0(m_anim, time, *m_unk0x78); + FUN_1006b9a0(m_anim, time, m_unk0x78); if (m_unk0x8c != NULL && m_currentWorld != NULL && m_currentWorld->GetCamera() != NULL) { for (MxS32 i = 0; i < m_unk0x94; i++) { @@ -690,9 +690,37 @@ const char* LegoAnimPresenter::GetActionObjectName() return m_action->GetObjectName(); } -// STUB: LEGO1 0x1006b9a0 -void LegoAnimPresenter::FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, MxMatrix& p_matrix) +// FUNCTION: LEGO1 0x1006b9a0 +void LegoAnimPresenter::FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, Matrix4* p_matrix) { + LegoTreeNode* root = p_anim->GetRoot(); + MxMatrix mat; + LegoAnimNodeData* data = (LegoAnimNodeData*) root->GetData(); + + if (p_matrix != NULL) { + mat = *p_matrix; + } + else { + LegoROI* roi = m_unk0x68[data->GetUnknown0x20()]; + + if (roi != NULL) { + mat = roi->GetLocal2World(); + } + else { + mat.SetIdentity(); + } + } + + if (p_anim->GetScene() != NULL) { + MxMatrix transform(mat); + p_anim->GetScene()->FUN_1009f490(p_time, transform); + + if (m_currentWorld != NULL && m_currentWorld->GetCamera() != NULL) { + m_currentWorld->GetCamera()->FUN_100123e0(transform, 0); + } + } + + LegoROI::FUN_100a8e80(root, mat, p_time, m_unk0x68); } // STUB: LEGO1 0x1006bac0 diff --git a/LEGO1/lego/sources/anim/legoanim.cpp b/LEGO1/lego/sources/anim/legoanim.cpp index d11efc4d..1a0a5e9a 100644 --- a/LEGO1/lego/sources/anim/legoanim.cpp +++ b/LEGO1/lego/sources/anim/legoanim.cpp @@ -136,6 +136,13 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage) return result; } +// STUB: LEGO1 0x1009f490 +undefined4 LegoAnimScene::FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix) +{ + // TODO + return 0; +} + // FUNCTION: LEGO1 0x1009f900 LegoAnimKey::LegoAnimKey() { diff --git a/LEGO1/lego/sources/anim/legoanim.h b/LEGO1/lego/sources/anim/legoanim.h index c1ccc016..3527747c 100644 --- a/LEGO1/lego/sources/anim/legoanim.h +++ b/LEGO1/lego/sources/anim/legoanim.h @@ -123,6 +123,7 @@ class LegoAnimNodeData : public LegoTreeNodeData { LegoU32 GetRotationIndex() { return m_rotationIndex; } LegoU32 GetScaleIndex() { return m_scaleIndex; } LegoU32 GetMorphIndex() { return m_morphIndex; } + undefined2 GetUnknown0x20() { return m_unk0x20; } void SetTranslationIndex(LegoU32 p_translationIndex) { m_translationIndex = p_translationIndex; } void SetRotationIndex(LegoU32 p_rotationIndex) { m_rotationIndex = p_rotationIndex; } @@ -207,6 +208,7 @@ class LegoAnimScene { LegoAnimScene(); ~LegoAnimScene(); LegoResult Read(LegoStorage* p_storage); + undefined4 FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix); private: LegoU16 m_unk0x00; // 0x00 @@ -234,6 +236,8 @@ class LegoAnim : public LegoTree { const LegoChar* GetActorName(LegoU32 p_index); undefined4 GetActorUnknown0x04(LegoU32 p_index); + inline LegoAnimScene* GetScene() { return m_scene; } + // SYNTHETIC: LEGO1 0x100a0ba0 // LegoAnim::`scalar deleting destructor'