//user-defined gravity public PhysicsManager(Game game, EventDispatcher eventDispatcher, StatusType statusType, Vector3 gravity) : base(game, eventDispatcher, statusType) { this.physicSystem = new PhysicsSystem(); //add cd/cr system this.physicSystem.CollisionSystem = new CollisionSystemSAP(); //allows us to define the direction and magnitude of gravity - default is (0, -9.8f, 0) this.physicSystem.Gravity = gravity; //25/11/17 - prevents bug where objects would show correct CDCR response when velocity == Vector3.Zero this.physicSystem.EnableFreezing = false; this.physicSystem.SolverType = PhysicsSystem.Solver.Normal; this.physicSystem.CollisionSystem.UseSweepTests = true; //affect accuracy and the overhead == time required this.physicSystem.NumCollisionIterations = 8; //8 this.physicSystem.NumContactIterations = 8; //8 this.physicSystem.NumPenetrationRelaxtionTimesteps = 12; //15 #region SETTING_COLLISION_ACCURACY //affect accuracy of the collision detection this.physicSystem.AllowedPenetration = 0.000025f; this.physicSystem.CollisionTollerance = 0.00005f; #endregion this.physCont = new PhysicsController(); this.physicSystem.AddController(physCont); //batch removal - as in ObjectManager this.removeList = new List <CollidableObject>(); }
public PhysicsManager(Main game) : base(game) { this.game = game; this.physicSystem = new PhysicsSystem(); //add cd/cr system this.physicSystem.CollisionSystem = new CollisionSystemSAP(); this.physicSystem.EnableFreezing = true; this.physicSystem.SolverType = PhysicsSystem.Solver.Normal; this.physicSystem.CollisionSystem.UseSweepTests = true; //affect accuracy and the overhead == time required this.physicSystem.NumCollisionIterations = 8; //8 this.physicSystem.NumContactIterations = 8; //8 this.physicSystem.NumPenetrationRelaxtionTimesteps = 12; //15 #region SETTING_COLLISION_ACCURACY //affect accuracy of the collision detection this.physicSystem.AllowedPenetration = 0.000025f; this.physicSystem.CollisionTollerance = 0.00005f; #endregion this.physCont = new PhysicsController(); this.physicSystem.AddController(physCont); this.physicsDebugDrawer = new PhysicsDebugDrawer(game); game.Components.Add(this.physicsDebugDrawer); }
public PhysicsManager(Main game, bool bEnableDebugDrawer) : base(game) { this.game = game; this.bEnableDebugDrawer = bEnableDebugDrawer; this.physicSystem = new PhysicsSystem(); //add cd/cr system this.physicSystem.CollisionSystem = new CollisionSystemSAP(); this.physicSystem.EnableFreezing = true; this.physicSystem.SolverType = PhysicsSystem.Solver.Normal; this.physicSystem.CollisionSystem.UseSweepTests = true; //affect accuracy and the overhead == time required this.physicSystem.NumCollisionIterations = 8; //8 this.physicSystem.NumContactIterations = 8; //8 this.physicSystem.NumPenetrationRelaxtionTimesteps = 12; //15 #region SETTING_COLLISION_ACCURACY //affect accuracy of the collision detection this.physicSystem.AllowedPenetration = 0.000025f; this.physicSystem.CollisionTollerance = 0.00005f; #endregion this.physCont = new PhysicsController(); this.physicSystem.AddController(physCont); if (bEnableDebugDrawer) { this.physicsDebugDrawer = new PhysicsDebugDrawer(game); game.Components.Add(this.physicsDebugDrawer); } }