cpSpaceStep
Posted: Sun Oct 18, 2009 5:03 pm
Hi
I am confused about cpSpaceStep() implementation.
For instance, take this code snippet:
// Run the impulse solver.
// run the old-style elastic solver if elastic iterations are disabled
cpFloat elasticCoef = (space->elasticIterations ? 0.0f : 1.0f);
for(int i=0; i<space->iterations; i++){
for(int j=0; j<arbiters->num; j++)
cpArbiterApplyImpulse((cpArbiter *)arbiters->arr[j], elasticCoef);
for(int j=0; j<constraints->num; j++){
cpConstraint *constraint = (cpConstraint *)constraints->arr[j];
constraint->klass->applyImpulse(constraint);
}
}
According to the comment, the old-style elastic solver is run *if* elastic iterations are disabled.
I have 8 elastic iterations, but it seems to execute the quoted code anyways.
I don't see the 'conditional part' here.
Also... I tried to follow the cached impulses.
I would expect some mechanism that says 'if cached do cheap stuff else do expensive stuff'.
However, I can't find this test. It seems that the expensive stuff is done every frame?
Bram
I am confused about cpSpaceStep() implementation.
For instance, take this code snippet:
// Run the impulse solver.
// run the old-style elastic solver if elastic iterations are disabled
cpFloat elasticCoef = (space->elasticIterations ? 0.0f : 1.0f);
for(int i=0; i<space->iterations; i++){
for(int j=0; j<arbiters->num; j++)
cpArbiterApplyImpulse((cpArbiter *)arbiters->arr[j], elasticCoef);
for(int j=0; j<constraints->num; j++){
cpConstraint *constraint = (cpConstraint *)constraints->arr[j];
constraint->klass->applyImpulse(constraint);
}
}
According to the comment, the old-style elastic solver is run *if* elastic iterations are disabled.
I have 8 elastic iterations, but it seems to execute the quoted code anyways.
I don't see the 'conditional part' here.
Also... I tried to follow the cached impulses.
I would expect some mechanism that says 'if cached do cheap stuff else do expensive stuff'.
However, I can't find this test. It seems that the expensive stuff is done every frame?
Bram