Extracting the shape from a body

Hi

I maybe missing something but in the code below I'm iterating through the world body list and then the shape list for each body. I can then identify a shape as a circle via ShapeType but I can't see a way of exxtracting the exact ShapeDef; ie in this case CircleDef. As a workaround I'm having to store the circle radius in the user data object and use getPosition() for the circle centre.

I find it a bit strange how I can identify a body's shape type but can't go any further.

Looking in the Shape constructor, which is passed a ShapeDef and can see that the exact ShapeDef is not stored but rather the ShapeDef's properties copied over. Thus, I can see how a specific CircleDef cannot be extracted by downcasting but maybe I'm missing the point!!

Graham

Code:
        for (Body b = m_world.getBodyList(); b != null; b = b.getNext())
        {
            for (Shape s = b.getShapeList(); s != null; s = s.getNext())
            {
                ShapeType sType = s.getType();
                if (sType.compareTo(ShapeType.CIRCLE_SHAPE) == 0) // circle
                {
                    Vec2 circleCentre = b.getPosition();
                    UserData userData = (UserData)s.getUserData();
                    float circleRadius = userData.getCircleRadius();
                }
            }
        }
Solved with:

final CircleShape circle = (CircleShape)s;

I forgot about CircleShape!!

Graham

Original thread: https://box2d.org/forum/viewtopic.php?t=5626