From 05965f53570f343eba0d14bff2b31aa5c32261f6 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 2 Mar 2024 09:43:19 -0500 Subject: [PATCH] Implement/match ViewManager ctor/dtor/structure (#614) * Implement/match ViewManager constructor/structure * Add dtor --- LEGO1/realtime/realtimeview.cpp | 11 ++++++++ LEGO1/realtime/realtimeview.h | 3 ++ LEGO1/tgl/d3drm/impl.h | 2 ++ LEGO1/viewmanager/viewmanager.cpp | 40 +++++++++++++++++++++++++-- LEGO1/viewmanager/viewmanager.h | 46 +++++++++++++++++++++++++++---- 5 files changed, 94 insertions(+), 8 deletions(-) diff --git a/LEGO1/realtime/realtimeview.cpp b/LEGO1/realtime/realtimeview.cpp index 9522d1c1..afe0e790 100644 --- a/LEGO1/realtime/realtimeview.cpp +++ b/LEGO1/realtime/realtimeview.cpp @@ -14,6 +14,17 @@ float g_userMaxLod = 3.6f; // GLOBAL: LEGO1 0x1010104c float g_partsThreshold = 1000.0f; +// FUNCTION: LEGO1 0x100a5dc0 +RealtimeView::RealtimeView() +{ + UpdateMaxLOD(); +} + +// FUNCTION: LEGO1 0x100a5dd0 +RealtimeView::~RealtimeView() +{ +} + // FUNCTION: LEGO1 0x100a5de0 void RealtimeView::SetUserMaxLOD(float p_lod) { diff --git a/LEGO1/realtime/realtimeview.h b/LEGO1/realtime/realtimeview.h index f732c480..10a45617 100644 --- a/LEGO1/realtime/realtimeview.h +++ b/LEGO1/realtime/realtimeview.h @@ -3,6 +3,9 @@ class RealtimeView { public: + RealtimeView(); + ~RealtimeView(); + static float GetPartsThreshold(); static float GetUserMaxLOD(); static void SetPartsThreshold(float); diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index 78b16641..69caa85e 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -84,6 +84,8 @@ class RendererImpl : public Renderer { return m_data->CreateTextureFromSurface(pSurface, pTexture2); } + inline IDirect3DRM2* ImplementationData() const { return m_data; } + public: inline Result Create(); inline void Destroy(); diff --git a/LEGO1/viewmanager/viewmanager.cpp b/LEGO1/viewmanager/viewmanager.cpp index 3e68f78e..c72c10d3 100644 --- a/LEGO1/viewmanager/viewmanager.cpp +++ b/LEGO1/viewmanager/viewmanager.cpp @@ -1,17 +1,35 @@ #include "viewmanager.h" -#include "decomp.h" +#include "tgl/d3drm/impl.h" DECOMP_SIZE_ASSERT(ViewManager, 0x1bc) -// STUB: LEGO1 0x100a5eb0 +inline undefined4 SetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer); +inline undefined4 SetFrame(IDirect3DRMFrame2*& frame, Tgl::Group* scene); + +// FUNCTION: LEGO1 0x100a5eb0 ViewManager::ViewManager(Tgl::Renderer* pRenderer, Tgl::Group* scene, const OrientableROI* point_of_view) + : scene(scene), flags(c_bit1 | c_bit2 | c_bit3 | c_bit4) { + SetPOVSource(point_of_view); + unk0x28 = 0.09; + SetD3DRM(d3drm, pRenderer); + SetFrame(frame, scene); + unk0x34 = 0.0; + unk0x38 = 0.0; + unk0x3c = 0.0; + unk0x40.SetIdentity(); + unk0x88 = 0.0; + unk0x8c = 0.0; + + memset(unk0xf0, 0, sizeof(unk0xf0)); + seconds_allowed = 1.0; } -// STUB: LEGO1 0x100a60c0 +// FUNCTION: LEGO1 0x100a60c0 ViewManager::~ViewManager() { + SetPOVSource(NULL); } // STUB: LEGO1 0x100a64d0 @@ -23,19 +41,35 @@ void ViewManager::RemoveAll(ViewROI*) // STUB: LEGO1 0x100a6930 void ViewManager::Update(float p_previousRenderTime, float p_und2) { + // TODO } // STUB: LEGO1 0x100a6d50 void ViewManager::SetResolution(int width, int height) { + // TODO } // STUB: LEGO1 0x100a6d70 void ViewManager::SetFrustrum(float fov, float front, float back) { + // TODO } // STUB: LEGO1 0x100a6da0 void ViewManager::SetPOVSource(const OrientableROI* point_of_view) { + // TODO +} + +inline undefined4 SetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer) +{ + d3drm = ((TglImpl::RendererImpl*) pRenderer)->ImplementationData(); + return 0; +} + +inline undefined4 SetFrame(IDirect3DRMFrame2*& frame, Tgl::Group* scene) +{ + frame = ((TglImpl::GroupImpl*) scene)->ImplementationData(); + return 0; } diff --git a/LEGO1/viewmanager/viewmanager.h b/LEGO1/viewmanager/viewmanager.h index 237a5f98..19398ef8 100644 --- a/LEGO1/viewmanager/viewmanager.h +++ b/LEGO1/viewmanager/viewmanager.h @@ -1,12 +1,23 @@ #ifndef VIEWMANAGER_H #define VIEWMANAGER_H +#include "decomp.h" +#include "realtime/realtimeview.h" #include "viewroi.h" +#include + // VTABLE: LEGO1 0x100dbd88 // SIZE 0x1bc class ViewManager { public: + enum Flags { + c_bit1 = 0x01, + c_bit2 = 0x02, + c_bit3 = 0x04, + c_bit4 = 0x08 + }; + ViewManager(Tgl::Renderer* pRenderer, Tgl::Group* scene, const OrientableROI* point_of_view); virtual ~ViewManager(); @@ -20,17 +31,42 @@ class ViewManager { // SYNTHETIC: LEGO1 0x100a6000 // ViewManager::`scalar deleting destructor' - inline CompoundObject& GetUnknown0x08() { return m_unk0x08; } + inline CompoundObject& GetUnknown0x08() { return unk0x08; } - inline void AddToUnknown0x08(ViewROI* p_roi) { m_unk0x08.push_back(p_roi); } + inline void AddToUnknown0x08(ViewROI* p_roi) { unk0x08.push_back(p_roi); } private: - undefined4 m_unk0x04; // 0x04 - CompoundObject m_unk0x08; // 0x08 - undefined m_pad[0x1a8]; // 0x14 + Tgl::Group* scene; // 0x04 + CompoundObject unk0x08; // 0x08 + RealtimeView rt_view; // 0x14 + ROIList visible_rois; // 0x18 + float unk0x28; // 0x28 + undefined4 unk0x2c; // 0x2c + unsigned int flags; // 0x30 + float unk0x34; // 0x34 + float unk0x38; // 0x38 + float unk0x3c; // 0x3c + MxMatrix unk0x40; // 0x40 + float unk0x88; // 0x88 + float unk0x8c; // 0x8c + undefined unk0x90[0x60]; // 0x90 + undefined unk0xf0[0x60]; // 0xf0 + undefined unk0x150[0x60]; // 0x150 + IDirect3DRM2* d3drm; // 0x1b0 + IDirect3DRMFrame2* frame; // 0x1b4 + float seconds_allowed; // 0x1b8 }; // TEMPLATE: LEGO1 0x10022030 // list >::insert +// TEMPLATE: LEGO1 0x100a6020 +// List::~List + +// TEMPLATE: LEGO1 0x100a6070 +// Vector::~Vector + +// TEMPLATE: LEGO1 0x100a6f80 +// vector >::~vector > + #endif // VIEWMANAGER_H