[ODE] a bug in dBodyDestroy

Russ Smith russ at q12.org
Wed Mar 19 01:10:02 2003


> Hello ODE,
> 
> If the "body" has more than one "geometry" attached to it then
> dBodyDestroy intends to remove the body from all attached
> "geometries". For this purpose dBodyDestroy has code
> ...

> Eeek!!! nice catch. I think I've seen this too but couldn't quite
> figure it out.  I'm using multiple geoms per body as well.  Do you
> have a patch for Russ to commit?  Would this work...


hi konstantin,

thanks for finding the problem. i finally got around to fixing this,
here is my solution:

void dBodyDestroy (dxBody *b)
{
  ...
  // all geoms that link to this body must be notified that the body is
  // about to disappear. note that the call to dGeomSetBody(geom,0) will
  // result in dGeomGetBodyNext() returning 0 for the body, so we must
  // get the next body before setting the body to 0.
  dxGeom *next_geom = 0;
  for (dxGeom *geom = b->geom; geom; geom = next_geom) {
    next_geom = dGeomGetBodyNext (geom);
    dGeomSetBody (geom,0);
  }
  ...
}

does this work for you konstantin/david ?

russ.

-- 
Russell Smith
http://www.q12.org