[ODE] TriMesh Collision

Bob Cober AzCoder at cox.net
Fri Jun 11 21:05:39 MST 2004


Thanks in advance for any help - this is driving me nuts:

I am getting a segfault whenever a box collides with a trimesh.  The 
actual error is in OpCode, although I am certain it is caused by my code.

Opcode::OBBCollider::InitQuery(Opcode::OBBCache&, IceMaths::OBB const&, 
IceMaths::Matrix4x4 const*, IceMaths::Matrix4x4 const*) (this=0x8123160, 
cache=@0x8123500, box=@0xbffff1d0, worldb=0x0, worldm=0xbffff180) at 
OPC_Common.h:96

I have noticed that during the collision callback, dGeomGetBody returns 
0 for o2.  Should a dGeometBody() be returning 0 for a Trimesh?

Thanks again for your time...


Here is the simplified code:
float vertices[]=
  {0.0f,1000.0f,0.0f,
   6000.0f,1000.0f,6000.0f,
   6000.0f,1000.0f,0.0f};

float indices[]={0,1,2};
dTriMeshDataID Data;

CPhysicsMgr::CPhysicsMgr()
{
  world = dWorldCreate();
  space = dSimpleSpaceCreate(0);
  contactGroup = dJointGroupCreate(0);
  dWorldSetGravity(world,0,-9.5,0);
  dWorldSetCFM (world,1e-5);
  Data = dGeomTriMeshDataCreate();
  
dGeomTriMeshDataBuildSingle(Data,&vertices[0],3*sizeof(float),3,&indices[0],3,3*sizeof(int));
  dCreateTriMesh(space, Data, 0, 0, 0);
}

void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
  int i;
  dBodyID b1 = dGeomGetBody(o1);
  dBodyID b2 = dGeomGetBody(o2);
  dContact contact[MAX_CONTACTS];   // up to MAX_CONTACTS contacts per 
box-box
  for (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 = 0;//0.01;
    contact[i].surface.bounce_vel = 100.0;
  }

  if (int numc = dCollide 
(o1,o2,MAX_CONTACTS,&contact[0].geom,sizeof(dContact)))
    {

      for (i=0; i<numc; i++)
        {
          dJointID c = dJointCreateContact 
(getPhysicsMgr()->world,getPhysicsMgr()->contactGroup,contact+i);
          dJointAttach (c,b1,b2);
        }
    }


}




More information about the ODE mailing list