So, in my little editor, I stuffed all my b2BodyDefs into a vector as well as added them to the world so that I could save them later.
Now I'm trying to save them... I can get all the b2PolyDef properties correctly, but when I try to access the circle's properties..they're all nonsensical:
Am I not allowed to cast a b2ShapeDef like that, or what? It works for b2PolyDef so I can't figure why it won't work for b2CircleDef.
Code:
m_bodies.push_back(bd);
m_world->CreateBody(&bd);
m_world->CreateBody(&bd);
Now I'm trying to save them... I can get all the b2PolyDef properties correctly, but when I try to access the circle's properties..they're all nonsensical:
Code:
for(int i=0; i<m_bodies.size(); ++i)
{
for (int j=0; j<b2_maxShapesPerBody; ++j)
{
if(m_bodies[i].shapes[j] != NULL)
{
switch(m_bodies[i].shapes[j]->type)
{
case e_circleShape:
{
const b2CircleDef* cd = (const b2CircleDef*)m_bodies[i].shapes[j];
radius = new TiXmlElement("Radius");
shape->LinkEndChild(radius);
radius->SetDoubleAttribute("Value",cd->radius);
}
break;
{
for (int j=0; j<b2_maxShapesPerBody; ++j)
{
if(m_bodies[i].shapes[j] != NULL)
{
switch(m_bodies[i].shapes[j]->type)
{
case e_circleShape:
{
const b2CircleDef* cd = (const b2CircleDef*)m_bodies[i].shapes[j];
radius = new TiXmlElement("Radius");
shape->LinkEndChild(radius);
radius->SetDoubleAttribute("Value",cd->radius);
}
break;
Am I not allowed to cast a b2ShapeDef like that, or what? It works for b2PolyDef so I can't figure why it won't work for b2CircleDef.