Example #1
0
        public b2Joint(b2JointDef def)
        {
            Debug.Assert(def.BodyA != def.BodyB);

            m_type             = def.JointType;
            Prev               = null;
            Next               = null;
            m_bodyA            = def.BodyA;
            m_bodyB            = def.BodyB;
            m_index            = 0;
            m_collideConnected = def.CollideConnected;
            m_islandFlag       = false;
            m_userData         = def.UserData;
            m_edgeA            = new b2JointEdge();
            m_edgeB            = new b2JointEdge();
        }
Example #2
0
        protected b2Transform m_xf = b2Transform.Default; // the body origin transform

        #endregion Fields

        #region Constructors

        public b2Body(b2BodyDef bd, b2World world)
        {
            m_flags = 0;

            if (bd.bullet)
            {
                m_flags |= b2BodyFlags.e_bulletFlag;
            }
            if (bd.fixedRotation)
            {
                m_flags |= b2BodyFlags.e_fixedRotationFlag;
            }
            if (bd.allowSleep)
            {
                m_flags |= b2BodyFlags.e_autoSleepFlag;
            }
            if (bd.awake)
            {
                m_flags |= b2BodyFlags.e_awakeFlag;
            }
            if (bd.active)
            {
                m_flags |= b2BodyFlags.e_activeFlag;
            }

            m_world = world;

            m_xf.p = bd.position;
            m_xf.q.Set(bd.angle);

            Sweep.localCenter.SetZero();
            Sweep.c0 = m_xf.p;
            Sweep.c = m_xf.p;
            Sweep.a0 = bd.angle;
            Sweep.a = bd.angle;
            Sweep.alpha0 = 0.0f;

            m_jointList = null;
            m_contactList = null;
            Prev = null;
            Next = null;

            m_linearVelocity = bd.linearVelocity;
            m_angularVelocity = bd.angularVelocity;

            m_linearDamping = bd.linearDamping;
            m_angularDamping = bd.angularDamping;
            m_gravityScale = bd.gravityScale;

            m_force.SetZero();
            m_torque = 0.0f;

            m_sleepTime = 0.0f;

            m_type = bd.type;

            if (m_type == b2BodyType.b2_dynamicBody)
            {
                m_mass = 1.0f;
                m_invMass = 1.0f;
            }
            else
            {
                m_mass = 0.0f;
                m_invMass = 0.0f;
            }

            m_I = 0.0f;
            m_invI = 0.0f;

            m_userData = bd.userData;

            m_fixtureList = null;
            m_fixtureCount = 0;
        }
Example #3
0
        public b2Joint(b2JointDef def)
        {
            Debug.Assert(def.BodyA != def.BodyB);

            m_type = def.JointType;
            Prev = null;
            Next = null;
            m_bodyA = def.BodyA;
            m_bodyB = def.BodyB;
            m_index = 0;
            m_collideConnected = def.CollideConnected;
            m_islandFlag = false;
            m_userData = def.UserData;
            m_edgeA = new b2JointEdge();
            m_edgeB = new b2JointEdge();
        }