示例#1
0
        protected virtual void InternalSingleStepSimulation(float timeStep)
        {
            BulletGlobals.StartProfile("internalSingleStepSimulation");
#if DEBUG
            if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugDiscreteDynamicsWorld)
            {
                BulletGlobals.g_streamWriter.WriteLine("internalSingleStepSimulation");
            }
#endif
            if (null != m_internalPreTickCallback)
            {
                m_internalPreTickCallback.InternalTickCallback(this, timeStep);
            }

            ///apply gravity, predict motion
            PredictUnconstraintMotion(timeStep);

            DispatcherInfo dispatchInfo = GetDispatchInfo();

            dispatchInfo.SetTimeStep(timeStep);
            dispatchInfo.SetStepCount(0);
            dispatchInfo.SetDebugDraw(GetDebugDrawer());

            ///perform collision detection
            PerformDiscreteCollisionDetection();

            CalculateSimulationIslands();

            GetSolverInfo().m_timeStep = timeStep;

            ///solve contact and other joint constraints
            SolveConstraints(GetSolverInfo());

            ///CallbackTriggers();

            ///integrate transforms
            IntegrateTransforms(timeStep);

            ///update vehicle simulation
            UpdateActions(timeStep);

            UpdateActivationState(timeStep);

            if (m_internalTickCallback != null)
            {
                m_internalTickCallback.InternalTickCallback(this, timeStep);
            }
            BulletGlobals.StopProfile();
        }
        ///maxSubSteps/fixedTimeStep for interpolation is currently ignored for btSimpleDynamicsWorld, use btDiscreteDynamicsWorld instead
        public override int StepSimulation(float timeStep, int maxSubSteps, float fixedTimeStep)
        {
            ///apply gravity, predict motion
            PredictUnconstraintMotion(timeStep);

            DispatcherInfo dispatchInfo = GetDispatchInfo();

            dispatchInfo.SetTimeStep(timeStep);
            dispatchInfo.SetStepCount(0);
            dispatchInfo.SetDebugDraw(GetDebugDrawer());

            ///perform collision detection
            PerformDiscreteCollisionDetection();

            ///solve contact constraints
            int numManifolds = m_dispatcher1.GetNumManifolds();

            if (numManifolds != 0)
            {
                PersistentManifoldArray manifoldPtr = (m_dispatcher1 as CollisionDispatcher).GetInternalManifoldPointer();

                ContactSolverInfo infoGlobal = new ContactSolverInfo();
                infoGlobal.m_timeStep = timeStep;
                m_constraintSolver.PrepareSolve(0, numManifolds);
                m_constraintSolver.SolveGroup(null, 0, manifoldPtr, 0, numManifolds, null, 0, 0, infoGlobal, m_debugDrawer, m_dispatcher1);
                m_constraintSolver.AllSolved(infoGlobal, m_debugDrawer);
            }

            ///integrate transforms
            IntegrateTransforms(timeStep);

            UpdateAabbs();

            SynchronizeMotionStates();

            ClearForces();

            return(1);
        }