Example #1
0
        public virtual void SetType(b2BodyType type)
        {
            if (m_world.IsLocked() == true)
            {
                return;
            }

            if (m_type == type)
            {
                return;
            }

            m_type = type;

            ResetMassData();

            if (m_type == b2BodyType.b2_staticBody)
            {
                m_linearVelocity.SetZero();
                m_angularVelocity = 0.0f;
                m_sweep.a0        = m_sweep.a;
                m_sweep.c0        = m_sweep.c;
                SynchronizeFixtures();
            }

            SetAwake(true);

            m_force.SetZero();
            m_torque = 0.0f;

            // Since the body type changed, we need to flag contacts for filtering.
            for (b2Fixture f = m_fixtureList; f != null; f = f.Next)
            {
                f.Refilter();
            }
        }