[ODE] Stepfast - auto-disable stuff
Frederic Ferland
fref at videotron.ca
Thu Jul 17 10:51:02 2003
Just checking before I delete this post... Was this code ever added to
CVS? I didn't really get a reply the last time I asked. Since these
functions are in the current ODE documentation, I think it would be a good
idea to actually have the code in the library too instead of getting
compile errors when trying to use them... :)
Anyone with write-access to CVS care to do this?
At 02:15 PM 7/14/2003 +0300, you wrote:
> > the documentation defines a number of other functions that are not
> > actually implemented in the source:
> > dBodySetAutoDisableThresholdSF1
> > dBodyGetAutoDisableThresholdSF1
> > ...
>
>These weren't implemented in the stepfast source. I've implemented these for
>my LTGameJam - that required some small modifications to ODE core.
>
>You can either try to grab the source from http://jammy.sourceforge.net/2003
>("dingus.zip", dingus/lib/ode, look for "Araz" comment :)), or I can explain
>it in basic steps here:
>
>Changes to ODE internal files (hm, my naming convention differs from ODE's
>:)):
>objects.h:
> add to struct dxBody:
> int mDisableSteps; // auto-disable counter
> add to struct dxWorld:
> dReal mAutoDisableThreshold;
> int mAutoDisableSteps;
>ode.cpp:
> add to dBodyCreate(dxWorld* w):
> b->mDisableSteps = 0;
> add to dWorldCreate():
> w->mAutoDisableSteps = 10;
> w->mAutoDisableThreshold = REAL(0.008);
> add functions like (add their prototypes to public objects.h):
> void dWorldSetAutoDisableSteps( dWorldID w, int steps )
> {
> dAASSERT(w);
> w->mAutoDisableSteps = steps;
> }
> void dWorldSetAutoDisableThreshold( dWorldID w, dReal threshold )
> {
> dAASSERT(w);
> w->mAutoDisableThreshold = threshold;
> }
>stepfast.cpp (actually one needs to add this to "normal" ODE's solver also):
> insert approx at line 1016, at start of loop for( bb=world->firstbody;
>... ):
> // ---- code begin ------------------------
> if( !(bb->flags&dxBodyDisabled) ) {
> bool disable = true;
> const dReal *lvel = bb->lvel;;
> dReal lspeed = dDOT(lvel,lvel);
> if( lspeed > world->mAutoDisableThreshold ) {
> disable = false;
> } else {
> const dReal *avel = bb->avel;
> dReal aspeed = dDOT(avel,avel);
> if( aspeed > world->mAutoDisableThreshold ) {
> disable = false;
> }
> }
> if( disable )
> ++bb->mDisableSteps;
> else
> bb->mDisableSteps = 0;
> if( bb->mDisableSteps > world->mAutoDisableSteps ) {
> bb->flags |= dxBodyDisabled;
> }
> }
>
> // ---- code end ------------------------
> add approx. at line 1080 (with above code included), in "traverse and
>tag all body's joints, add untagged..." code:
> n->body->flags &= ~dxBodyDisabled; // this line exists
> n->body->mDisableSteps = 0; // add this line
> n->body->tag = 1; // this exists
>
>Basically, that's all :)
>
>
>Aras Pranckevicius aka NeARAZ
>http://www.gim.ktu.lt/nesnausk/nearaz/
>
>_______________________________________________
>ODE mailing list
>ODE@q12.org
>http://q12.org/mailman/listinfo/ode