Small flaw in Hinge callback

praetor

10-07-2006 01:24:55

I recently implemented a breakable hinge. In my wrapper for this, I plugged in to the OgreNewt Hinge callback. From within my callback I delete the hinge if the current force is over a threshold.

Now, immediately after this the callback within OgreNewt accesses my deleted hinge. This trashes the heap and caused quite a few headaches. While researching this issue I saw that Newton allows for the destruction of joints even within callbacks. I thought you should know that OgreNewt break this.

I fixed it by simply waiting until the next frame to actually do the joint destruction. I have no real suggestions to fix this issue, other my own workaround, but in case anyone else ever runs across this I figured I'd throw it out there.

maxwave

11-07-2006 18:59:37

I implement break of joints too. And I can't simply delete joint. I get error about heap free.

Now I use
hinge->~Hinge()
the joints are breaked, but app have leaks - when creating new joints.