[ODE] trimesh collision causes crash?

Fabian Mathews supagu at hotmail.com
Thu Feb 26 12:51:03 MST 2004


right, when my ball comes in contact with my triangle mesh it
A) crashes or B) goes through, this depends on my callback function when 
calling
dSpaceCollide

this is what i have:

#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;
  }
  if (int numc = dCollide(o1,o2,MAX_CONTACTS,&contact[0].geom,
			   sizeof(dContact)))
  {

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



extra info if you need it:

my box physics object:
PhysicsObj::PhysicsObj()
{
	dMass m;
	body = dBodyCreate( PhysicsMgr::GetInstance().GetWorld() );

	dBodySetPosition(body, 0, 30, 0);
	dBodySetLinearVel(body, -5.00, 15.0, -5.00);

	dMassSetBox( &m, 5.0, 5, 5, 5 );
	geom = dCreateBox( PhysicsMgr::GetInstance().GetSpace(), 5, 5, 5);

	dBodySetMass( body, &m );
	dGeomSetBody( geom, body );

	SetSpace( PhysicsMgr::GetInstance().GetSpace() );
}

//set space just set the objs to that space

//and the settup for my trimesh:
bool ColTriMesh::Build()
{
	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 );

	return true;
}


Im guessing its something with the call back function as thats where it 
crashes :-/


Thanks from,
Fabian


-------------------------------
Fabian "SupaGu" Mathews

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail



More information about the ODE mailing list