[ODE] dCollide crashes me app!
Rob Ruck
bobruck at btinternet.com
Fri Feb 27 12:14:25 MST 2004
>From what I can work out, its tri-meshes crashing for you, and none of the
other primitives. The callback looks fine at a glance, and so does the snippet
of tri-mesh setup code, but.... From the look of it, you new the indices/vert
data locally, and I imagine, you probably delete it too. The tri-mesh stuff
doesn't make a copy of this data, you need to alloc it and leave it alloc'd until
you're finished, and then delete it yourself.
On 27 Feb 2004 at 0:37, Fabian Mathews wrote:
> 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
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
--
Rob Ruck
mailto:bobruck at btinternet.com
More information about the ODE
mailing list