I want to take a b2Body and clear its shapes. I realize that this can be done by destroying the body itself and making a new one, but I want to keep the same b2Body instance.
I was just going to do this:
but I think that won't work because it'll try to call GetNext after it's been destroyed.
So maybe this would work?
I was just going to do this:
Code:
for (b2Shape *sh = body->GetShapeList(); sh; sh = sh->GetNext())
{
body->DestroyShape(sh);
}
{
body->DestroyShape(sh);
}
but I think that won't work because it'll try to call GetNext after it's been destroyed.
So maybe this would work?
Code:
for (b2Shape *sh = body->GetShapeList(); sh;)
{
b2Shape *next = sh->GetNext();
body->DestroyShape(sh);
sh = next;
}
{
b2Shape *next = sh->GetNext();
body->DestroyShape(sh);
sh = next;
}