[ODE] nearCallback() question
David McClurg
dmcclurg at pandemicstudios.com.au
Mon Aug 12 23:37:01 2002
I've noticed two methods of passing bodies to dJointAttach() in the test programs for ODE...
#1)
static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
<snip>
n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
for (i=0; i<n; i++) {
<snip>
dJointAttach (c,
dGeomGetBody(contact[i].geom.g1),
dGeomGetBody(contact[i].geom.g2));
}
}
#2)
static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
<snip>
n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
for (i=0; i<n; i++) {
<snip>
dJointAttach (c, b1, b2);
}
}
Method #2 fails in some cases because b1 & b2 are reversed and the joint subsequently gets reversed. But in the case of a geom transform like in test_boxstack.cpp if you don't use method #2 then the body comes up NULL.
So my question is, how do I properly get the bodies to pass to dJointAttach() in all cases?
Ta