Update dpGrid.cpp

This commit is contained in:
David Markowitz 2024-02-04 16:44:40 -08:00
parent 8e29148137
commit a88ef0c325

View File

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