Implement/match LegoLoopingAnimPresenter (#924)

This commit is contained in:
Christian Semmler 2024-05-15 14:34:36 -04:00 committed by GitHub
parent 29a0e32739
commit 9a05edd0a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 111 additions and 39 deletions

View file

@ -119,7 +119,7 @@ class LegoAnimPresenter : public MxVideoPresenter {
LegoROI** m_unk0x8c; // 0x8c LegoROI** m_unk0x8c; // 0x8c
char** m_unk0x90; // 0x90 char** m_unk0x90; // 0x90
MxU8 m_unk0x94; // 0x94 MxU8 m_unk0x94; // 0x94
undefined m_unk0x95; // 0x95 MxBool m_unk0x95; // 0x95
MxBool m_unk0x96; // 0x96 MxBool m_unk0x96; // 0x96
undefined m_unk0x97; // 0x97 undefined m_unk0x97; // 0x97
LegoAnimSubstMap* m_substMap; // 0x98 LegoAnimSubstMap* m_substMap; // 0x98

View file

@ -97,7 +97,7 @@ void LegoPathPresenter::StreamingTickle()
MxStreamChunk* chunk = m_subscriber->PopData(); MxStreamChunk* chunk = m_subscriber->PopData();
if (chunk) { if (chunk) {
if (chunk->GetFlags() & MxStreamChunk::c_end) { if (chunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) {
ProgressTickleState(e_repeating); ProgressTickleState(e_repeating);
} }

View file

@ -53,7 +53,7 @@ void LegoAnimPresenter::Init()
m_unk0xa8.Clear(); m_unk0xa8.Clear();
m_unk0xa4 = 0; m_unk0xa4 = 0;
m_currentWorld = NULL; m_currentWorld = NULL;
m_unk0x95 = 0; m_unk0x95 = FALSE;
m_worldId = -1; m_worldId = -1;
m_substMap = NULL; m_substMap = NULL;
m_worldAtom.Clear(); m_worldAtom.Clear();
@ -806,7 +806,7 @@ void LegoAnimPresenter::StreamingTickle()
} }
else { else {
if (m_action->GetElapsedTime() > m_anim->GetDuration() + m_action->GetStartTime()) { if (m_action->GetElapsedTime() > m_anim->GetDuration() + m_action->GetStartTime()) {
m_unk0x95 = 1; m_unk0x95 = TRUE;
} }
} }
} }

View file

@ -1,15 +1,88 @@
#include "legoloopinganimpresenter.h" #include "legoloopinganimpresenter.h"
#include "anim/legoanim.h"
#include "legocameracontroller.h"
#include "legoworld.h"
#include "mxcompositepresenter.h"
#include "mxdsaction.h"
#include "mxdssubscriber.h"
DECOMP_SIZE_ASSERT(LegoLoopingAnimPresenter, 0xc0) DECOMP_SIZE_ASSERT(LegoLoopingAnimPresenter, 0xc0)
// STUB: LEGO1 0x1006caa0 // FUNCTION: LEGO1 0x1006caa0
// FUNCTION: BETA10 0x1005223d
void LegoLoopingAnimPresenter::StreamingTickle() void LegoLoopingAnimPresenter::StreamingTickle()
{ {
// TODO if (m_subscriber->PeekData()) {
MxStreamChunk* chunk = m_subscriber->PopData();
m_subscriber->FreeDataChunk(chunk);
} }
// STUB: LEGO1 0x1006cb40 if (m_unk0x95) {
ProgressTickleState(e_done);
if (m_compositePresenter) {
if (m_compositePresenter->IsA("LegoAnimMMPresenter")) {
m_compositePresenter->VTable0x60(this);
}
}
}
else {
if (m_action->GetDuration() != -1) {
if (m_action->GetElapsedTime() > m_action->GetDuration() + m_action->GetStartTime()) {
m_unk0x95 = TRUE;
}
}
}
}
// FUNCTION: LEGO1 0x1006cb40
// FUNCTION: BETA10 0x1005239a
void LegoLoopingAnimPresenter::PutFrame() void LegoLoopingAnimPresenter::PutFrame()
{ {
// TODO MxLong time;
if (m_action->GetStartTime() <= m_action->GetElapsedTime()) {
time = (m_action->GetElapsedTime() - m_action->GetStartTime()) % m_anim->GetDuration();
}
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();
}
}
}
} }

View file

