internal static b2Contact Create(b2Fixture fixtureA, int indexA, b2Fixture fixtureB, int indexB) { if (s_initialized == false) { InitializeRegisters(); s_initialized = true; } b2Shape.Type type1 = fixtureA.GetType(); b2Shape.Type type2 = fixtureB.GetType(); Debug.Assert(0 <= ((int)type1) && type1 < b2Shape.Type.e_typeCount); Debug.Assert(0 <= ((int)type2) && type2 < b2Shape.Type.e_typeCount); b2ContactCreateFcn createFcn = s_registers[(int)type1, (int)type2].createFcn; if (createFcn != null) { if (s_registers[(int)type1, (int)type2].primary) { return(createFcn(fixtureA, indexA, fixtureB, indexB)); } else { return(createFcn(fixtureB, indexB, fixtureA, indexA)); } } else { return(null); } }
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); } }
internal static void Destroy(ref b2Contact contact) { Debug.Assert(s_initialized == true); b2Fixture fixtureA = contact.m_fixtureA; b2Fixture fixtureB = contact.m_fixtureB; if (contact.m_manifold.pointCount > 0 && fixtureA.IsSensor() == false && fixtureB.IsSensor() == false) { fixtureA.GetBody().SetAwake(true); fixtureB.GetBody().SetAwake(true); } b2Shape.Type typeA = fixtureA.GetType(); b2Shape.Type typeB = fixtureB.GetType(); Debug.Assert(0 <= ((int)typeA) && typeB < b2Shape.Type.e_typeCount); Debug.Assert(0 <= ((int)typeA) && typeB < b2Shape.Type.e_typeCount); b2ContactDestroyFcn destroyFcn = s_registers[(int)typeA, (int)typeB].destroyFcn; destroyFcn(ref contact); }
public override void Reset(b2Fixture fixtureA = null, b2Fixture fixtureB = null) { base.Reset(fixtureA, fixtureB); b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape); b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_circleShape); }