示例#1
0
        public virtual b2Fixture CreateFixture(b2FixtureDef def)
        {
            if (m_world.IsLocked == true)
            {
                return(null);
            }

            b2Fixture fixture = new b2Fixture();

            fixture.Create(this, def);

            if (m_flags.HasFlag(b2BodyFlags.e_activeFlag))
            {
                b2BroadPhase broadPhase = m_world.ContactManager.BroadPhase;
                fixture.CreateProxies(broadPhase, m_xf);
            }

            fixture.Next  = m_fixtureList;
            m_fixtureList = fixture;
            ++m_fixtureCount;

            fixture.Body = this;

            // Adjust mass properties if needed.
            if (fixture.Density > 0.0f)
            {
                ResetMassData();
            }

            // Let the world know we have a new fixture. This will cause new contacts
            // to be created at the beginning of the next time step.
            m_world.Flags |= b2WorldFlags.e_newFixture;

            return(fixture);
        }
示例#2
0
        public virtual void SetActive(bool flag)
        {
            if (flag == IsActive())
            {
                return;
            }

            if (flag)
            {
                m_flags |= b2BodyFlags.e_activeFlag;

                // Create all proxies.
                b2BroadPhase broadPhase = m_world.ContactManager.BroadPhase;
                for (b2Fixture f = m_fixtureList; f != null; f = f.Next)
                {
                    f.CreateProxies(broadPhase, m_xf);
                }

                // Contacts are created the next time step.
            }
            else
            {
                m_flags &= ~b2BodyFlags.e_activeFlag;

                // Destroy all proxies.
                b2BroadPhase broadPhase = m_world.ContactManager.BroadPhase;
                for (b2Fixture f = m_fixtureList; f != null; f = f.Next)
                {
                    f.DestroyProxies(broadPhase);
                }

                // Destroy the attached contacts.
                b2ContactEdge ce = m_contactList;
                while (ce != null)
                {
                    b2ContactEdge ce0 = ce;
                    ce = ce.Next;
                    m_world.ContactManager.Destroy(ce0.Contact);
                }
                m_contactList = null;
            }
        }
示例#3
0
        public virtual b2Fixture CreateFixture(b2FixtureDef def)
        {
            if (m_world.IsLocked == true)
            {
                return null;
            }

            b2Fixture fixture = new b2Fixture();
            fixture.Create(this, def);

            if (m_flags.HasFlag(b2BodyFlags.e_activeFlag))
            {
                b2BroadPhase broadPhase = m_world.ContactManager.BroadPhase;
                fixture.CreateProxies(broadPhase, m_xf);
            }

            fixture.Next = m_fixtureList;
            m_fixtureList = fixture;
            ++m_fixtureCount;

            fixture.Body = this;

            // Adjust mass properties if needed.
            if (fixture.Density > 0.0f)
            {
                ResetMassData();
            }

            // Let the world know we have a new fixture. This will cause new contacts
            // to be created at the beginning of the next time step.
            m_world.Flags |= b2WorldFlags.e_newFixture;

            return fixture;
        }