Gila
08-05-2006 09:10:16
I have just encountered a very strange problem which seems like either a bug in Newton/OgreNewt or just a strange behaviour caused by what I'm doing.... hope you can help...
In my game I have objects that can change shape as the game progresses - chunks of objects may be detached and glued onto other objects.
I've implemented this by having each of my GameObjects contain a pointer to an OgreNewt::Body which is created in the initial shape at creation time. Part of this creation stage also assigns the custom force callback, which is a member of my GameObject and uses the state of the GameObject to generate the appropriate extra forces (e.g. dragging by the player).
When a shape gets modified I have a function something like this:
What happens is that customForceCallback is no longer called (a breakpoint in the function is never hit).
Unfortunately it would be hard to reduce my actual code to a minimal example to repro this. If necessary though, I could probably hack one of the OgreNewt demos to try and create the same situation.
Thanks in advance for any help.. it's making me pretty sad!
In my game I have objects that can change shape as the game progresses - chunks of objects may be detached and glued onto other objects.
I've implemented this by having each of my GameObjects contain a pointer to an OgreNewt::Body which is created in the initial shape at creation time. Part of this creation stage also assigns the custom force callback, which is a member of my GameObject and uses the state of the GameObject to generate the appropriate extra forces (e.g. dragging by the player).
When a shape gets modified I have a function something like this:
- Delete the current Body (storing the position, velocity, etc)
- Generate a new Collision for the new shape of the object
- Generate a new Body using this Collision
- Set the force callback, i.e.
pBody->setCustomForceAndTorqueCallback( fastdelegate::MakeDelegate( this, &GameObject::customForceCallback) );
- Restore position, velocity, etc. from the old body.
What happens is that customForceCallback is no longer called (a breakpoint in the function is never hit).
Unfortunately it would be hard to reduce my actual code to a minimal example to repro this. If necessary though, I could probably hack one of the OgreNewt demos to try and create the same situation.
Thanks in advance for any help.. it's making me pretty sad!