diff --git a/dPhysics/dpGrid.cpp b/dPhysics/dpGrid.cpp index 6e38be92..8ec944fd 100644 --- a/dPhysics/dpGrid.cpp +++ b/dPhysics/dpGrid.cpp @@ -77,8 +77,8 @@ void dpGrid::Delete(dpEntity* entity) { int oldCellZ = (int)std::round(entity->m_Position.z) / dpGrid::CELL_SIZE + NUM_CELLS / 2; // Clamp values to the range [0, NUM_CELLS - 1] - cellX = std::clamp(oldCellX, 0, NUM_CELLS - 1); - cellZ = std::clamp(oldCellZ, 0, NUM_CELLS - 1); + oldCellX = std::clamp(oldCellX, 0, NUM_CELLS - 1); + oldCellZ = std::clamp(oldCellZ, 0, NUM_CELLS - 1); auto& cell = m_Cells[oldCellX][oldCellZ]; auto toRemove = std::find(cell.begin(), cell.end(), entity);