Implement ViewManager::FUN_100a65b0 (#650)

This commit is contained in:
Christian Semmler 2024-03-09 23:12:15 -05:00 committed by GitHub
parent a55b01d186
commit 660c1e1170
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 65 additions and 8 deletions

View file

@ -86,11 +86,10 @@ Result GroupImpl::Add(const Group* pGroup)
}
// FUNCTION: LEGO1 0x100a3430
Result GroupImpl::Add(const Mesh* pMesh)
Result GroupImpl::Add(const MeshBuilder* pMeshBuilder)
{
const MeshImpl* pMeshImpl = static_cast<const MeshImpl*>(pMesh);
// TODO: Incorrect structure
return ResultVal(m_data->AddVisual((IDirect3DRMMesh*) pMeshImpl->ImplementationData()));
const MeshBuilderImpl* pMeshBuilderImpl = static_cast<const MeshBuilderImpl*>(pMeshBuilder);
return ResultVal(m_data->AddVisual(pMeshBuilderImpl->ImplementationData()));
}
// FUNCTION: LEGO1 0x100a3450

View file

@ -321,7 +321,7 @@ public:
Result Add(const Group*) override;
// vtable+0x20
Result Add(const Mesh*) override;
Result Add(const MeshBuilder*) override;
Result Remove(const Group*) override;
Result Remove(const MeshBuilder*) override;
Result RemoveAll() override;

View file

@ -298,7 +298,7 @@ public:
virtual Result GetTexture(Texture*&) = 0;
virtual Result SetMaterialMode(MaterialMode) = 0;
virtual Result Add(const Group*) = 0;
virtual Result Add(const Mesh*) = 0;
virtual Result Add(const MeshBuilder*) = 0;
virtual Result Remove(const Group*) = 0;
virtual Result Remove(const MeshBuilder*) = 0;
virtual Result RemoveAll() = 0;

View file

@ -28,6 +28,7 @@ public:
Tgl::MeshBuilder* GetMeshBuilder() { return m_meshBuilder; }
const Tgl::MeshBuilder* GetMeshBuilder() const { return m_meshBuilder; }
undefined4 GetUnknown0x08() { return m_unk0x08; }
unsigned char GetUnknown0x08Test4() { return m_unk0x08 & 0xffffff04; }
unsigned char GetUnknown0x08Test8() { return m_unk0x08 & 0xffffff08; }

View file

@ -24,6 +24,7 @@ float g_unk0x1010105c = 0.000125F;
// GLOBAL: LEGO1 0x10101060
float g_elapsedSeconds = 0;
inline void SetAppData(ViewROI* p_roi, DWORD data);
inline undefined4 GetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer);
inline undefined4 GetFrame(IDirect3DRMFrame2*& frame, Tgl::Group* scene);
@ -106,10 +107,57 @@ void ViewManager::RemoveAll(ViewROI* p_roi)
}
}
// STUB: LEGO1 0x100a65b0
// FUNCTION: LEGO1 0x100a65b0
void ViewManager::FUN_100a65b0(ViewROI* p_roi, int p_und)
{
// TODO
if (p_roi->GetLODCount() <= p_und) {
p_und = p_roi->GetLODCount() - 1;
}
int unk0xe0 = p_roi->GetUnknown0xe0();
if (unk0xe0 == p_und) {
return;
}
Tgl::Group* group = p_roi->GetGeometry();
Tgl::MeshBuilder* meshBuilder;
ViewLOD* lod;
if (unk0xe0 < 0) {
lod = (ViewLOD*) p_roi->GetLOD(p_und);
if (lod->GetUnknown0x08() & ViewLOD::c_bit4) {
scene->Add((Tgl::MeshBuilder*) group);
SetAppData(p_roi, (DWORD) p_roi);
}
}
else {
lod = (ViewLOD*) p_roi->GetLOD(unk0xe0);
if (lod != NULL) {
meshBuilder = lod->GetMeshBuilder();
if (meshBuilder != NULL) {
group->Remove(meshBuilder);
}
}
lod = (ViewLOD*) p_roi->GetLOD(p_und);
}
if (lod->GetUnknown0x08() & ViewLOD::c_bit4) {
meshBuilder = lod->GetMeshBuilder();
if (meshBuilder != NULL) {
group->Add(meshBuilder);
SetAppData(p_roi, (DWORD) p_roi);
p_roi->SetUnknown0xe0(p_und);
return;
}
}
p_roi->SetUnknown0xe0(-1);
}
// FUNCTION: LEGO1 0x100a66a0
@ -399,6 +447,15 @@ ViewROI* ViewManager::Pick(Tgl::View* p_view, unsigned long x, unsigned long y)
return NULL;
}
inline void SetAppData(ViewROI* p_roi, DWORD data)
{
IDirect3DRMFrame2* frame = NULL;
if (GetFrame(frame, p_roi->GetGeometry()) == 0) {
frame->SetAppData(data);
}
}
inline undefined4 GetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer)
{
d3drm = ((TglImpl::RendererImpl*) pRenderer)->ImplementationData();