[ODE] Possible Bug in ODE
Benny
Benny <benny at kramekweb.com>
Sun Dec 8 10:09:02 2002
I wrote a very small program that demonstrates what I think is a bug in ODE.
I think it is a problem with dCollide(), but it only happens with Transform
Geoms.
When compiled with an old cvs(ode v0.3 probably also is good), this program
runs with no problems, returning zero contact points between the two
non-touching geoms.
But when compiled with the latest cvs(from about 4 hours ago), it thinks
wrongly that there are contact points.
// -----------------------------------
#include <stdio.h>
#include <ode/ode.h>
int main()
{
dWorldID world;
dBodyID body1, body2;
dGeomID E1, T1, E2, T2, box;
dMatrix3 RIdentity;
dRSetIdentity(RIdentity);
world = dWorldCreate();
dWorldSetGravity(world, 0, 0, 0);
// Normal Body with a Box ---------------
body1 = dBodyCreate(world);
dBodySetPosition(body1, 0, 0, 0);
dBodySetRotation(body1, RIdentity);
box = dCreateBox(0, 10, 10, 10);
dGeomSetBody(box, body1);
// --------------------------------------
// Add an offsetted Box to body1 --------
// far away from everything -------------
// (shouldn't collide) ------------------
E1 = dCreateBox(0, 5, 5, 5);
dGeomSetPosition(E1, 200, 0, 0);
dGeomSetRotation(E1, RIdentity);
T1 = dCreateGeomTransform(0);
dGeomTransformSetGeom(T1, E1);
dGeomSetBody(T1, body1);
// --------------------------------------
// Create body2 with a box --------------
// at center of mass but through a ------
// Geom Transform -----------------------
body2 = dBodyCreate(world);
dBodySetPosition(body2, 0, 0, 0);
dBodySetRotation(body2, RIdentity);
E2 = dCreateBox(0, 5, 5, 5);
dGeomSetPosition(E2, 0, 0, 0);
dGeomSetRotation(E2, RIdentity);
T2 = dCreateGeomTransform(0);
dGeomTransformSetGeom(T2, E2);
dGeomSetBody(T2, body2);
// --------------------------------------
dBodySetPosition(body2, 7, 0, 0);
// I don't know if this is needed. I'll call it anyway.
dWorldStep(world, 1);
dContact dummycontacts[10];
// The dCollide() function should not return any contacts, but it does
int numContacts = dCollide(T1, T2, 1, &dummycontacts[0].geom,
sizeof(dContact));
printf("%d\n", numContacts);
return 0;
}