[ODE] Trimesh-sphere collision detection debugging

Jean-Sebastien Guay jean-sebastien.guay at polymtl.ca
Tue Mar 14 08:45:28 MST 2006


Hello Jason,

Thanks for the reply.

> What do you mean by "getting a collision"? How are you testing? The
> near callback will be called if the objects are simply near each
> other. At that point you get to decide whether you want to do the
> exact test (by calling dCollide) or not. If you have a large terrain,
> the sphere may indeed fall within its bounding box and trigger the
> callback.

The callback is triggered, and a call to dCollide returns one contact point,
even though the mobile object and terrain are not touching at all.

Here's the relevant part of my code:

-------------------------------------------------------------------
void NearCallback(dGeomID o1, dGeomID o2)
{
    dBodyID b1 = dGeomGetBody(o1);
    dBodyID b2 = dGeomGetBody(o2);

    // If the bodies are already connected by another joint other than a
    // contact joint, don't check collisions.
    if (b1 && b2 && dAreConnectedExcluding(b1,b2,dJointTypeContact)) return;

    // Prepare contact data structure
    // TODO: This could be specified on a per-PhysicsObject basis and loaded
    //       with the object descriptions from the level data files
    dContact contact[MAX_CONTACTS];
    for (int i = 0; i < MAX_CONTACTS; i++)
    {
        contact[i].surface.mode       = dContactBounce | dContactSoftCFM;
        contact[i].surface.mu         = dInfinity;
        contact[i].surface.mu2        = 0;
        contact[i].surface.bounce     = 1e-5f;
        contact[i].surface.bounce_vel = 1e-9f;
        contact[i].surface.soft_cfm   = 1e-6f;
    }

    // Check for actual collisions between the two objects
    int numc = dCollide(o1, o2, MAX_CONTACTS, &contact[0].geom,
                        sizeof(dContact));

    if(numc > 0)
    {
        // Create the contact joints for the collision
        for (int i = 0; i < numc; i++)
        {
            dJointID c = dJointCreateContact(m_World, m_CollisionJoints,
                                             &contact[i]);
            dJointAttach(c, b1, b2);
        }

        // [...] call the gameplay object's collision handler
    }
}
-------------------------------------------------------------------

I'd really like to be able to debug this. There might be something wrong in the
data I'm passing to the trimesh creation function, or the physics objects may
not be synchronized with their gameplay state (position, orientation, etc). I'd
just like some tips on how to find the source of the error.

Thanks a lot,

J-S
--
______________________________________________________
Jean-Sebastien Guay     jean-sebastien.guay at polymtl.ca
                         http://whitestar02.webhop.org


More information about the ODE mailing list