From 67127e25154a900df1602c3dace2d82a97f47b54 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 13 Apr 2024 11:59:16 -0400 Subject: [PATCH] Implement/match LegoAnimPresenter::PutFrame (#796) * Implement/match LegoAnimPresenter::PutFrame * compat mode --- .../lego/legoomni/include/legoanimpresenter.h | 1 + .../legoomni/src/video/legoanimpresenter.cpp | 56 ++++++++++++++++++- LEGO1/realtime/vector.h | 2 +- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 47e05145..f802d6bf 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -92,6 +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_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 7fe3f0e5..d822a5f9 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -510,10 +510,57 @@ void LegoAnimPresenter::FUN_1006ac90() // TODO } -// STUB: LEGO1 0x1006ad30 +// FUNCTION: LEGO1 0x1006ad30 void LegoAnimPresenter::PutFrame() { - // TODO + if (m_currentTickleState == e_streaming) { + MxLong time; + + if (m_action->GetStartTime() <= m_action->GetElapsedTime()) { + time = m_action->GetElapsedTime() - m_action->GetStartTime(); + } + else { + time = 0; + } + + 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++) { + if (m_unk0x8c[i] != NULL) { + MxMatrix mat(m_unk0x8c[i]->GetLocal2World()); + + Vector3 pos(mat[0]); + Vector3 dir(mat[1]); + Vector3 up(mat[2]); + Vector3 und(mat[3]); + + float possqr = sqrt(pos.LenSquared()); + float dirsqr = sqrt(dir.LenSquared()); + float upsqr = sqrt(up.LenSquared()); + + up = und; + +#ifdef COMPAT_MODE + Mx3DPointFloat location = m_currentWorld->GetCamera()->GetWorldLocation(); + ((Vector3&) up).Sub(&location); +#else + ((Vector3&) up).Sub(&m_currentWorld->GetCamera()->GetWorldLocation()); +#endif + ((Vector3&) dir).Div(dirsqr); + pos.EqualsCross(&dir, &up); + pos.Unitize(); + up.EqualsCross(&pos, &dir); + ((Vector3&) pos).Mul(possqr); + ((Vector3&) dir).Mul(dirsqr); + ((Vector3&) up).Mul(upsqr); + + m_unk0x8c[i]->FUN_100a58f0(mat); + m_unk0x8c[i]->VTable0x14(); + } + } + } + } } // FUNCTION: LEGO1 0x1006b550 @@ -643,6 +690,11 @@ const char* LegoAnimPresenter::GetActionObjectName() return m_action->GetObjectName(); } +// STUB: LEGO1 0x1006b9a0 +void LegoAnimPresenter::FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, MxMatrix& p_matrix) +{ +} + // STUB: LEGO1 0x1006bac0 void LegoAnimPresenter::ParseExtra() { diff --git a/LEGO1/realtime/vector.h b/LEGO1/realtime/vector.h index 84060d3b..acdd6cb3 100644 --- a/LEGO1/realtime/vector.h +++ b/LEGO1/realtime/vector.h @@ -126,7 +126,7 @@ class Vector2 { virtual void Sub(float* p_other) { SubImpl(p_other); } // vtable+0x58 // FUNCTION: LEGO1 0x10002200 - virtual void Sub(Vector2* p_other) { SubImpl(p_other->m_data); } // vtable+0x54 + virtual void Sub(const Vector2* p_other) { SubImpl((float*) p_other->m_data); } // vtable+0x54 // FUNCTION: LEGO1 0x10002210 virtual void Mul(float* p_other) { MulVectorImpl(p_other); } // vtable+0x64