Beispiel #1
0
        public b2World(b2Vec2 gravity)
        {
            m_destructionListener = null;
            m_debugDraw           = null;

            m_bodyList  = null;
            m_jointList = null;

            m_bodyCount  = 0;
            m_jointCount = 0;

            m_warmStarting      = true;
            m_continuousPhysics = true;
            m_subStepping       = false;

            m_stepComplete = true;

            m_allowSleep = true;
            m_gravity    = gravity;

            m_flags = b2WorldFlags.e_clearForces;

            m_inv_dt0 = 0.0f;
        }
Beispiel #2
0
        public void Step(float dt, int velocityIterations, int positionIterations)
        {
            b2Timer stepTimer;

            // If new fixtures were added, we need to find the new contacts.
            if (m_flags.HasFlag(b2WorldFlags.e_newFixture))
            {
                m_contactManager.FindNewContacts();
                m_flags &= ~b2WorldFlags.e_newFixture;
            }

            m_flags |= b2WorldFlags.e_locked;

            b2TimeStep step;

            step.dt = dt;
            step.velocityIterations = velocityIterations;
            step.positionIterations = positionIterations;
            if (dt > 0.0f)
            {
                step.inv_dt = 1.0f / dt;
            }
            else
            {
                step.inv_dt = 0.0f;
            }

            step.dtRatio = m_inv_dt0 * dt;

            step.warmStarting = m_warmStarting;

            // Update contacts. This is where some contacts are destroyed.
            {
                b2Timer timer;
                m_contactManager.Collide();
                m_profile.collide = timer.GetMilliseconds();
            }

            // Integrate velocities, solve velocityraints, and integrate positions.
            if (m_stepComplete && step.dt > 0.0f)
            {
                b2Timer timer;
                Solve(step);
                m_profile.solve = timer.GetMilliseconds();
            }

            // Handle TOI events.
            if (m_continuousPhysics && step.dt > 0.0f)
            {
                b2Timer timer;
                SolveTOI(step);
                m_profile.solveTOI = timer.GetMilliseconds();
            }

            if (step.dt > 0.0f)
            {
                m_inv_dt0 = step.inv_dt;
            }

            if (m_flags.HasFlag(b2WorldFlags.e_clearForces))
            {
                ClearForces();
            }

            m_flags &= ~b2WorldFlags.e_locked;

            m_profile.step = stepTimer.GetMilliseconds();
        }
Beispiel #3
0
        public b2World(b2Vec2 gravity)
        {
            m_destructionListener = null;
            m_debugDraw = null;

            m_bodyList = null;
            m_jointList = null;

            m_bodyCount = 0;
            m_jointCount = 0;

            m_warmStarting = true;
            m_continuousPhysics = true;
            m_subStepping = false;

            m_stepComplete = true;

            m_allowSleep = true;
            m_gravity = gravity;

            m_flags = b2WorldFlags.e_clearForces;

            m_inv_dt0 = 0.0f;

            // setup up our default Contact Manager
            m_contactManager = new b2ContactManager();
        }
Beispiel #4
0
 public static bool HasFlag(this b2WorldFlags flag, b2WorldFlags testFlag)
 {
     return ((flag & testFlag) == testFlag);
 }
Beispiel #5
0
 public static bool HasFlag(this b2WorldFlags flag, b2WorldFlags testFlag)
 {
     return((flag & testFlag) == testFlag);
 }