| 282 | } |
| 283 | |
| 284 | void dBodyDestroy (dxBody *b) |
| 285 | { |
| 286 | dAASSERT (b); |
| 287 | |
| 288 | // all geoms that link to this body must be notified that the body is about |
| 289 | // to disappear. note that the call to dGeomSetBody(geom,0) will result in |
| 290 | // dGeomGetBodyNext() returning 0 for the body, so we must get the next body |
| 291 | // before setting the body to 0. |
| 292 | dxGeom *next_geom = 0; |
| 293 | for (dxGeom *geom = b->geom; geom; geom = next_geom) { |
| 294 | next_geom = dGeomGetBodyNext (geom); |
| 295 | dGeomSetBody (geom,0); |
| 296 | } |
| 297 | |
| 298 | // detach all neighbouring joints, then delete this body. |
| 299 | dxJointNode *n = b->firstjoint; |
| 300 | while (n) { |
| 301 | // sneaky trick to speed up removal of joint references (black magic) |
| 302 | n->joint->node[(n == n->joint->node)].body = 0; |
| 303 | |
| 304 | dxJointNode *next = n->next; |
| 305 | n->next = 0; |
| 306 | removeJointReferencesFromAttachedBodies (n->joint); |
| 307 | n = next; |
| 308 | } |
| 309 | if (b->world) dWorldRemoveBody (b->world,b); |
| 310 | delete b; |
| 311 | } |
| 312 | |
| 313 | |
| 314 | void dBodySetData (dBodyID b, void *data) |
no test coverage detected