@ -5,18 +5,16 @@
#include "mxcore.h" #include "mxcore.h"
#include "mxtypes.h" #include "mxtypes.h"
#define DS_CHUNK_BIT1 0x01
#define DS_CHUNK_END_OF_STREAM 0x02
#define DS_CHUNK_BIT3 0x04
#define DS_CHUNK_SPLIT 0x10
#define DS_CHUNK_BIT16 0x8000
// VTABLE: LEGO1 0x100dc7f8 // VTABLE: LEGO1 0x100dc7f8
// SIZE 0x1c // SIZE 0x1c
class MxDSChunk : public MxCore { class MxDSChunk : public MxCore {
public: public:
enum {
c_bit1 = 0x01,
c_end = 0x02,
c_bit3 = 0x04,
c_split = 0x10,
c_bit16 = 0x8000
};
MxDSChunk(); MxDSChunk();
~MxDSChunk() override; ~MxDSChunk() override;
@ -39,13 +37,13 @@ class MxDSChunk : public MxCore {
inline static MxU32 Size(MxU32 p_dataSize) { return (p_dataSize & 1) + p_dataSize + 8; } inline static MxU32 Size(MxU32 p_dataSize) { return (p_dataSize & 1) + p_dataSize + 8; }
inline static MxU8* End(MxU8* p_buffer) { return p_buffer + Size(*IntoLength(p_buffer)); } inline static MxU8* End(MxU8* p_buffer) { return p_buffer + Size(*IntoLength(p_buffer)); }
inline void SetFlags(MxU16 p_flags) { m_flags = p_flags; } inline void SetChunkFlags(MxU16 p_flags) { m_flags = p_flags; }
inline void SetObjectId(undefined4 p_objectid) { m_objectId = p_objectid; } inline void SetObjectId(undefined4 p_objectid) { m_objectId = p_objectid; }
inline void SetTime(MxLong p_time) { m_time = p_time; } inline void SetTime(MxLong p_time) { m_time = p_time; }
inline void SetLength(MxU32 p_length) { m_length = p_length; } inline void SetLength(MxU32 p_length) { m_length = p_length; }
inline void SetData(MxU8* p_data) { m_data = p_data; } inline void SetData(MxU8* p_data) { m_data = p_data; }
inline MxU16 GetFlags() { return m_flags; } inline MxU16 GetChunkFlags() { return m_flags; }
inline undefined4 GetObjectId() { return m_objectId; } inline undefined4 GetObjectId() { return m_objectId; }
inline MxLong GetTime() { return m_time; } inline MxLong GetTime() { return m_time; }
inline MxU32 GetLength() { return m_length; } inline MxU32 GetLength() { return m_length; }

View file

@ -192,8 +192,9 @@ void MxWavePresenter::StreamingTickle()
if (!(m_action->GetFlags() & MxDSAction::c_looping)) { if (!(m_action->GetFlags() & MxDSAction::c_looping)) {
MxStreamChunk* chunk = CurrentChunk(); MxStreamChunk* chunk = CurrentChunk();
if (chunk && chunk->GetFlags() & MxDSChunk::c_end && !(chunk->GetFlags() & MxDSChunk::c_bit16)) { if (chunk && chunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM &&
chunk->SetFlags(chunk->GetFlags() | MxDSChunk::c_bit16); !(chunk->GetChunkFlags() & DS_CHUNK_BIT16)) {
chunk->SetChunkFlags(chunk->GetChunkFlags() | DS_CHUNK_BIT16);
m_currentChunk = new MxStreamChunk; m_currentChunk = new MxStreamChunk;
MxU8* data = new MxU8[m_chunkLength]; MxU8* data = new MxU8[m_chunkLength];
@ -203,7 +204,7 @@ void MxWavePresenter::StreamingTickle()
m_currentChunk->SetLength(m_chunkLength); m_currentChunk->SetLength(m_chunkLength);
m_currentChunk->SetData(data); m_currentChunk->SetData(data);
m_currentChunk->SetTime(chunk->GetTime() + 1000); m_currentChunk->SetTime(chunk->GetTime() + 1000);
m_currentChunk->SetFlags(MxDSChunk::c_bit1); m_currentChunk->SetChunkFlags(DS_CHUNK_BIT1);
} }
} }

View file

@ -67,7 +67,7 @@ MxStreamChunk* MxMediaPresenter::CurrentChunk()
if (m_subscriber) { if (m_subscriber) {
chunk = m_subscriber->PeekData(); chunk = m_subscriber->PeekData();
if (chunk && chunk->GetFlags() & MxDSChunk::c_bit3) { if (chunk && chunk->GetChunkFlags() & DS_CHUNK_BIT3) {
m_action->SetFlags(m_action->GetFlags() | MxDSAction::c_bit7); m_action->SetFlags(m_action->GetFlags() | MxDSAction::c_bit7);
m_subscriber->PopData(); m_subscriber->PopData();
m_subscriber->FreeDataChunk(chunk); m_subscriber->FreeDataChunk(chunk);
@ -87,7 +87,7 @@ MxStreamChunk* MxMediaPresenter::NextChunk()
if (m_subscriber) { if (m_subscriber) {
chunk = m_subscriber->PopData(); chunk = m_subscriber->PopData();
if (chunk && chunk->GetFlags() & MxDSChunk::c_bit3) { if (chunk && chunk->GetChunkFlags() & DS_CHUNK_BIT3) {
m_action->SetFlags(m_action->GetFlags() | MxDSAction::c_bit7); m_action->SetFlags(m_action->GetFlags() | MxDSAction::c_bit7);
m_subscriber->FreeDataChunk(chunk); m_subscriber->FreeDataChunk(chunk);
chunk = NULL; chunk = NULL;
@ -180,7 +180,7 @@ void MxMediaPresenter::StreamingTickle()
m_currentChunk = NextChunk(); m_currentChunk = NextChunk();
if (m_currentChunk) { if (m_currentChunk) {
if (m_currentChunk->GetFlags() & MxDSChunk::c_end) { if (m_currentChunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) {
m_subscriber->FreeDataChunk(m_currentChunk); m_subscriber->FreeDataChunk(m_currentChunk);
m_currentChunk = NULL; m_currentChunk = NULL;
ProgressTickleState(e_repeating); ProgressTickleState(e_repeating);

View file

@ -242,7 +242,7 @@ MxResult MxDSBuffer::ParseChunk(
p_header->SetTime(p_header->GetTime() + m_unk0x30->GetUnknowna8()); p_header->SetTime(p_header->GetTime() + m_unk0x30->GetUnknowna8());
if (p_header->GetFlags() & MxDSChunk::c_split) { if (p_header->GetChunkFlags() & DS_CHUNK_SPLIT) {
MxU32 length = p_header->GetLength() + MxDSChunk::GetHeaderSize() + 8; MxU32 length = p_header->GetLength() + MxDSChunk::GetHeaderSize() + 8;
MxDSBuffer* buffer = new MxDSBuffer(); MxDSBuffer* buffer = new MxDSBuffer();
@ -252,7 +252,7 @@ MxResult MxDSBuffer::ParseChunk(
if (*p_streamingAction) { if (*p_streamingAction) {
MxU16* flags = MxStreamChunk::IntoFlags(buffer->GetBuffer()); MxU16* flags = MxStreamChunk::IntoFlags(buffer->GetBuffer());
*flags = p_header->GetFlags() & ~MxDSChunk::c_split; *flags = p_header->GetChunkFlags() & ~DS_CHUNK_SPLIT;
delete p_header; delete p_header;
(*p_streamingAction)->SetUnknowna0(buffer); (*p_streamingAction)->SetUnknowna0(buffer);
@ -268,7 +268,7 @@ MxResult MxDSBuffer::ParseChunk(
return FAILURE; return FAILURE;
} }
else { else {
if (p_header->GetFlags() & MxDSChunk::c_end) { if (p_header->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) {
if (m_unk0x30->HasId(p_header->GetObjectId())) { if (m_unk0x30->HasId(p_header->GetObjectId())) {
if (m_unk0x30->GetFlags() & MxDSAction::c_bit3 && if (m_unk0x30->GetFlags() & MxDSAction::c_bit3 &&
(m_unk0x30->GetLoopCount() > 1 || m_unk0x30->GetDuration() == -1)) { (m_unk0x30->GetLoopCount() > 1 || m_unk0x30->GetDuration() == -1)) {

View file

@ -15,7 +15,7 @@ MxDSChunk::MxDSChunk()
// FUNCTION: LEGO1 0x100be170 // FUNCTION: LEGO1 0x100be170
MxDSChunk::~MxDSChunk() MxDSChunk::~MxDSChunk()
{ {
if (m_flags & c_bit1) { if (m_flags & DS_CHUNK_BIT1) {
delete[] m_data; delete[] m_data;
} }
} }

View file

@ -130,7 +130,7 @@ void MxDSSubscriber::FreeDataChunk(MxStreamChunk* p_chunk)
delete p_chunk; delete p_chunk;
} }
} }
else if (p_chunk->GetFlags() & MxDSChunk::c_bit1 && p_chunk) { else if (p_chunk->GetChunkFlags() & DS_CHUNK_BIT1 && p_chunk) {
delete p_chunk; delete p_chunk;
} }
} }

View file

@ -126,15 +126,15 @@ MxU32 ReadData(MxU8* p_buffer, MxU32 p_size)
data += MxDSChunk::Size(*psize); data += MxDSChunk::Size(*psize);
if ((*MxDSChunk::IntoType(data2) == FOURCC('M', 'x', 'C', 'h')) && if ((*MxDSChunk::IntoType(data2) == FOURCC('M', 'x', 'C', 'h')) &&
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::c_split)) { (*MxStreamChunk::IntoFlags(data2) & DS_CHUNK_SPLIT)) {
if (*MxStreamChunk::IntoObjectId(data2) == *MxStreamChunk::IntoObjectId(data3) && if (*MxStreamChunk::IntoObjectId(data2) == *MxStreamChunk::IntoObjectId(data3) &&
(*MxStreamChunk::IntoFlags(data3) & MxDSChunk::c_split) && (*MxStreamChunk::IntoFlags(data3) & DS_CHUNK_SPLIT) &&
*MxStreamChunk::IntoTime(data2) == *MxStreamChunk::IntoTime(data3)) { *MxStreamChunk::IntoTime(data2) == *MxStreamChunk::IntoTime(data3)) {
MxDSBuffer::Append(data2, data3); MxDSBuffer::Append(data2, data3);
continue; continue;
} }
else { else {
*MxStreamChunk::IntoFlags(data2) &= ~MxDSChunk::c_split; *MxStreamChunk::IntoFlags(data2) &= ~DS_CHUNK_SPLIT;
} }
} }
@ -142,7 +142,7 @@ MxU32 ReadData(MxU8* p_buffer, MxU32 p_size)
memcpy(data2, data3, MxDSChunk::Size(*psize)); memcpy(data2, data3, MxDSChunk::Size(*psize));
if (*MxStreamChunk::IntoObjectId(data2) == id && if (*MxStreamChunk::IntoObjectId(data2) == id &&
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::c_end)) { (*MxStreamChunk::IntoFlags(data2) & DS_CHUNK_END_OF_STREAM)) {
break; break;
} }
} }
@ -157,6 +157,6 @@ MxU32 ReadData(MxU8* p_buffer, MxU32 p_size)
} while (data < end); } while (data < end);
} }
*MxStreamChunk::IntoFlags(data2) &= ~MxDSChunk::c_split; *MxStreamChunk::IntoFlags(data2) &= ~DS_CHUNK_SPLIT;
return MxDSChunk::End(data2) - p_buffer; return MxDSChunk::End(data2) - p_buffer;
} }

View file

@ -61,7 +61,7 @@ MxResult MxStreamChunk::SendChunk(MxStreamListMxDSSubscriber& p_subscriberList,
{ {
for (MxStreamListMxDSSubscriber::iterator it = p_subscriberList.begin(); it != p_subscriberList.end(); it++) { for (MxStreamListMxDSSubscriber::iterator it = p_subscriberList.begin(); it != p_subscriberList.end(); it++) {
if ((*it)->GetObjectId() == m_objectId && (*it)->GetUnknown48() == p_obj24val) { if ((*it)->GetObjectId() == m_objectId && (*it)->GetUnknown48() == p_obj24val) {
if (m_flags & MxDSChunk::c_end && m_buffer) { if (m_flags & DS_CHUNK_END_OF_STREAM && m_buffer) {
m_buffer->ReleaseRef(this); m_buffer->ReleaseRef(this);
m_buffer = NULL; m_buffer = NULL;
} }

View file

@ -284,7 +284,7 @@ MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action)
return FAILURE; return FAILURE;
} }
chunk->SetFlags(MxDSChunk::c_bit3); chunk->SetChunkFlags(DS_CHUNK_BIT3);
chunk->SetObjectId(objectId); chunk->SetObjectId(objectId);
if (chunk->SendChunk(m_subscriberList, FALSE, p_action->GetUnknown24()) != SUCCESS) { if (chunk->SendChunk(m_subscriberList, FALSE, p_action->GetUnknown24()) != SUCCESS) {

View file

@ -43,7 +43,7 @@ void MxLoopingFlcPresenter::NextFrame()
{ {
MxStreamChunk* chunk = NextChunk(); MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end) { if (chunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) {
ProgressTickleState(e_repeating); ProgressTickleState(e_repeating);
} }
else { else {

View file

@ -53,7 +53,7 @@ void MxLoopingSmkPresenter::NextFrame()
{ {
MxStreamChunk* chunk = NextChunk(); MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end) { if (chunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) {
ProgressTickleState(e_repeating); ProgressTickleState(e_repeating);
} }
else { else {

View file

@ -180,7 +180,7 @@ void MxVideoPresenter::NextFrame()
{ {
MxStreamChunk* chunk = NextChunk(); MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end) { if (chunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) {
m_subscriber->FreeDataChunk(chunk); m_subscriber->FreeDataChunk(chunk);
ProgressTickleState(e_repeating); ProgressTickleState(e_repeating);
} }