Here is my problem:
- I try to create a NewtonBody when I press A (for example) from a Key() event in GLFW and it crashes.
- When I press A (for example), I set a bool on true (in function Key() ), and in my update() loop, I create a NewtonBody (if the bool is true): it doesn't crash.
Here is how I create my body:
- Code: Select all
inline NewtonBody * DynamicBox(ml::mat4 m, float mass, float *d, Object *o){
NewtonCollision *c = NewtonCreateBox(world, d[0], d[1], d[2], 0, NULL); //<-- crashes here
NewtonBody *b = NewtonCreateDynamicBody(world, c, &m[0].x);
NewtonBodySetMassProperties(b, mass, c);
NewtonDestroyCollision(c);
InitBody(b, o);
return b;
}
inline void InitBody(NewtonBody *b, Object *o){
ent->b = b;
NewtonBodySetUserData(b,ent);
NewtonBodySetForceAndTorqueCallback(b, ApplyForceAndTorque);
//NewtonBodySetTransformCallback(b, ApplyTransform);
NewtonBodySetDestructorCallback(b, DestroyBody);
NewtonBodySetAutoSleep(b, 1);
NewtonBodySetLinearDamping(b, 0.f);
}
and it crashes at NewtonCreateBox(). I had this issue some time ago and I "resolved" it with the bool trick.
I tried copying the exact same code in the 2 functions; it doesn't work in Key() but it works in update().
PS: I can't update to the latest newton game dynamics lib (I have the version of 22/7 - something like this) because my internet connection is unstable (disconnects all the time). Hopefully, it will work once again this week...
I don't think I will be able to go to the forums today.