[ODE] Destroying Body before Geom

Chris Osborn cwosborn at nps.edu
Wed Oct 19 18:45:17 MST 2005


Hi guys,

How does one correctly destroy a body before the geom associated with 
it? I have a base class with a dGeomID and a derived class with a 
dBodyID . Since the derived classes destructor is called first, 
dBodyDestroy is called before dGeomDestroy.

~Derived()
{
    dBodyDestroy(mBodyID);
}

~Base()
{
    dGeomDestroy(mGeomID);
}

This results in a access violation in collision_kernel.cpp:

dxGeom *dGeomGetBodyNext (dxGeom *geom)
{
   return geom->body_next;  //right here, where geom is a bad pointer
}

I've tried calling dGeomSetBody(mGeomID, 0) prior to dBodyDestory, 
hoping to decouple the two. But then it dies in dxGeom::bodyRemove().

Any ideas?

Thanks
-chris



More information about the ODE mailing list