| 306 | |
| 307 | |
| 308 | void dGeomSetBody (dxGeom *g, dxBody *b) |
| 309 | { |
| 310 | dAASSERT (g); |
| 311 | dUASSERT (g->gflags & GEOM_PLACEABLE,"geom must be placeable"); |
| 312 | CHECK_NOT_LOCKED (g->parent_space); |
| 313 | |
| 314 | if (b) { |
| 315 | if (!g->body) dFree (g->pos,sizeof(dxPosR)); |
| 316 | g->pos = b->pos; |
| 317 | g->R = b->R; |
| 318 | dGeomMoved (g); |
| 319 | if (g->body != b) { |
| 320 | g->bodyRemove(); |
| 321 | g->bodyAdd (b); |
| 322 | } |
| 323 | } |
| 324 | else { |
| 325 | if (g->body) { |
| 326 | dxPosR *pr = (dxPosR*) dAlloc (sizeof(dxPosR)); |
| 327 | g->pos = pr->pos; |
| 328 | g->R = pr->R; |
| 329 | memcpy (g->pos,g->body->pos,sizeof(dVector3)); |
| 330 | memcpy (g->R,g->body->R,sizeof(dMatrix3)); |
| 331 | g->bodyRemove(); |
| 332 | } |
| 333 | // dGeomMoved() should not be called if the body is being set to 0, as the |
| 334 | // new position of the geom is set to the old position of the body, so the |
| 335 | // effective position of the geom remains unchanged. |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | |
| 340 | dBodyID dGeomGetBody (dxGeom *g) |
no test coverage detected