void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color& color) { b2Color coreColor(0.9f, 0.6f, 0.6f); switch (fixture->GetType()) { case b2Shape::e_circle: { b2CircleShape* circle = (b2CircleShape*)fixture->GetShape(); b2Vec2 center = b2Mul(xf, circle->m_p); float32 radius = circle->m_radius; b2Vec2 axis = xf.R.col1; m_debugDraw->DrawSolidCircle(center, radius, axis, color); } break; case b2Shape::e_polygon: { b2PolygonShape* poly = (b2PolygonShape*)fixture->GetShape(); int32 vertexCount = poly->m_vertexCount; b2Assert(vertexCount <= b2_maxPolygonVertices); b2Vec2 vertices[b2_maxPolygonVertices]; for (int32 i = 0; i < vertexCount; ++i) { vertices[i] = b2Mul(xf, poly->m_vertices[i]); } m_debugDraw->DrawSolidPolygon(vertices, vertexCount, color); } break; } }
void b2World::DrawShape(b2Shape* shape, const b2XForm& xf, const b2Color& color, bool core) { b2Color coreColor(0.9f, 0.6f, 0.6f); switch (shape->GetType()) { case e_circleShape: { b2CircleShape* circle = (b2CircleShape*)shape; b2Vec2 center = b2Mul(xf, circle->GetLocalPosition()); float32 radius = circle->GetRadius(); b2Vec2 axis = xf.R.col1; m_debugDraw->DrawSolidCircle(center, radius, axis, color); if (core) { m_debugDraw->DrawCircle(center, radius - b2_toiSlop, coreColor); } } break; case e_polygonShape: { b2PolygonShape* poly = (b2PolygonShape*)shape; int32 vertexCount = poly->GetVertexCount(); const b2Vec2* localVertices = poly->GetVertices(); b2Assert(vertexCount <= b2_maxPolygonVertices); b2Vec2 vertices[b2_maxPolygonVertices]; for (int32 i = 0; i < vertexCount; ++i) { vertices[i] = b2Mul(xf, localVertices[i]); } m_debugDraw->DrawSolidPolygon(vertices, vertexCount, color); if (core) { const b2Vec2* localCoreVertices = poly->GetCoreVertices(); for (int32 i = 0; i < vertexCount; ++i) { vertices[i] = b2Mul(xf, localCoreVertices[i]); } m_debugDraw->DrawPolygon(vertices, vertexCount, coreColor); } } break; case e_unknownShape: case e_shapeTypeCount: break; } }