// Integrate the motion of the balls, including collision detection and resolution public void IntegrateMotion(float timeStep) { CheckCollisions_Grid(timeStep); foreach (Ball ball in balls) { ball.CheckBoundary(boxSize); ball.MoveBall(timeStep); ball.Fade(); } // Update grid grid.Empty(); List <Vector3> positions = balls.Select(o => o.position).ToList(); // make a list of the ball positions grid.Fill(positions, balls, ballRadius); }