[ODE] Stepfast - auto-disable stuff
Frederic Ferland
fref at videotron.ca
Mon Jul 14 11:08:02 2003
Any chance this could be added to CVS so that it is not lost and that we
don't have to make these changes every time there's a new release of ODE?
(especially since we already have the docs for this...)
Thanks!
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
______________________________________________________________
Frederic Ferland <fref@bigfoot.com>
Computer Game Programmer
Strategy First (www.strategyfirst.com)