private void drawShape(Fixture fixture, Transform xf, Color4f color, bool wireframe) { switch (fixture.getType()) { case ShapeType.CIRCLE: { CircleShape circle = (CircleShape) fixture.getShape(); // Vec2 center = Mul(xf, circle.m_p); Transform.mulToOutUnsafe(xf, circle.m_p, ref center); float radius = circle.m_radius; xf.q.getXAxis(axis); if (fixture.getUserData() != null && fixture.getUserData().Equals(LIQUID_INT)) { Body b = fixture.getBody(); liquidOffset.set(b.m_linearVelocity); float linVelLength = b.m_linearVelocity.length(); if (averageLinearVel == -1) { averageLinearVel = linVelLength; } else { averageLinearVel = .98f*averageLinearVel + .02f*linVelLength; } liquidOffset.mulLocal(liquidLength/averageLinearVel/2); circCenterMoved.set(center); circCenterMoved.addLocal(liquidOffset); center.subLocal(liquidOffset); m_debugDraw.drawSegment(center, circCenterMoved, liquidColor); return; } if (wireframe) { m_debugDraw.drawCircle(center, radius, axis, color); } else { m_debugDraw.drawSolidCircle(center, radius, axis, color); } } break; case ShapeType.POLYGON: { PolygonShape poly = (PolygonShape) fixture.getShape(); int vertexCount = poly.m_count; Debug.Assert(vertexCount <= Settings.maxPolygonVertices); Vec2[] vertices = tlvertices.get(Settings.maxPolygonVertices); for (int i = 0; i < vertexCount; ++i) { // vertices[i] = Mul(xf, poly.m_vertices[i]); Transform.mulToOutUnsafe(xf, poly.m_vertices[i], ref vertices[i]); } if (wireframe) { m_debugDraw.drawPolygon(vertices, vertexCount, color); } else { m_debugDraw.drawSolidPolygon(vertices, vertexCount, color); } } break; case ShapeType.EDGE: { EdgeShape edge = (EdgeShape) fixture.getShape(); Transform.mulToOutUnsafe(xf, edge.m_vertex1, ref v1); Transform.mulToOutUnsafe(xf, edge.m_vertex2, ref v2); m_debugDraw.drawSegment(v1, v2, color); } break; case ShapeType.CHAIN: { ChainShape chain = (ChainShape) fixture.getShape(); int count = chain.m_count; Vec2[] vertices = chain.m_vertices; Transform.mulToOutUnsafe(xf, vertices[0], ref v1); for (int i = 1; i < count; ++i) { Transform.mulToOutUnsafe(xf, vertices[i], ref v2); m_debugDraw.drawSegment(v1, v2, color); m_debugDraw.drawCircle(v1, 0.05f, color); v1.set(v2); } } break; default: break; } }
private void DrawFixture(Fixture fixture) { Color4f color = new Color4f(0.95f, 0.95f, 0.6f); Transform xf = fixture.getBody().getTransform(); switch (fixture.getType()) { case ShapeType.CIRCLE: { CircleShape circle = (CircleShape) fixture.getShape(); Vec2 center = Transform.mul(xf, circle.m_p); float radius = circle.m_radius; debugDraw.drawCircle(center, radius, color); } break; case ShapeType.POLYGON: { PolygonShape poly = (PolygonShape) fixture.getShape(); int vertexCount = poly.m_count; Debug.Assert(vertexCount <= Settings.maxPolygonVertices); Vec2[] vertices = new Vec2[Settings.maxPolygonVertices]; for (int i = 0; i < vertexCount; ++i) { vertices[i] = Transform.mul(xf, poly.m_vertices[i]); } debugDraw.drawPolygon(vertices, vertexCount, color); } break; default: break; } }
public Contact popContact(Fixture fixtureA, int indexA, Fixture fixtureB, int indexB) { ShapeType type1 = fixtureA.getType(); ShapeType type2 = fixtureB.getType(); ContactRegister reg = contactStacks[(int) type1][(int) type2]; if (reg != null) { if (reg.primary) { Contact c = reg.creator.pop(); c.init(fixtureA, indexA, fixtureB, indexB); return c; } else { Contact c = reg.creator.pop(); c.init(fixtureB, indexB, fixtureA, indexA); return c; } } else { return null; } }