[ODE] patch: auto-disable implemented
Aras Pranckevicius
nearaz at interamotion.com
Tue Oct 21 12:01:30 MST 2003
> Hey, it'd be best if you include a plain text file version of your
> patch. I always get hard time dealing with my email client to copy
> the right code... :(
Pasted into text file - seems to be ok.
> Ah, you said you'd put a convex geom into ODE, Right?
I _would_, if that would be _that easy_ :) I've just finished reading a huge
pile of papers, had a hard time visualizing Minkowski sums and similar
things, and even more hard time understanding all the scary math...
Now, I've nearly implemented GJK (with Cameron's and Van den Bergen
improvements), but that's GJK only - it doesn't give contacts nor
penetration depth per se. I'll keep working on it (Cameron has estimation of
penetration bounds, Bergen has some penetration depth computation, and then
there's stuff from DEEP and [don't know if speelling is correct] Agrawal).
If I'll have any results, this mailing list will certainly be notified. But
I can't promise what or when anything will be :(
Aras Pranckevicius aka NeARAZ
http://www.gim.ktu.lt/nesnausk/nearaz/
-------------- next part --------------
-----------------------------------------------------
objects.h (the one internal to ode sources):
approx. at line 40, add to body flags enum:
dxBodyAutoDisable = 16 // enable auto-disable on body
approx. at line 80, add to struct dxBody:
// auto-disabling
dReal autodis_threshold;
int autodis_steps;
int autodis_counter;
-----------------------------------------------------
ode.cpp
in processIslands, add to the start of initial
body visiting loop
["for (bb=world->firstbody; bb; bb=(dxBody*)bb->next)"]:
if( (bb->flags&dxBodyAutoDisable) && !(bb->flags&dxBodyDisabled) ) {
bool disable = true;
const dReal *lvel = bb->lvel;;
dReal lspeed = dDOT(lvel,lvel);
if( lspeed > bb->autodis_threshold ) {
disable = false;
} else {
const dReal *avel = bb->avel;
dReal aspeed = dDOT(avel,avel);
if( aspeed > bb->autodis_threshold ) {
disable = false;
}
}
if( disable )
++bb->autodis_counter;
else
bb->autodis_counter = 0;
if( bb->autodis_counter > bb->autodis_steps ) {
bb->flags |= dxBodyDisabled;
continue;
}
}
in the same processIslands, in "traverse and tag all body's
joints, add...", add to inside
of "if (n->body && !n->body->tag) {":
n->body->flags &= ~dxBodyDisabled;
n->body->autodis_counter = 0;
in dBodyCreate(), add initialization:
b->autodis_threshold = REAL(0.003);
b->autodis_steps = 10;
b->autodis_counter = 0;
add implementation of auto-disable functions:
void dBodySetAutoDisableThresholdSF1( dBodyID b, dReal threshold )
{
dAASSERT(b);
b->autodis_threshold = threshold;
}
dReal dBodyGetAutoDisableThresholdSF1( dBodyID b )
{
dAASSERT(b);
return b->autodis_threshold;
}
void dBodySetAutoDisableStepsSF1( dBodyID b, int steps )
{
dAASSERT(b);
b->autodis_steps = steps;
}
int dBodyGetAutoDisableStepsSF1( dBodyID b )
{
dAASSERT(b);
return b->autodis_steps;
}
void dBodySetAutoDisableSF1( dBodyID b, int doAutoDisable )
{
dAASSERT(b);
if( !doAutoDisable ) b->flags &= ~dxBodyAutoDisable;
else b->flags |= dxBodyAutoDisable;
}
int dBodyGetAutoDisableSF1( dBodyID b )
{
dAASSERT(b);
return ((b->flags & dxBodyAutoDisable) != 0);
}
-----------------------------------------------------
stepfast.cpp: similar to ode.cpp
in processIslandsFast, add to the start of initial body
visiting loop, just after
[#ifdef TIMING dTimerNow ("Island Processing); #endif]:
if( (bb->flags&dxBodyAutoDisable) && !(bb->flags&dxBodyDisabled) ) {
bool disable = true;
const dReal *lvel = bb->lvel;;
dReal lspeed = dDOT(lvel,lvel);
if( lspeed > bb->autodis_threshold ) {
disable = false;
} else {
const dReal *avel = bb->avel;
dReal aspeed = dDOT(avel,avel);
if( aspeed > bb->autodis_threshold ) {
disable = false;
}
}
if( disable )
++bb->autodis_counter;
else
bb->autodis_counter = 0;
if( bb->autodis_counter > bb->autodis_steps ) {
bb->flags |= dxBodyDisabled;
continue;
}
}
in the same processIslandsFast, in "traverse and tag all body's joints,
add untagged...", after "n->body->flags &= ~dxBodyDisabled;" add:
n->body->autodis_counter = 0;
That should be it.
More information about the ODE
mailing list