Hi everyone!
Preamble.
In our game we have a coefficient named "ptmRatio" (pixels to meters ratio). All coordinates, dimensions and forces depends on it.
We also have a rope and a track (for crawler excavator), consisting of small objects with b2RopeJoint and b2LinearJoint.
Problem.
Once we desided to increase ptmRatio from 46 up to 1000 (and tuned all settings proportionally) to make our physics more realistic. Before these manipulations everything was perfect, but now a rope and a track elements began vibrate spontaneously.
Screencast:
In this video you can see, that rope elements vibrate slowly, but on real device with normal FPS is looks terribly, besides it shakes other objects!
http://dl.dropbox.com/u/17069366/trembling.swf
Simulating:
Preamble.
In our game we have a coefficient named "ptmRatio" (pixels to meters ratio). All coordinates, dimensions and forces depends on it.
We also have a rope and a track (for crawler excavator), consisting of small objects with b2RopeJoint and b2LinearJoint.
Problem.
Once we desided to increase ptmRatio from 46 up to 1000 (and tuned all settings proportionally) to make our physics more realistic. Before these manipulations everything was perfect, but now a rope and a track elements began vibrate spontaneously.
Screencast:
In this video you can see, that rope elements vibrate slowly, but on real device with normal FPS is looks terribly, besides it shakes other objects!
http://dl.dropbox.com/u/17069366/trembling.swf
Code:
ropeElement.density = 5.0f;
ropeElement.size = 0.006f;
settings.jointLength = 0.01f;
gravity b2Vec2(0, -10);
ropeElement.size = 0.006f;
settings.jointLength = 0.01f;
gravity b2Vec2(0, -10);
Code:
b2RopeJointDef joint;
joint.maxLength = settings.jointLength;
joint.bodyA = elementPrev;
joint.bodyB = elementNext;
joint.localAnchorA = elementPrev->GetLocalCenter() + b2Vec2(0, ropeElement.size / 2);
joint.localAnchorB = elementNext->GetLocalCenter() + b2Vec2(0, ropeElement.size / -2);
joint.maxLength = settings.jointLength;
joint.bodyA = elementPrev;
joint.bodyB = elementNext;
joint.localAnchorA = elementPrev->GetLocalCenter() + b2Vec2(0, ropeElement.size / 2);
joint.localAnchorB = elementNext->GetLocalCenter() + b2Vec2(0, ropeElement.size / -2);
Simulating:
Code:
// every frame
int32 velocityIterations = 20;
int32 positionIterations = 20;
world->Step(1.0f/60, velocityIterations, positionIterations);
int32 velocityIterations = 20;
int32 positionIterations = 20;
world->Step(1.0f/60, velocityIterations, positionIterations);