예제 #1
0
        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);
            }
        }