private void DrawShape(Fixture fixture, Transform xf, Color color) { Color coreColor = new Color(0.9f, 0.6f, 0.6f); switch (fixture.GetType()) { case ShapeType.CircleShape: { CircleShape circle = (CircleShape)fixture.GetShape(); Vec2 center = Math.Mul(xf, circle._p); float radius = circle._radius; Vec2 axis = xf.R.Col1; _debugDraw.DrawSolidCircle(center, radius, axis, color); } break; case ShapeType.PolygonShape: { PolygonShape poly = (PolygonShape)fixture.GetShape(); int vertexCount = poly.VertexCount; Box2DXDebug.Assert(vertexCount <= Settings.MaxPolygonVertices); Vec2[] vertices = new Vec2[Settings.MaxPolygonVertices]; for (int i = 0; i < vertexCount; ++i) { vertices[i] = Math.Mul(xf, poly.Vertices[i]); } _debugDraw.DrawSolidPolygon(vertices, vertexCount, color); } break; } }
public static Contact Create(Fixture fixtureA, Fixture fixtureB) { if (Initialized == false) { InitializeRegisters(); Initialized = true; } ShapeType type1 = fixtureA.GetType(); ShapeType type2 = fixtureB.GetType(); Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount); Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount); ContactCreateFcn createFcn = Registers[(int)type1][(int)type2].CreateFcn; if (createFcn != null) { if (Registers[(int)type1][(int)type2].Primary) { return(createFcn(fixtureA, fixtureB)); } else { return(createFcn(fixtureB, fixtureA)); } } else { return(null); } }
public CircleContact(Fixture fixtureA, Fixture fixtureB) : base(fixtureA, fixtureB) { Box2DXDebug.Assert(fixtureA.GetType() == ShapeType.CircleShape); Box2DXDebug.Assert(fixtureB.GetType() == ShapeType.CircleShape); }
public static Contact Create(Fixture fixtureA, Fixture fixtureB) { if (Initialized == false) { InitializeRegisters(); Initialized = true; } ShapeType type1 = fixtureA.GetType(); ShapeType type2 = fixtureB.GetType(); Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount); Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount); ContactCreateFcn createFcn = Registers[(int)type1][(int)type2].CreateFcn; if (createFcn != null) { if (Registers[(int)type1][(int)type2].Primary) { return createFcn(fixtureA, fixtureB); } else { return createFcn(fixtureB, fixtureA); } } else { return null; } }