From 01735bdc286a1aa39dbfc3cf8273b000f27b186a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 18 May 2024 12:27:14 -0400 Subject: [PATCH] Implement/match ViewManager::FUN_100a6150 (#934) --- LEGO1/viewmanager/viewmanager.cpp | 33 ++++++++++++++++++++++++++++--- LEGO1/viewmanager/viewmanager.h | 2 +- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/LEGO1/viewmanager/viewmanager.cpp b/LEGO1/viewmanager/viewmanager.cpp index 9db4ba6f..e71e3d2f 100644 --- a/LEGO1/viewmanager/viewmanager.cpp +++ b/LEGO1/viewmanager/viewmanager.cpp @@ -8,6 +8,9 @@ DECOMP_SIZE_ASSERT(ViewManager, 0x1bc) +// GLOBAL: LEGO1 0x100dbc78 +int g_unk0x100dbc78[8][3] = {{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}}; + // GLOBAL: LEGO1 0x100dbcd8 int g_unk0x100dbcd8[18] = {0, 1, 5, 6, 2, 3, 3, 0, 4, 1, 2, 6, 0, 3, 2, 4, 5, 6}; @@ -55,11 +58,35 @@ ViewManager::~ViewManager() SetPOVSource(NULL); } -// STUB: LEGO1 0x100a6150 +// FUNCTION: LEGO1 0x100a6150 // FUNCTION: BETA10 0x10172164 -undefined4 ViewManager::FUN_100a6150(const BoundingBox& p_bounding_box) +unsigned int ViewManager::FUN_100a6150(const BoundingBox& p_bounding_box) { - return 1; + const Vector3* box[] = {&p_bounding_box.Min(), &p_bounding_box.Max()}; + + float und[8][3]; + int i, j, k; + + for (i = 0; i < 8; i++) { + for (j = 0; j < 3; j++) { + und[i][j] = box[g_unk0x100dbc78[i][j]]->operator[](j); + } + } + + for (i = 0; i < 6; i++) { + for (k = 0; k < 8; k++) { + if (unk0x150[i][0] * und[k][0] + unk0x150[i][2] * und[k][2] + unk0x150[i][1] * und[k][1] + unk0x150[i][3] >= + 0.0f) { + break; + } + } + + if (k == 8) { + return FALSE; + } + } + + return TRUE; } // FUNCTION: LEGO1 0x100a6410 diff --git a/LEGO1/viewmanager/viewmanager.h b/LEGO1/viewmanager/viewmanager.h index f2fdcdb4..3f9d1826 100644 --- a/LEGO1/viewmanager/viewmanager.h +++ b/LEGO1/viewmanager/viewmanager.h @@ -23,7 +23,7 @@ class ViewManager { void Remove(ViewROI* p_roi); void RemoveAll(ViewROI* p_roi); - undefined4 FUN_100a6150(const BoundingBox& p_bounding_box); + unsigned int FUN_100a6150(const BoundingBox& p_bounding_box); void FUN_100a65b0(ViewROI* p_roi, int p_und); void FUN_100a66a0(ViewROI* p_roi); void SetPOVSource(const OrientableROI* point_of_view);