MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / dTestDataStructures

Function dTestDataStructures

3rd_party/Src/ode/ode/src/ode.cpp:1477–1576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1475
1476
1477extern "C" void dTestDataStructures()
1478{
1479 int i;
1480 DO(printf ("testDynamicsStuff()\n"));
1481
1482 dBodyID body [NUM];
1483 int nb = 0;
1484 dJointID joint [NUM];
1485 int nj = 0;
1486
1487 for (i=0; i<NUM; i++) body[i] = 0;
1488 for (i=0; i<NUM; i++) joint[i] = 0;
1489
1490 DO(printf ("creating world\n"));
1491 dWorldID w = dWorldCreate();
1492 checkWorld (w);
1493
1494 for (;;) {
1495 if (nb < NUM && dRandReal() > 0.5) {
1496 DO(printf ("creating body\n"));
1497 body[nb] = dBodyCreate (w);
1498 DO(printf ("\t--> %p\n",body[nb]));
1499 nb++;
1500 checkWorld (w);
1501 DO(printf ("%d BODIES, %d JOINTS\n",nb,nj));
1502 }
1503 if (nj < NUM && nb > 2 && dRandReal() > 0.5) {
1504 dBodyID b1 = body [dRand() % nb];
1505 dBodyID b2 = body [dRand() % nb];
1506 if (b1 != b2) {
1507 DO(printf ("creating joint, attaching to %p,%p\n",b1,b2));
1508 joint[nj] = dJointCreateBall (w,0);
1509 DO(printf ("\t-->%p\n",joint[nj]));
1510 checkWorld (w);
1511 dJointAttach (joint[nj],b1,b2);
1512 nj++;
1513 checkWorld (w);
1514 DO(printf ("%d BODIES, %d JOINTS\n",nb,nj));
1515 }
1516 }
1517 if (nj > 0 && nb > 2 && dRandReal() > 0.5) {
1518 dBodyID b1 = body [dRand() % nb];
1519 dBodyID b2 = body [dRand() % nb];
1520 if (b1 != b2) {
1521 int k = dRand() % nj;
1522 DO(printf ("reattaching joint %p\n",joint[k]));
1523 dJointAttach (joint[k],b1,b2);
1524 checkWorld (w);
1525 DO(printf ("%d BODIES, %d JOINTS\n",nb,nj));
1526 }
1527 }
1528 if (nb > 0 && dRandReal() > 0.5) {
1529 int k = dRand() % nb;
1530 DO(printf ("destroying body %p\n",body[k]));
1531 dBodyDestroy (body[k]);
1532 checkWorld (w);
1533 for (; k < (NUM-1); k++) body[k] = body[k+1];
1534 nb--;

Callers

nothing calls this directly

Calls 9

dWorldCreateFunction · 0.85
checkWorldFunction · 0.85
dRandRealFunction · 0.85
dBodyCreateFunction · 0.85
dRandFunction · 0.85
dJointCreateBallFunction · 0.85
dJointAttachFunction · 0.85
dBodyDestroyFunction · 0.85
dJointDestroyFunction · 0.85

Tested by

no test coverage detected