百度企业网站建设费用中国建设银行人力资源网站
物理引擎系统-ode
目录
物理引擎系统-ode
一、物理引擎系统-ode——processIslands
二、物理引擎系统-ode——processIslands
三、物理引擎系统-ode——processIslands
四、物理引擎系统-ode——processIslands
五、物理引擎系统-ode——processIslands
一、物理引擎系统-ode——processIslands
static void processIslands (dxWorld *world, dReal stepsize)
 {
   dxBody *b,*bb,**body;
   dxJoint *j,**joint;
  // nothing to do if no bodies
   if (world->nb <= 0) return;
二、物理引擎系统-ode——processIslands
  // make arrays for body and joint lists (for a single island) to go into
   body = (dxBody**) ALLOCA (world->nb * sizeof(dxBody*));
   joint = (dxJoint**) ALLOCA (world->nj * sizeof(dxJoint*));
   int bcount = 0;    // number of bodies in `body'
   int jcount = 0;    // number of joints in `joint'
三、物理引擎系统-ode——processIslands
  // set all body/joint tags to 0
   for (b=world->firstbody; b; b=(dxBody*)b->next) b->tag = 0;
   for (j=world->firstjoint; j; j=(dxJoint*)j->next) j->tag = 0;
  // allocate a stack of unvisited bodies in the island. the maximum size of
   // the stack can be the lesser of the number of bodies or joints, because
   // new bodies are only ever added to the stack by going through untagged
   // joints. all the bodies in the stack must be tagged!
   int stackalloc = (world->nj < world->nb) ? world->nj : world->nb;
   dxBody **stack = (dxBody**) ALLOCA (stackalloc * sizeof(dxBody*));
四、物理引擎系统-ode——processIslands
  for (bb=world->firstbody; bb; bb=(dxBody*)bb->next) {
     // get bb = the next enabled, untagged body, and tag it
     if (bb->tag || (bb->flags & dxBodyDisabled)) continue;
     bb->tag = 1;
// tag all bodies and joints starting from bb.
     int stacksize = 0;
     b = bb;
     body[0] = bb;
     bcount = 1;
     jcount = 0;
     goto quickstart;
     while (stacksize > 0) {
       b = stack[--stacksize];    // pop body off stack
       body[bcount++] = b;    // put body on body list
       quickstart:
五、物理引擎系统-ode——processIslands
      // traverse and tag all body's joints, add untagged connected bodies
       // to stack
       for (dxJointNode *n=b->firstjoint; n; n=n->next) {
     if (!n->joint->tag) {
       n->joint->tag = 1;
       joint[jcount++] = n->joint;
       if (n->body && !n->body->tag) {
         n->body->tag = 1;
         stack[stacksize++] = n->body;
       }
     }
       }
       dIASSERT(stacksize <= world->nb);
       dIASSERT(stacksize <= world->nj);
     }
