From 093e9d857852be51ffd05743db8a26a32db7a9c4 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 20 Dec 2024 11:41:54 -0700 Subject: [PATCH] Fixes --- LEGO1/tgl/d3drm/group.cpp | 111 ++++++++++++++++++++------------------ LEGO1/tgl/d3drm/impl.h | 2 +- LEGO1/tgl/tgl.h | 2 +- 3 files changed, 62 insertions(+), 53 deletions(-) diff --git a/LEGO1/tgl/d3drm/group.cpp b/LEGO1/tgl/d3drm/group.cpp index bb05ef12..d125296c 100644 --- a/LEGO1/tgl/d3drm/group.cpp +++ b/LEGO1/tgl/d3drm/group.cpp @@ -113,57 +113,66 @@ Result GroupImpl::RemoveAll() } // FUNCTION: LEGO1 0x100a3540 -Result GroupImpl::Bounds(D3DVECTOR *p_min, D3DVECTOR *p_max) +Result GroupImpl::Bounds(D3DVECTOR* p_min, D3DVECTOR* p_max) { - D3DRMBOX size; - IDirect3DRMFrame2 *frame = m_data; - size.min.x = 88888.f; - size.min.y = 88888.f; - size.min.z = 88888.f; - size.max.x = -88888.f; - size.max.y = -88888.f; - size.max.z = -88888.f; - IDirect3DRMVisualArray *visuals; - Result result = (Result) SUCCEEDED(frame->GetVisuals(&visuals)); - if (result) { - int i; - for (i = 0; i < (int)visuals->GetSize(); i++) { - IDirect3DRMVisual *visual; - visuals->GetElement(i, &visual); - IDirect3DRMMesh *mesh; - /* - * BUG: should be: - * visual->QueryInterface(IID_IDirect3DRMMesh, (void**)&mesh)); - */ - result = (Result) SUCCEEDED(visual->QueryInterface(IID_IDirect3DRMMeshBuilder, (void**)&mesh)); - if (result) { - D3DRMBOX box; - result = (Result) SUCCEEDED(mesh->GetBox(&box)); - if (size.max.y < box.max.y) { - size.max.y = box.max.y; - } - if (size.max.z < box.max.z) { - size.max.z = box.max.z; - } - if (box.min.x < size.min.x) { - size.min.x = box.min.x; - } - if (box.min.y < size.min.y) { - size.min.y = box.min.y; - } - if (box.min.z < size.min.z) { - size.min.z = box.min.z; - } - if (size.max.x < box.max.x) { - size.max.x = box.max.x; - } - mesh->Release(); - } - visual->Release(); - } - visuals->Release(); - } - *p_min = size.min; - *p_max = size.max; + D3DRMBOX size; + IDirect3DRMFrame2* frame = m_data; + + size.min.x = 88888.f; + size.min.y = 88888.f; + size.min.z = 88888.f; + size.max.x = -88888.f; + size.max.y = -88888.f; + size.max.z = -88888.f; + + IDirect3DRMVisualArray* visuals; + Result result = (Result) SUCCEEDED(frame->GetVisuals(&visuals)); + + if (result == Success) { + int i; + for (i = 0; i < (int) visuals->GetSize(); i++) { + IDirect3DRMVisual* visual; + visuals->GetElement(i, &visual); + IDirect3DRMMesh* mesh; + /* + * BUG: should be: + * visual->QueryInterface(IID_IDirect3DRMMesh, (void**)&mesh)); + */ + result = (Result) SUCCEEDED(visual->QueryInterface(IID_IDirect3DRMMeshBuilder, (void**) &mesh)); + + if (result == Success) { + D3DRMBOX box; + result = (Result) SUCCEEDED(mesh->GetBox(&box)); + + if (size.max.y < box.max.y) { + size.max.y = box.max.y; + } + if (size.max.z < box.max.z) { + size.max.z = box.max.z; + } + if (box.min.x < size.min.x) { + size.min.x = box.min.x; + } + if (box.min.y < size.min.y) { + size.min.y = box.min.y; + } + if (box.min.z < size.min.z) { + size.min.z = box.min.z; + } + if (size.max.x < box.max.x) { + size.max.x = box.max.x; + } + + mesh->Release(); + } + + visual->Release(); + } + + visuals->Release(); + } + + *p_min = size.min; + *p_max = size.max; return result; } diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index b2e82f1c..a2998c7a 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -335,7 +335,7 @@ class GroupImpl : public Group { Result RemoveAll() override; // vtable+0x30 - Result Bounds(D3DVECTOR *p_min, D3DVECTOR *p_max) override; + Result Bounds(D3DVECTOR* p_min, D3DVECTOR* p_max) override; IDirect3DRMFrame2* ImplementationData() const { return m_data; } diff --git a/LEGO1/tgl/tgl.h b/LEGO1/tgl/tgl.h index 830e9286..34b1d5ee 100644 --- a/LEGO1/tgl/tgl.h +++ b/LEGO1/tgl/tgl.h @@ -305,7 +305,7 @@ class Group : public Object { // This is TransformLocalToWorld in the leak, however it seems // to have been replaced by something else in the shipped code. - virtual Result Bounds(D3DVECTOR *, D3DVECTOR *) = 0; + virtual Result Bounds(D3DVECTOR*, D3DVECTOR*) = 0; // SYNTHETIC: LEGO1 0x100a2510 // Tgl::Group::~Group