public void Execute() { while (movingParticles.Count > 0) { MovingEntity movingParticle = movingParticles.Dequeue(); // remove from old cell: int cellIndex; if (grid.TryGetCellIndex(movingParticle.oldCellCoord, out cellIndex)) { var oldCell = grid.usedCells[cellIndex]; oldCell.Remove(movingParticle.entity); grid.usedCells[cellIndex] = oldCell; } // add to new cell: cellIndex = grid.GetOrCreateCell(movingParticle.newCellCoord); var newCell = grid.usedCells[cellIndex]; newCell.Add(movingParticle.entity); grid.usedCells[cellIndex] = newCell; } grid.RemoveEmpty(); }
public void Execute() { grid.Clear(); for (int i = 0; i < simplexCount; ++i) { // add to new cell: int cellIndex = grid.GetOrCreateCell(cellCoords[i]); var newCell = grid.usedCells[cellIndex]; newCell.Add(i); grid.usedCells[cellIndex] = newCell; } }