Exemplo n.º 1
0
        public void Destroy(b2Contact contact)
        {
            if (contact.m_manifold.m_pointCount > 0)
            {
                contact.m_fixtureA.m_body.SetAwake(true);
                contact.m_fixtureB.m_body.SetAwake(true);
            }

            int type1 = contact.m_fixtureA.GetType();
            int type2 = contact.m_fixtureB.GetType();

            //b2Settings.b2Assert(b2Shape.e_unknownShape < type1 && type1 < b2Shape.e_shapeTypeCount);
            //b2Settings.b2Assert(b2Shape.e_unknownShape < type2 && type2 < b2Shape.e_shapeTypeCount);

            b2ContactRegister reg = m_registers[type1][type2];

            if (true)
            {
                reg.poolCount++;
                contact.m_next = reg.pool;
                reg.pool       = contact;
            }

            Action <b2Contact, object> destroyFcn = reg.destroyFcn;

            destroyFcn(contact, m_allocator);
        }
Exemplo n.º 2
0
        public b2Contact Create(b2Fixture fixtureA, b2Fixture fixtureB)
        {
            int type1 = fixtureA.GetType();
            int type2 = fixtureB.GetType();

            //b2Settings.b2Assert(b2Shape.e_unknownShape < type1 && type1 < b2Shape.e_shapeTypeCount);
            //b2Settings.b2Assert(b2Shape.e_unknownShape < type2 && type2 < b2Shape.e_shapeTypeCount);

            b2ContactRegister reg = m_registers[type1][type2];

            b2Contact c;

            if (reg.pool != null)
            {
                // Pop a contact off the pool
                c        = reg.pool;
                reg.pool = c.m_next;
                reg.poolCount--;
                c.Reset(fixtureA, fixtureB);
                return(c);
            }

            Func <object, b2Contact> createFcn = reg.createFcn;

            if (createFcn != null)
            {
                if (reg.primary)
                {
                    c = createFcn(m_allocator);
                    c.Reset(fixtureA, fixtureB);
                    return(c);
                }
                else
                {
                    c = createFcn(m_allocator);
                    c.Reset(fixtureB, fixtureA);
                    return(c);
                }
            }
            else
            {
                return(null);
            }
        }