private void moveParticles() { Parallel.ForEach(_sharedList.getParticles(), p => { if (p != null) { p.move(); } }); }
public void checkCollisions() { foreach (Particle p in _particleList.getParticles()) { if (p != null) { List <Particle> oldCell = getCell(p.OldPos); if (oldCell != null) { List <Particle> newCell = getCell(p.Pos); if (newCell != null) { if (oldCell != newCell) { newCell.Add(p); if (oldCell.Contains(p)) { oldCell.Remove(p); } } } } } } Parallel.ForEach(_particleList.getParticles(), p => { if (p != null) { List <Particle> cell = getCell(p.Pos); if (cell != null) { p.collide(cell.ToArray()); } } }); Parallel.ForEach(_particleList.getParticles(), p => { if (p != null) { p.collide(_heightMap); } }); }