[ODE] nearcallback pointer help
Arturo Colorado Garín
acolorado at telefonica.net
Mon Nov 6 13:39:44 MST 2006
Well, it's the same idea as mine, only that your "bridge function" is a static class member instead of a global function. I still prefer the global function because it only appears in the .cpp file and therefore keeps the class declaration clean. But both are equally valid and basically the same.
Btw, in CB_nearCallback I forgot to cast the 'data' parameter from 'void *' to 'PhysicsManager *'.
Cheers,
--Arturo.
----- Original Message -----
From: Vortex 2
To: ODE (mailing list)
Sent: Monday, November 06, 2006 3:34 AM
Subject: Re: [ODE] nearcallback pointer help
I do it a differerent way.
First in my class header I have this:
static void nearCollision(void *data, dGeomID o1, dGeomID o2);
void CollisionCallback(dGeomID o1,dGeomID o2);
Now I have this code in my source file:
In my class I have an update method and in that update method I have this:
dSpaceCollide(mSpace,this,&nearCollision);
Then I define nearCollision like this:
void PhysicsWorld::nearCollision(void*data,dGeomID o1,dGeomID o2)
{
PhysicsWorld*pThis=(PhysicsWorld*)data;
if(pThis)
{
pThis->CollisionCallback(o1,o2);
}
}
Then I have my actual collision callback:
void PhysicsWorld::CollisionCallback(dGeomID o1, dGeomID o2)
{
//collision code here and stuff.
}
------------------------------------------------------------------------------
_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://q12.org/pipermail/ode/attachments/20061106/98bd7854/attachment.htm
More information about the ODE
mailing list