Clear unknowns in LegoROI and related classes

This commit is contained in:
Florian Kaiser 2025-05-09 11:35:09 +02:00
parent 0a2d598b57
commit cfd746eb95
8 changed files with 95 additions and 63 deletions

View File

@ -1373,7 +1373,7 @@ void LegoCarBuild::FUN_10025350(MxS32 p_objectId)
m_Paint_Sound->Enable(FALSE);
m_Paint_Sound->Enable(TRUE);
m_unk0x110->FUN_100a93b0(color);
m_unk0x110->SetColorNamed2(color);
sprintf(buffer, "c_%s", m_unk0x110->GetName());
VariableTable()->SetVariable(buffer, color);
}

View File

@ -220,8 +220,8 @@ void LegoCarBuildAnimPresenter::StreamingTickle()
LegoROI* roi = m_roiMap[j];
if (roi && roi->GetName() && (strcmpi(name, roi->GetName()) == 0)) {
roi->FUN_100a9dd0();
roi->FUN_100a9350("lego red");
roi->ClearMeshOffset();
roi->SetColorNamed("lego red");
}
}
}

View File

@ -567,14 +567,20 @@ LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key)
LegoTextureInfo* textureInfo = textureContainer->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]);
if (textureInfo != NULL) {
childROI->FUN_100a9210(textureInfo);
childROI->FUN_100a9170(1.0F, 1.0F, 1.0F, 0.0F);
childROI->SetTexture(textureInfo);
childROI->SetLodColor(1.0F, 1.0F, 1.0F, 0.0F);
}
}
else if (g_actorLODs[i + 1].m_flags & LegoActorLOD::c_flag2 || (i == 0 && part.m_unk0x00[part.m_unk0x08] == 0)) {
LegoFloat red, green, blue, alpha;
childROI->FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha);
childROI->FUN_100a9170(red, green, blue, alpha);
childROI->GetColorFromGlobalHandlerOrAlias(
part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]],
red,
green,
blue,
alpha
);
childROI->SetLodColor(red, green, blue, alpha);
}
comp->push_back(childROI);
@ -796,8 +802,8 @@ MxBool LegoCharacterManager::SwitchColor(LegoROI* p_roi, LegoROI* p_targetROI)
}
LegoFloat red, green, blue, alpha;
LegoROI::FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha);
p_targetROI->FUN_100a9170(red, green, blue, alpha);
LegoROI::GetColorFromGlobalHandlerOrAlias(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha);
p_targetROI->SetLodColor(red, green, blue, alpha);
return TRUE;
}
@ -832,7 +838,13 @@ MxBool LegoCharacterManager::SwitchVariant(LegoROI* p_roi)
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
LegoFloat red, green, blue, alpha;
LegoROI::FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha);
LegoROI::GetColorFromGlobalHandlerOrAlias(
part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]],
red,
green,
blue,
alpha
);
for (MxS32 i = 0; i < lodSize; i++) {
LegoLOD* lod = (LegoLOD*) (*lodList)[i];

View File

@ -176,7 +176,7 @@ LegoGameState::LegoGameState()
// FUNCTION: LEGO1 0x10039720
LegoGameState::~LegoGameState()
{
LegoROI::FUN_100a9d30(NULL);
LegoROI::SetGlobalROIHandler(NULL);
if (m_stateCount) {
for (MxS16 i = 0; i < m_stateCount; i++) {
@ -1062,7 +1062,7 @@ void LegoGameState::SetColors()
// FUNCTION: LEGO1 0x1003bac0
void LegoGameState::SetROIHandlerFunction()
{
LegoROI::FUN_100a9d30(&ROIHandlerFunction);
LegoROI::SetGlobalROIHandler(&ROIHandlerFunction);
}
// FUNCTION: LEGO1 0x1003bad0

View File

@ -32,7 +32,7 @@ LegoLOD::LegoLOD(Tgl::Renderer* p_renderer) : ViewLOD(p_renderer)
m_numMeshes = 0;
m_numVertices = 0;
m_numPolys = 0;
m_unk0x1c = 0;
m_meshOffset = 0;
}
// FUNCTION: LEGO1 0x100aa450
@ -212,7 +212,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
if (textureName != NULL) {
if (mesh->GetUnknown0x21()) {
LegoROI::FUN_100a9cf0(textureName, paletteEntries, sizeOfArray(paletteEntries));
LegoROI::GetPaletteEntriesFromGlobalHandler(textureName, paletteEntries, sizeOfArray(paletteEntries));
}
textureInfo = p_textureContainer->Get(mesh->GetTextureName());
@ -232,7 +232,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
LegoFloat alpha = 0.0F;
if (mesh->GetUnknown0x21()) {
LegoROI::FUN_100a9bf0(materialName, red, green, blue, alpha);
LegoROI::GetColorFromGlobalHandlerOrAlias(materialName, red, green, blue, alpha);
}
else {
red = mesh->GetColor().GetRed() / 255.0;
@ -265,7 +265,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
}
}
m_unk0x1c = meshUnd2;
m_meshOffset = meshUnd2;
if (textureVertices != NULL) {
delete[] textureVertices;
@ -319,7 +319,7 @@ LegoLOD* LegoLOD::Clone(Tgl::Renderer* p_renderer)
dupLod->m_numMeshes = m_numMeshes;
dupLod->m_numVertices = m_numVertices;
dupLod->m_numPolys = m_numPolys;
dupLod->m_unk0x1c = m_unk0x1c;
dupLod->m_meshOffset = m_meshOffset;
return dupLod;
}
@ -327,7 +327,7 @@ LegoLOD* LegoLOD::Clone(Tgl::Renderer* p_renderer)
// FUNCTION: LEGO1 0x100aacb0
LegoResult LegoLOD::FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
{
for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) {
for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) {
if (!m_melems[i].m_unk0x04) {
m_melems[i].m_tglMesh->SetColor(p_red, p_green, p_blue, p_alpha);
}
@ -337,9 +337,9 @@ LegoResult LegoLOD::FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p
}
// FUNCTION: LEGO1 0x100aad00
LegoResult LegoLOD::FUN_100aad00(LegoTextureInfo* p_textureInfo)
LegoResult LegoLOD::SetTextureInfo(LegoTextureInfo* p_textureInfo)
{
for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) {
for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) {
if (m_melems[i].m_unk0x04) {
LegoTextureInfo::SetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo);
m_melems[i].m_tglMesh->SetColor(1.0F, 1.0F, 1.0F, 0.0F);
@ -353,7 +353,7 @@ LegoResult LegoLOD::FUN_100aad00(LegoTextureInfo* p_textureInfo)
// FUNCTION: LEGO1 0x100aad70
LegoResult LegoLOD::FUN_100aad70(LegoTextureInfo* p_textureInfo)
{
for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) {
for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) {
if (m_melems[i].m_unk0x04) {
LegoTextureInfo::SetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo);
}
@ -365,7 +365,7 @@ LegoResult LegoLOD::FUN_100aad70(LegoTextureInfo* p_textureInfo)
// FUNCTION: LEGO1 0x100aadc0
LegoResult LegoLOD::GetTexture(LegoTextureInfo*& p_textureInfo)
{
for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) {
for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) {
if (m_melems[i].m_unk0x04) {
if (LegoTextureInfo::GetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo) == TRUE) {
return SUCCESS;
@ -390,9 +390,9 @@ LegoBool LegoLOD::FUN_100aae20(const LegoChar* p_name)
// FUNCTION: LEGO1 0x100aae60
// FUNCTION: BETA10 0x1018e50f
void LegoLOD::FUN_100aae60()
void LegoLOD::ClearMeshOffset()
{
m_unk0x1c = 0;
m_meshOffset = 0;
}
inline BOOL GetMeshData(IDirect3DRMMesh*& mesh, D3DRMGROUPINDEX& index, Tgl::Mesh* pMesh)

View File

@ -30,9 +30,9 @@ class LegoLOD : public ViewLOD {
LegoResult Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_textureContainer, LegoStorage* p_storage);
LegoLOD* Clone(Tgl::Renderer* p_renderer);
LegoResult FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha);
LegoResult FUN_100aad00(LegoTextureInfo* p_textureInfo);
LegoResult SetTextureInfo(LegoTextureInfo* p_textureInfo);
LegoResult FUN_100aad70(LegoTextureInfo* p_textureInfo);
void FUN_100aae60();
void ClearMeshOffset();
LegoResult GetTexture(LegoTextureInfo*& p_textureInfo);
static LegoBool FUN_100aae20(const LegoChar* p_name);
@ -45,7 +45,7 @@ class LegoLOD : public ViewLOD {
LegoU32 m_numMeshes; // 0x10
LegoU32 m_numVertices; // 0x14
LegoU32 m_numPolys; // 0x18
undefined4 m_unk0x1c; // 0x1c
LegoU32 m_meshOffset; // 0x1c
};
#endif // LEGOLOD_H

View File

@ -52,10 +52,10 @@ const char* g_unk0x10101380[] = {"bike", "moto", "haus", NULL};
const char* g_unk0x10101390[] = {"rcuser", "jsuser", "dunebugy", "chtrblad", "chtrbody", "chtrshld", NULL};
// GLOBAL: LEGO1 0x101013ac
ROIHandler g_unk0x101013ac = NULL;
ROIHandler g_roiHandler = NULL;
// GLOBAL: LEGO1 0x101013b0
TextureHandler g_unk0x101013b0 = NULL;
TextureHandler g_textureHandler = NULL;
// FUNCTION: LEGO1 0x100a81b0
void LegoROI::FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name)
@ -299,16 +299,16 @@ LegoResult LegoROI::Read(
goto done;
}
FUN_100a9210(textureInfo);
FUN_100a9170(1.0F, 1.0F, 1.0F, 0.0F);
SetTexture(textureInfo);
SetLodColor(1.0F, 1.0F, 1.0F, 0.0F);
}
else {
LegoFloat red = 1.0F;
LegoFloat green = 0.0F;
LegoFloat blue = 1.0F;
LegoFloat alpha = 0.0F;
FUN_100a9bf0(textureName, red, green, blue, alpha);
FUN_100a9170(red, green, blue, alpha);
GetColorFromGlobalHandlerOrAlias(textureName, red, green, blue, alpha);
SetLodColor(red, green, blue, alpha);
}
}
@ -481,7 +481,7 @@ LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time)
// FUNCTION: LEGO1 0x100a9170
// FUNCTION: BETA10 0x1018ae09
LegoResult LegoROI::FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
LegoResult LegoROI::SetLodColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
{
LegoResult result = SUCCESS;
CompoundObject::iterator it;
@ -497,7 +497,7 @@ LegoResult LegoROI::FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p
if (comp != NULL) {
for (it = comp->begin(); it != comp->end(); it++) {
if (((LegoROI*) *it)->FUN_100a9170(p_red, p_green, p_blue, p_alpha) != SUCCESS) {
if (((LegoROI*) *it)->SetLodColor(p_red, p_green, p_blue, p_alpha) != SUCCESS) {
result = FAILURE;
}
}
@ -507,7 +507,7 @@ LegoResult LegoROI::FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p
}
// FUNCTION: LEGO1 0x100a9210
LegoResult LegoROI::FUN_100a9210(LegoTextureInfo* p_textureInfo)
LegoResult LegoROI::SetTexture(LegoTextureInfo* p_textureInfo)
{
LegoResult result = SUCCESS;
CompoundObject::iterator it;
@ -516,14 +516,14 @@ LegoResult LegoROI::FUN_100a9210(LegoTextureInfo* p_textureInfo)
for (LegoU32 i = 0; i < lodCount; i++) {
LegoLOD* lod = (LegoLOD*) GetLOD(i);
if (lod->FUN_100aad00(p_textureInfo) != SUCCESS) {
if (lod->SetTextureInfo(p_textureInfo) != SUCCESS) {
result = FAILURE;
}
}
if (comp != NULL) {
for (it = comp->begin(); it != comp->end(); it++) {
if (((LegoROI*) *it)->FUN_100a9210(p_textureInfo) != SUCCESS) {
if (((LegoROI*) *it)->SetTexture(p_textureInfo) != SUCCESS) {
result = FAILURE;
}
}
@ -560,18 +560,18 @@ LegoResult LegoROI::GetTexture(LegoTextureInfo*& p_textureInfo)
// FUNCTION: LEGO1 0x100a9330
// FUNCTION: BETA10 0x1018b22c
LegoResult LegoROI::FUN_100a9330(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
LegoResult LegoROI::SetCustomLodColor2(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
{
return FUN_100a9170(p_red, p_green, p_blue, p_alpha);
return SetLodColor(p_red, p_green, p_blue, p_alpha);
}
// FUNCTION: LEGO1 0x100a9350
// FUNCTION: BETA10 0x1018b25c
LegoResult LegoROI::FUN_100a9350(const LegoChar* p_color)
LegoResult LegoROI::SetColorNamed(const LegoChar* p_color)
{
MxFloat red, green, blue, alpha;
if (ColorAliasLookup(p_color, red, green, blue, alpha)) {
return FUN_100a9170(red, green, blue, alpha);
return SetLodColor(red, green, blue, alpha);
}
return SUCCESS;
@ -579,11 +579,11 @@ LegoResult LegoROI::FUN_100a9350(const LegoChar* p_color)
// FUNCTION: LEGO1 0x100a93b0
// FUNCTION: BETA10 0x1018b2c0
LegoResult LegoROI::FUN_100a93b0(const LegoChar* p_color)
LegoResult LegoROI::SetColorNamed2(const LegoChar* p_color)
{
MxFloat red, green, blue, alpha;
if (ColorAliasLookup(p_color, red, green, blue, alpha)) {
return FUN_100a9330(red, green, blue, alpha);
return SetCustomLodColor2(red, green, blue, alpha);
}
return 0;
@ -755,15 +755,21 @@ void TimeROI::FUN_100a9b40(Matrix4& p_matrix, LegoTime p_time)
}
// FUNCTION: LEGO1 0x100a9bf0
LegoBool LegoROI::FUN_100a9bf0(const LegoChar* p_param, float& p_red, float& p_green, float& p_blue, float& p_alpha)
LegoBool LegoROI::GetColorFromGlobalHandlerOrAlias(
const LegoChar* p_param,
float& p_red,
float& p_green,
float& p_blue,
float& p_alpha
)
{
if (p_param == NULL) {
return FALSE;
}
if (g_unk0x101013ac) {
if (g_roiHandler) {
char buf[32];
if (g_unk0x101013ac(p_param, buf, sizeof(buf))) {
if (g_roiHandler(p_param, buf, sizeof(buf))) {
p_param = buf;
}
}
@ -789,14 +795,18 @@ LegoBool LegoROI::ColorAliasLookup(const LegoChar* p_param, float& p_red, float&
}
// FUNCTION: LEGO1 0x100a9cf0
LegoBool LegoROI::FUN_100a9cf0(const LegoChar* p_param, unsigned char* paletteEntries, LegoU32 p_numEntries)
LegoBool LegoROI::GetPaletteEntriesFromGlobalHandler(
const LegoChar* p_param,
unsigned char* paletteEntries,
LegoU32 p_numEntries
)
{
if (p_param == NULL) {
return FALSE;
}
if (g_unk0x101013b0 != NULL) {
return g_unk0x101013b0(p_param, paletteEntries, p_numEntries);
if (g_textureHandler != NULL) {
return g_textureHandler(p_param, paletteEntries, p_numEntries);
}
paletteEntries[0] = '\0';
@ -804,9 +814,9 @@ LegoBool LegoROI::FUN_100a9cf0(const LegoChar* p_param, unsigned char* paletteEn
}
// FUNCTION: LEGO1 0x100a9d30
void LegoROI::FUN_100a9d30(ROIHandler p_func)
void LegoROI::SetGlobalROIHandler(ROIHandler p_func)
{
g_unk0x101013ac = p_func;
g_roiHandler = p_func;
}
// FUNCTION: LEGO1 0x100a9d40
@ -828,12 +838,12 @@ void LegoROI::SetName(const LegoChar* p_name)
// FUNCTION: LEGO1 0x100a9dd0
// FUNCTION: BETA10 0x1018bfdb
void LegoROI::FUN_100a9dd0()
void LegoROI::ClearMeshOffset()
{
int lodCount = GetLODCount();
for (LegoS32 i = 0; i < lodCount; i++) {
LegoLOD* lod = (LegoLOD*) GetLOD(i);
lod->FUN_100aae60();
lod->ClearMeshOffset();
}
}

View File

@ -36,26 +36,32 @@ class LegoROI : public ViewROI {
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);
LegoResult FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha);
LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo);
LegoResult SetLodColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha);
LegoResult SetTexture(LegoTextureInfo* p_textureInfo);
LegoResult GetTexture(LegoTextureInfo*& p_textureInfo);
LegoResult FUN_100a9330(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha);
LegoResult FUN_100a9350(const LegoChar* p_color);
LegoResult FUN_100a93b0(const LegoChar* p_color);
LegoResult SetCustomLodColor2(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha);
LegoResult SetColorNamed(const LegoChar* p_color);
LegoResult SetColorNamed2(const LegoChar* p_color);
LegoU32 FUN_100a9410(Vector3& p_v1, Vector3& p_v2, float p_f1, float p_f2, Vector3& p_v3, LegoBool p_collideBox);
void SetName(const LegoChar* p_name);
float IntrinsicImportance() const override; // vtable+0x04
void UpdateWorldBoundingVolumes() override; // vtable+0x18
void FUN_100a9dd0();
void ClearMeshOffset();
void SetDisplayBB(int p_displayBB);
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 void SetGlobalROIHandler(ROIHandler p_func);
static LegoBool GetColorFromGlobalHandlerOrAlias(
const LegoChar* p_param,
float& p_red,
float& p_green,
float& p_blue,
float& p_alpha
);
static LegoBool ColorAliasLookup(
const LegoChar* p_param,
float& p_red,
@ -63,7 +69,11 @@ class LegoROI : public ViewROI {
float& p_blue,
float& p_alpha
);
static LegoBool FUN_100a9cf0(const LegoChar* p_param, unsigned char* paletteEntries, LegoU32 p_numEntries);
static LegoBool GetPaletteEntriesFromGlobalHandler(
const LegoChar* p_param,
unsigned char* paletteEntries,
LegoU32 p_numEntries
);
// FUNCTION: BETA10 0x1000f320
const LegoChar* GetName() const { return m_name; }