internal static Contact Create(Fixture fixtureA, int indexA, Fixture fixtureB, int indexB) { ShapeType type1 = fixtureA.Shape.ShapeType; ShapeType type2 = fixtureB.Shape.ShapeType; //Debug.Assert(ShapeType.Unknown < type1 && type1 < ShapeType.TypeCount); //Debug.Assert(ShapeType.Unknown < type2 && type2 < ShapeType.TypeCount); Contact c = null; Queue <Contact> pool = fixtureA.Body._world._contactPool; if (pool.Count > 0) { lock (fixtureA.Body._world._contactPool) c = pool.Dequeue() ?? c; if (c != null) { if ((type1 >= type2 || (type1 == ShapeType.Edge && type2 == ShapeType.Polygon)) && !(type2 == ShapeType.Edge && type1 == ShapeType.Polygon)) { c.Reset(fixtureA, indexA, fixtureB, indexB); } else { c.Reset(fixtureB, indexB, fixtureA, indexA); } } } else { // Edge+Polygon is non-symetrical due to the way Erin handles collision type registration. if ((type1 >= type2 || (type1 == ShapeType.Edge && type2 == ShapeType.Polygon)) && !(type2 == ShapeType.Edge && type1 == ShapeType.Polygon)) { c = new Contact(fixtureA, indexA, fixtureB, indexB); } else { c = new Contact(fixtureB, indexB, fixtureA, indexA); } } c._type = _registers[(int)type1, (int)type2]; return(c); }