Improve LegoBuildingManager::FUN_10030630

This commit is contained in:
jonschz 2024-12-14 09:28:35 +01:00
parent a60019a86c
commit 77e8f06403
2 changed files with 25 additions and 22 deletions

View File

@ -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 {

View File

@ -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