Get size of a Body

Simple question:
I've got a Body which I identified as a Box. How do I get the extents vector? Is there a simple way or should I store the size value in the userData? The same for a Body I identified as a Circle. How do I get the radius?
If the body only has one shape, you can access the shape using
myBody->m_shapeList

Once you have the shape, you can check what type it is (circle, box, poly) with the member variable m_type.
If it's a circle, cast the pointer to a b2CircleShape and simply access the m_radius variable.
If it's a box, cast it to a b2PolyShape, and use m_vertices[0] (being the vert at the top right), this should be the same as the extents you created the box with.

So something like this should work:
Code:
if (body->m_shapeList->m_type == e_circleShape){
   float radius = ((b2CircleShape*)body->m_shapeList)->m_radius;
}
else if (body->m_shapeList->m_type == e_polyShape){
   b2Vec2 boxExtents = ((b2PolyShape*)body->m_shapeList)->m_vertices[0];
}

Hope that's right, my brain is still in ActionScript mode.
Thank you, it works. 🙂

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