Implement various LegoROI functions (#637)

* WIP

* Fix

* Fix
This commit is contained in:
Christian Semmler 2024-03-08 14:28:52 -05:00 committed by GitHub
parent 45cba2c00e
commit 309997fddc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 117 additions and 5 deletions

View file

@ -406,6 +406,20 @@ LegoResult LegoAnimNodeData::Write(LegoStorage* p_storage)
return SUCCESS;
}
// STUB: LEGO1 0x100a03c0
LegoResult LegoAnimNodeData::FUN_100a03c0(LegoFloat p_time, Matrix4& p_matrix)
{
// TODO
return SUCCESS;
}
// STUB: LEGO1 0x100a0990
LegoBool LegoAnimNodeData::FUN_100a0990(LegoFloat p_time)
{
// TODO
return TRUE;
}
// FUNCTION: LEGO1 0x100a0b30
LegoAnim::LegoAnim()
{

View file

@ -4,6 +4,7 @@
#include "decomp.h"
#include "misc/legostorage.h"
#include "misc/legotree.h"
#include "realtime/matrix.h"
// SIZE 0x08
class LegoAnimKey {
@ -86,6 +87,14 @@ class LegoAnimNodeData : public LegoTreeNodeData {
LegoResult Read(LegoStorage* p_storage) override; // vtable+0x04
LegoResult Write(LegoStorage* p_storage) override; // vtable+0x08
LegoResult FUN_100a03c0(LegoFloat p_time, Matrix4& p_matrix);
LegoBool FUN_100a0990(LegoFloat p_time);
const LegoChar* GetName() { return m_name; }
LegoResult FUN_100a03c0(LegoTime p_time, Matrix4& p_matrix) { return FUN_100a03c0((LegoFloat) p_time, p_matrix); }
LegoBool FUN_100a0990(LegoTime p_time) { return FUN_100a0990((LegoFloat) p_time); }
// SYNTHETIC: LEGO1 0x1009fd80
// LegoAnimNodeData::`scalar deleting destructor'

View file

@ -1,5 +1,6 @@
#include "legoroi.h"
#include "anim/legoanim.h"
#include "geom/legobox.h"
#include "geom/legosphere.h"
#include "legolod.h"
@ -54,6 +55,11 @@ const char* g_unk0x10101390[] = {"rcuser", "jsuser", "dunebugy", "chtrblad", "ch
// GLOBAL: LEGO1 0x101013ac
ROIHandler g_unk0x101013ac = NULL;
// FUNCTION: LEGO1 0x100a81b0
void LegoROI::FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name)
{
}
// FUNCTION: LEGO1 0x100a81c0
void LegoROI::configureLegoROI(int p_roiConfig)
{
@ -328,11 +334,88 @@ LegoResult LegoROI::Read(
return result;
}
// STUB: LEGO1 0x100a90f0
// FUNCTION: LEGO1 0x100a8cb0
LegoResult LegoROI::FUN_100a8cb0(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix)
{
p_matrix.SetIdentity();
p_data->FUN_100a03c0(p_time, p_matrix);
return SUCCESS;
}
// FUNCTION: LEGO1 0x100a8ce0
LegoROI* LegoROI::FUN_100a8ce0(const LegoChar* p_name, LegoROI* p_roi)
{
CompoundObject::iterator it;
const LegoChar* name = p_roi->GetName();
if (name != NULL && *name != '\0' && !strcmpi(name, p_name)) {
return p_roi;
}
CompoundObject* comp = p_roi->comp;
if (comp != NULL) {
for (it = comp->begin(); it != comp->end(); it++) {
LegoROI* roi = (LegoROI*) *it;
name = roi->GetName();
if (name != NULL && *name != '\0' && !strcmpi(name, p_name)) {
return roi;
}
}
for (it = comp->begin(); it != comp->end(); it++) {
LegoROI* roi = FUN_100a8ce0(p_name, (LegoROI*) *it);
if (roi != NULL) {
return roi;
}
}
}
return NULL;
}
// FUNCTION: LEGO1 0x100a8da0
LegoResult LegoROI::FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi)
{
MxMatrix mat;
LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData();
const LegoChar* name = data->GetName();
LegoROI* roi = FUN_100a8ce0(name, p_roi);
if (roi == NULL) {
roi = FUN_100a8ce0(name, this);
}
if (roi != NULL) {
FUN_100a8cb0(data, p_time, mat);
roi->m_local2world.Product(mat, p_matrix);
roi->VTable0x1c();
LegoBool und = data->FUN_100a0990(p_time);
roi->SetUnknown0x0c(und);
for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {
FUN_100a8da0(p_node->GetChild(i), roi->m_local2world, p_time, roi);
}
}
else {
FUN_100a81b0("%s ROI Not found\n", name);
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x100a90f0
LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time)
{
// TODO
return SUCCESS;
LegoTreeNode* root = p_anim->GetRoot();
MxMatrix mat;
mat = m_local2world;
mat.SetIdentity();
return FUN_100a8da0(root, mat, p_time, this);
}
// STUB: LEGO1 0x100a9170

View file

@ -11,6 +11,8 @@ class LegoTextureContainer;
struct LegoTextureInfo;
class LegoStorage;
class LegoAnim;
class LegoAnimNodeData;
class LegoTreeNode;
// VTABLE: LEGO1 0x100dbe38
// SIZE 0x108
@ -27,16 +29,20 @@ class LegoROI : public ViewROI {
LegoTextureContainer* p_textureContainer,
LegoStorage* p_storage
);
LegoROI* FUN_100a8ce0(const LegoChar* p_name, LegoROI* p_roi);
LegoResult FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi);
LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time);
LegoResult FUN_100a9170(LegoFloat, LegoFloat, LegoFloat, LegoFloat);
LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo);
LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time);
float IntrinsicImportance() const override; // vtable+0x04
void UpdateWorldBoundingVolumes() override; // vtable+0x18
void SetDisplayBB(int p_displayBB);
static void configureLegoROI(int p_roi);
static LegoResult FUN_100a8cb0(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 FUN_100a9d30(ROIHandler p_func);
static LegoBool FUN_100a9bf0(const LegoChar* p_param, float& p_red, float& p_green, float& p_blue, float& p_alpha);
static LegoBool ColorAliasLookup(