Step function out of stack space

I must be doing something wrong because I only have a handful of objects in my scene and I get this exception after playing for maybe a minute:

java.lang.StackOverflowError: The ODE step function could not allocate enough stack memory to compute the time step!

This is usually caused by low stack size or by too many applied contacts respectively (number of contacts in this step was 3736).

What causes the number of "contacts" to go up?  What should I look for in my code?  Thanks.

As far as I can tell, ODE can't support a large number of contacts.  I believe that a contact is where two or more objects are 'touching'.  So, it's not necessarily the number of physics objects you have in your code…but the number of them that are interacting with each other.

For instance, having a couple hundred boxes hitting each other will probably be OK.  They're pretty simple shapes without 'much' computation behind them.  However, load up the ragdolls or even the Maggie object (I have done both) and add a several to your program.  If they are not touching each other, all is well.  However, slam them all together and the complex objects (assuming you calculated the physics geometry with 'triangle precision') quickly increase the number of contact points.  This then kills the system.

My suggestion would be to make your detailed graphical objects and then use simple physics objects to represent them.  Example being, if you're making a person with a very detailed hand, that doesn't necessarily mean you need that detail in the physics world.  You could probably represent each finger on the hand with one or two boxes (and connect them with Joints, just like on your actual hand).  This would then in turn reduce the complexity within the physics world (reducing the contacts as well), but would leave you with your desired graphical detail.

Feel free to correct me if I'm incorrect on any of this info.  :wink:


Currently my scene consists of a 1024x1024 height map with 2 textures (not sure if I'm saying that correctly), two tanks, and a couple "cannon balls" shot from the tanks.  The tanks are currently made out of 3 boxes (one for the body and two for the treads which use surface motion to make the tank move) which are attached to a DynamicPhysicsNode.  The cannon ball is also just a simple box (I originally tried spheres but it kept crashing in native code, not sure why).  I can't seem to find where to setup triangle accurate collisions, so I don't believe I've set that anywhere on anything.

Its actually only crashed that one time, but it always slows to a frame every 2-3 seconds after only running for a minute or two, so I suspect its the contacts thing.

maybe your objects are not deleted correctly and are still there physically.

enable the physics debug view to see whats going on.