I noticed a major performance hit on my iPhone game engine with 2.0.2 versus 2.0.1. Further testing shows that objects are not sleeping with SVN 2.0.2. A single body with a rectangular shape, laying on a static body (density=0) will not sleep, even though it does not appear to move. The same setup works fine with SVN 2.0.1.
In b2Island::Solve() the body always has body angular and linear velocity during the sleep test, even though it is stationary.
Is this a known issue, or is there certain properties that a body must have in 2.0.2 to sleep? I've tested both under Win32 and iPhone with the same results.
If I use a restitution greater than .001 then the bodies will not sleep. With a smaller restitution they will sleep.
Here's more info.
Timestep: 1/60 fixed, 10 velocity and 10 position iterations
Floor:
Density: 0.0
Shape: 50x1 rectangle
Friction: 1.0
Restitution: 0.0
Dynamic object:
Shape: 1x1 square polygon
Density: 1.0
Friction: 1.0
Restitution: 0.1
Mass, as computed by SetMassFromShapes(): 1.0
It works for me in the testbed. Did you adjust b2_velocityThreshold? Any other adjustments?
Can you reproduce this in the testbed? If so, please attach the code so I can debug it.
I've spent the last hour building the testbed (obtaining glut, glui, etc). Now I see that none of the tests are compatible with 2.0.2 (ie uses CreateShape instead of CreateFixture, etc). Is there a testbed that works with 2.0.2?
Dan
I figured out why they aren't sleeping. If gravity is greater than 60 then the bodies wont sleep. With 2.0.1 bodies will sleep with gravity as high as 100. The same issue manifests for setting forces directly to objects.
2.0.2, as retrieved from SVN, doesn't have glut or glui, and the examples are not compatible with the 2.0.2 API changes.
Yes, this fixed the sleeping problem in our game. We were using gravity of Y=80 with damping 2.0f. Now with Y=40 and damping of 1.0f the objects are sleeping. The motion now slightly different because of the lower damping, but at least objects seem to fall at the same rate.
So it seems 2.0.1 would sleep objects with higher forces / gravity applied, whereas 2.0.2 retains a "residual" linear and rotational velocity for objects that are stationary against fixed objects.