[ODE] dCollide crashes me app!
Fabian Mathews
supagu at hotmail.com
Fri Feb 27 00:37:40 MST 2004
i have a trimesh and a cube, and it crashes in the dCollide line in my code
when they intersect.
I have tried a plane and a cube, and it works fine, so im not sure if its my
callback function, or if its my trimesh settup code?
any ideas are appreciated!
thanks from fab,
any way, here is both:
callback:
-------------------------------------------
#define MAX_CONTACTS 40
void PhysicsMgr::NearCollisionCallback(void *data, dGeomID o1, dGeomID o2)
{
int i;
// if (o1->body && o2->body) return;
// exit without doing anything if the two bodies are connected by a joint
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;
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.1;
contact[i].surface.bounce_vel = 0.1;
contact[i].surface.soft_cfm = 0.01;
}
printf("hello?\n");
int numc=dCollide(o1,o2,MAX_CONTACTS,&contact[0].geom,sizeof(dContact));
printf("hello? 2\n");
if(numc>0)
{
for(i=0;i<numc;i++)
{
dJointID c = dJointCreateContact(world,contactgroup,&contact[i]);
dJointAttach(c,b1,b2);
}
}
-------------------------------------------
trimesh setup:
-------------------------------------------
printf("Building collision mesh!\n");
meshData = dGeomTriMeshDataCreate();
dVector3* newVerts = new dVector3[noVertices];
int* newIdxs = new int[noIndices];
for( int i = 0; i < noIndices; ++i )
{
newIdxs[i] = indices[i];
}
for( int v = 0; v < noIndices; ++v )
{
newVerts[v][0]= positions[v][0];
newVerts[v][1]= positions[v][1];
newVerts[v][2]= positions[v][2];
}
dGeomTriMeshDataBuildSimple( meshData, (dReal*)newVerts, noVertices,
newIdxs, noIndices );
geom = dCreateTriMesh( PhysicsMgr::GetInstance().GetSpace(), meshData, 0,
0, 0 );
---------------------------------------------
-------------------------------
Fabian "SupaGu" Mathews
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
More information about the ODE
mailing list