/** Create a new simulator. * * \param workers Use the specified number of worker threads.\n * When the number zero is specified, no multithreading will be used. * A good number is the number of cores on the machine. * * \param doubleBuffering Use Double Buffering for calculations. * Testing done with 5000 agents and 0.1 desired delta time showed that with double buffering enabled * the game ran at 50 fps for most frames, dropping to 10 fps during calculation frames. But without double buffering * it ran at around 10 fps all the time.\n * This will let threads calculate while the game progresses instead of waiting for the calculations * to finish. * \note Will only have effect if using multithreading * * \see #Multithreading */ public Simulator(int workers, bool doubleBuffering) { this.workers = new Simulator.Worker[workers]; this.doubleBuffering = doubleBuffering; this.DesiredDeltaTime = 1; Quadtree = new RVOQuadtree(); for (int i = 0; i < workers; i++) { this.workers[i] = new Simulator.Worker(this); } agents = new List <Agent>(); obstacles = new List <ObstacleVertex>(); }
/** Create a new simulator. * * \param workers Use the specified number of worker threads.\n * When the number zero is specified, no multithreading will be used. * A good number is the number of cores on the machine. * \param doubleBuffering Use Double Buffering for calculations. * Testing done with 5000 agents and 0.1 desired delta time showed that with double buffering enabled * the game ran at 50 fps for most frames, dropping to 10 fps during calculation frames. But without double buffering * it ran at around 10 fps all the time.\n * This will let threads calculate while the game progresses instead of waiting for the calculations * to finish. * \param movementPlane The plane that the movement happens in. XZ for 3D games, XY for 2D games. * * \note Will only have effect if using multithreading * * \see #Multithreading */ public Simulator(int workers, bool doubleBuffering, MovementPlane movementPlane) { this.workers = new Simulator.Worker[workers]; this.doubleBuffering = doubleBuffering; //GG //this.DesiredDeltaTime = 1; this.DesiredDeltaTime = VFactor.one; this.movementPlane = movementPlane; Quadtree = new RVOQuadtree(); for (int i = 0; i < workers; i++) { this.workers[i] = new Simulator.Worker(this); } agents = new List <Agent>(); obstacles = new List <ObstacleVertex>(); }