How can i get the user data that is passed in this callback:
void NewtonMaterialSetCollisionCallback (const NewtonWorld* newtonWorld, int id0, int id1, void* userData,
NewtonOnAABBOverlap aabbOverlap, NewtonContactProcess process);
I am trying to get the user data in the NewtonContactProcess function. I pass the class as userdata so that i can use that object to access data members of the class that are not static.
If it is this function: NewtonMaterialGetUserData() to retrieve the userdata, can you show me how to use it?
I must be doing something wrong, because my game crashes when it gets at this line:
if(id1 == newtonPt->sphereID || id1 == newtonPt->q3MapID)
GenericContactProcess code snippet:
- Code: Select all
void CNewton::GenericContactProcess(const NewtonJoint* contactJoint, dFloat timestep, int threadIndex)
{
NewtonBody* body0 = NewtonJointGetBody0(contactJoint);
NewtonBody* body1 = NewtonJointGetBody1(contactJoint);
int id1 = NewtonBodyGetMaterialGroupID(body0);
int id2 = NewtonBodyGetMaterialGroupID(body1);
CNewton* newtonPt = (CNewton*)NewtonMaterialGetUserData(NewtonBodyGetWorld(body0), id1, id2);
if(id1 == newtonPt->sphereID || id1 == newtonPt->q3MapID)
if(id2 == newtonPt->sphereID || id2 == newtonPt->q3MapID)
{
newtonPt->PlayTheSound();
}
delete [] newtonPt;
}
NewtonMaterialSetCollisionCallback (world, sphereID, q3MapID, userData, NULL, &CNewton::GenericContactProcess);
The userData is a type of CNewton.
What am i doing wrong guys?