From 77e8f0640352f04d7cea38a4a738829fb4f8a3d6 Mon Sep 17 00:00:00 2001 From: jonschz Date: Sat, 14 Dec 2024 09:28:35 +0100 Subject: [PATCH] Improve `LegoBuildingManager::FUN_10030630` --- .../src/common/legobuildingmanager.cpp | 43 ++++++++++--------- LEGO1/mxgeometry/mxgeometry3d.h | 4 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp index c02a86b8..9e1ddf62 100644 --- a/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp @@ -221,6 +221,7 @@ char* LegoBuildingManager::g_customizeAnimFile = NULL; MxS32 g_buildingManagerConfig = 1; // GLOBAL: LEGO1 0x10104c30 +// GLOBAL: BETA10 0x10209fa0 LegoBuildingInfo g_buildingInfo[16]; // GLOBAL: LEGO1 0x100f3748 @@ -808,7 +809,7 @@ MxResult LegoBuildingManager::FUN_10030630() for (MxS32 j = 0; j < boundary->GetNumEdges(); j++) { Mx4DPointFloat* normal = boundary->GetEdgeNormal(j); - if (position.Dot(normal, &position) + (*normal)[3] < -0.001) { + if (position.Dot(normal, &position) + (*normal).index_operator(3) < -0.001) { MxTrace( "Building %d shot location (%g, %g, %g) is not in boundary %s.\n", i, @@ -825,26 +826,28 @@ MxResult LegoBuildingManager::FUN_10030630() if (g_buildingInfo[i].m_boundary != NULL) { Mx4DPointFloat& unk0x14 = *g_buildingInfo[i].m_boundary->GetUnknown0x14(); - if (position.Dot(&position, &unk0x14) + unk0x14[3] <= 0.001 && - position.Dot(&position, &unk0x14) + unk0x14[3] >= -0.001) { - continue; + if (position.Dot(&position, &unk0x14) + unk0x14.index_operator(3) > 0.001 || + position.Dot(&position, &unk0x14) + unk0x14.index_operator(3) < -0.001) { + + g_buildingInfo[i].m_y = + -((position[0] * unk0x14.index_operator(0) + unk0x14.index_operator(3) + + position[2] * unk0x14.index_operator(2)) / + unk0x14.index_operator(1)); + + MxTrace( + "Building %d shot location (%g, %g, %g) is not on plane of boundary %s...adjusting to (%g, " + "%g, " + "%g)\n", + i, + position[0], + position[1], + position[2], + g_buildingInfo[i].m_boundary->GetName(), + position[0], + g_buildingInfo[i].m_y, + position[2] + ); } - - g_buildingInfo[i].m_y = - -((unk0x14[3] + unk0x14[0] * position[0] + unk0x14[2] * position[2]) / unk0x14[1]); - - MxTrace( - "Building %d shot location (%g, %g, %g) is not on plane of boundary %s...adjusting to (%g, %g, " - "%g)\n", - i, - position[0], - position[1], - position[2], - g_buildingInfo[i].m_boundary->GetName(), - position[0], - g_buildingInfo[i].m_y, - position[2] - ); } } else { diff --git a/LEGO1/mxgeometry/mxgeometry3d.h b/LEGO1/mxgeometry/mxgeometry3d.h index 039d96af..1cfa82ac 100644 --- a/LEGO1/mxgeometry/mxgeometry3d.h +++ b/LEGO1/mxgeometry/mxgeometry3d.h @@ -76,8 +76,8 @@ class Mx4DPointFloat : public Vector4 { // FUNCTION: BETA10 0x1004af10 float& operator[](int idx) { return m_data[idx]; } - const float& operator[](int idx) const { return m_data[idx]; } - + // According to the PDB, BETA10 will not link this one if it is never used + // const float& operator[](int idx) const { return m_data[idx]; } // only used by a couple of BETA10 functions for some unknown reason // FUNCTION: BETA10 0x1001c950