# collision woes in ode... (callback function)

## Recommended Posts

Here is what I'm using to find collision (unnecessary code has been cut out):
dGeomID geomID1;
dGeomID geomID2;

dSpaceID spaceID1;

dNearCallback* hit(void *data, dGeomID o1, dGeomID o2);

dSpaceCollide(spaceID1, 0, hit(0, geomID1, geomID2));

dNearCallback* hit(void *data, dGeomID o1, dGeomID o2)
{
dNearCallback* d;
return d;
}


When a collision actually occurs I get an error about an access violation to this line in collision_space_internal.h: callback (data,g1,g2); I have no idea what I could be doing wrong, I'm just trying to get ode to recognize a collision is occurring without doing anything about it. I think it is recognizing that a collision is occurring but it's crashing on me which is obviously not good. Theres also a really strange problem with the camera now, whenever I try to move it forward or strafe it right I get the error 'bad arguments' in collision_space.cpp:736. Though it works fine if I'm changing the viewing angle or moving it left or backwards. Really strange, this only just started happening when I tried implementing ode's collision system. [Edited by - chillypacman on May 4, 2007 8:35:57 AM]

##### Share on other sites
It looks like you don't quite understand how function pointers and callbacks work. The collision problem is because you're sending an uninitialized function pointer to ODE, and when it tries to call the function it crashes. The call to dSpaceCollide() should look more like this:

dSpaceCollide(spaceID1, 0, hit);

and hit() should look more like this:

void hit(void *data, dGeomID o1, dGeomID o2){   // test collision between o1 and o2 with dCollide()   // or something like that   ...}

##### Share on other sites
yep, I didn't really know how to use callbacks

Thanks for the help, works fine now. I didn't understand what the ODE manual was getting at when it showed the typdef of dNearCallBack.

Thanks for the help :)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628291
• Total Posts
2981862

• 11
• 10
• 10
• 11
• 17