| 214 | // `_joint' is the body array, `nj' is the size of the array. |
| 215 | |
| 216 | void dInternalStepIsland_x1 (dxWorld *world, dxBody * const *body, int nb, |
| 217 | dxJoint * const *_joint, int nj, dReal stepsize) |
| 218 | { |
| 219 | int i,j,k; |
| 220 | int n6 = 6*nb; |
| 221 | |
| 222 | # ifdef TIMING |
| 223 | dTimerStart("preprocessing"); |
| 224 | # endif |
| 225 | |
| 226 | // number all bodies in the body list - set their tag values |
| 227 | for (i=0; i<nb; i++) body[i]->tag = i; |
| 228 | |
| 229 | // make a local copy of the joint array, because we might want to modify it. |
| 230 | // (the "dxJoint *const*" declaration says we're allowed to modify the joints |
| 231 | // but not the joint array, because the caller might need it unchanged). |
| 232 | dxJoint **joint = (dxJoint**) ALLOCA (nj * sizeof(dxJoint*)); |
| 233 | memcpy (joint,_joint,nj * sizeof(dxJoint*)); |
| 234 | |
| 235 | // for all bodies, compute the inertia tensor and its inverse in the global |
| 236 | // frame, and compute the rotational force and add it to the torque |
| 237 | // accumulator. |
| 238 | // @@@ check computation of rotational force. |
| 239 | dReal *I = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal)); |
| 240 | dReal *invI = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal)); |
| 241 | |
| 242 | //dSetZero (I,3*nb*4); |
| 243 | //dSetZero (invI,3*nb*4); |
| 244 | for (i=0; i<nb; i++) { |
| 245 | dReal tmp[12]; |
| 246 | // compute inertia tensor in global frame |
| 247 | dMULTIPLY2_333 (tmp,body[i]->mass.I,body[i]->R); |
| 248 | dMULTIPLY0_333 (I+i*12,body[i]->R,tmp); |
| 249 | // compute inverse inertia tensor in global frame |
| 250 | dMULTIPLY2_333 (tmp,body[i]->invI,body[i]->R); |
| 251 | dMULTIPLY0_333 (invI+i*12,body[i]->R,tmp); |
| 252 | // compute rotational force |
| 253 | dMULTIPLY0_331 (tmp,I+i*12,body[i]->avel); |
| 254 | dCROSS (body[i]->tacc,-=,body[i]->avel,tmp); |
| 255 | } |
| 256 | |
| 257 | // add the gravity force to all bodies |
| 258 | for (i=0; i<nb; i++) { |
| 259 | if ((body[i]->flags & dxBodyNoGravity)==0) { |
| 260 | body[i]->facc[0] += body[i]->mass.mass * world->gravity[0]; |
| 261 | body[i]->facc[1] += body[i]->mass.mass * world->gravity[1]; |
| 262 | body[i]->facc[2] += body[i]->mass.mass * world->gravity[2]; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | // get m = total constraint dimension, nub = number of unbounded variables. |
| 267 | // create constraint offset array and number-of-rows array for all joints. |
| 268 | // the constraints are re-ordered as follows: the purely unbounded |
| 269 | // constraints, the mixed unbounded + LCP constraints, and last the purely |
| 270 | // LCP constraints. |
| 271 | // |
| 272 | // joints with m=0 are inactive and are removed from the joints array |
| 273 | // entirely, so that the code that follows does not consider them. |
no test coverage detected