From 7286f77e83ebea2a1e52dec87e345f0545b47e9e Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 20:39:54 +0000 Subject: [PATCH] bugfix(partitioning): Correct cell world coordinate calculation for overlap checks --- .../Source/GameLogic/Object/PartitionManager.cpp | 10 ++++++++-- .../Source/GameLogic/Object/PartitionManager.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp index c954025becd..7f8f5f593cf 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp @@ -1887,13 +1887,19 @@ void PartitionData::doCircleFillPrecise(Real centerX, Real centerY, Real radius) ThePartitionManager->worldToCell(centerX + radius, centerY + radius, &maxCellX, &maxCellY); Real cellSize = ThePartitionManager->getCellSize(); + Real halfCellSize = cellSize * 0.5f; for (Int x = minCellX; x <= maxCellX; ++x) { for (Int y = minCellY; y <= maxCellY; ++y) { - Real cellWorldX = x * cellSize; - Real cellWorldY = y * cellSize; + // getCellCenterPos returns the world-space center of the cell, accounting for + // m_worldExtents.lo offset. Subtracting halfCellSize gives the lower-left corner, + // which is what doesCircleOverlapCell expects. + Real cellWorldX, cellWorldY; + ThePartitionManager->getCellCenterPos(x, y, cellWorldX, cellWorldY); + cellWorldX -= halfCellSize; + cellWorldY -= halfCellSize; if (doesCircleOverlapCell(centerX, centerY, radius, cellWorldX, cellWorldY, cellSize)) { diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp index b5e7985605e..ac51a43f5a3 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp @@ -1891,13 +1891,19 @@ void PartitionData::doCircleFillPrecise(Real centerX, Real centerY, Real radius) ThePartitionManager->worldToCell(centerX + radius, centerY + radius, &maxCellX, &maxCellY); Real cellSize = ThePartitionManager->getCellSize(); + Real halfCellSize = cellSize * 0.5f; for (Int x = minCellX; x <= maxCellX; ++x) { for (Int y = minCellY; y <= maxCellY; ++y) { - Real cellWorldX = x * cellSize; - Real cellWorldY = y * cellSize; + // getCellCenterPos returns the world-space center of the cell, accounting for + // m_worldExtents.lo offset. Subtracting halfCellSize gives the lower-left corner, + // which is what doesCircleOverlapCell expects. + Real cellWorldX, cellWorldY; + ThePartitionManager->getCellCenterPos(x, y, cellWorldX, cellWorldY); + cellWorldX -= halfCellSize; + cellWorldY -= halfCellSize; if (doesCircleOverlapCell(centerX, centerY, radius, cellWorldX, cellWorldY, cellSize)) {