Sign in to follow this  
chillypacman

collision woes in ode... (callback function)

Recommended Posts

chillypacman    100
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 this post


Link to post
Share on other sites
BradDaBug    913
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 this post


Link to post
Share on other sites
chillypacman    100
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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this