internal DynamicWorldImp()
        {
            //Debug.WriteLine("DynamicWorldImp");

            //Default
            // collision configuration contains default setup for memory, collision setup
            BtCollisionConf = new DefaultCollisionConfiguration();
            BtDispatcher    = new CollisionDispatcher(BtCollisionConf);
            BtBroadphase    = new DbvtBroadphase();
            BtSolver        = new SequentialImpulseConstraintSolver();
            // BtCollisionShapes = new AlignedCollisionShapeArray();



            BtWorld = new DiscreteDynamicsWorld(BtDispatcher, BtBroadphase, BtSolver, BtCollisionConf)
            {
                Gravity = new Vector3(0, -9.81f, 0)
            };

            BtWorld.SolverInfo.NumIterations = 5;

            BtWorld.PerformDiscreteCollisionDetection();

            //GImpactCollisionAlgorithm.RegisterAlgorithm(BtDispatcher);
            // BtWorld.SetInternalTickCallback(MyTickCallBack);
            //BtWorld.SetInternalTickCallback(TickTack);

            //ManifoldPoint.ContactAdded += OnContactAdded;
            //PersistentManifold.ContactDestroyed += OnContactDestroyed;
            //PersistentManifold.ContactProcessed += OnContactProcessed;
        }
Beispiel #2
0
        internal static void Update(float deltaTime)
        {
            world.StepSimulation(deltaTime, 100);

            world.PerformDiscreteCollisionDetection();

            for (var i = 0; i < world.Dispatcher.NumManifolds; i++)
            {
                var mani = world.Dispatcher.GetManifoldByIndexInternal(i);
                mani.RefreshContactPoints(mani.Body0.WorldTransform, mani.Body1.WorldTransform);

                var colA = (mani.Body0.UserObject as CollisionObject).tag as PhysicalGameComponent;
                var colB = (mani.Body1.UserObject as CollisionObject).tag as PhysicalGameComponent;

                if (colA == colB)
                {
                    continue;
                }

                var mps = new ManifoldPoint[mani.NumContacts];
                for (int j = 0; j < mani.NumContacts; j++)
                {
                    mps[j] = mani.GetContactPoint(j);
                }

                colA.OnCollision(colB.GameObject, mps);
                colB.OnCollision(colA.GameObject, mps);
            }
        }