MouseJoint Flickering

Hi to all!

I'm making my first iPhone game.
I have increasing number balls that can be dragged. I had some problems with inertial delay of mousejoint and I configured them as follows:

Code:
b2MouseJointDef md;
md.body1 = _groundBody;
md.body2 = body;
md.target = p;
md.maxForce = 10000.0f * body->GetMass();
md.dampingRatio = 0;
md.frequencyHz = 100;
_world->CreateJoint(&md);


When I have 10/15 balls all is ok.
When I have 30/40 balls the overall performance seems to be ok but the dragging operation flickers a lot.
Is it a problem related to frequencyHz? Am I doing something wrong?

Thanks!
What does "flickers a lot" mean? sounds like a problem with your rendering engine. Box2D is a physics engine. It doesn't do flicker.
You are right.

I'm intending that behaves jerky.
Box2D uses an iterative solver for performance. The solver is not exact.

It sounds like you are up against the edge of its abilities. If you desire a mouse joint that is very strong and rigid, you may need to increase the velocity iterations and/or reduce the time step.
Erin Catto wrote:
The solver is not exact.

What do you mean?

Erin Catto wrote:
If you desire a mouse joint that is very strong and rigid, you may need to increase the velocity iterations and/or reduce the time step.

Is it not the same thing setting frequencyHz on the mouse joint?

Thanks
ricibald wrote:
What do you mean?


Box2D uses Gauss-Seidel to approximately solve constraints. You can read about it here:
http://en.wikipedia.org/wiki/Gauss%E2%80%93Seidel_method

Box2D also uses Semi-implicit Euler to approximately solve the differential equations:
http://en.wikipedia.org/wiki/Semi-implicit_Euler_method

ricibald wrote:
Is it not the same thing setting frequencyHz on the mouse joint?


No, the frequency on the mouse joint controls the frequency of oscillation (of the mouse joint):
http://en.wikipedia.org/wiki/Harmonic_oscillator
Now I'm not setting frequencyHz. The mousejoint makes inertial delay but in this phase it's ok. When about 30 balls are awake my mouse joint continues to behave jerky!

I configured velocity and position iterations to 1 and timestep synced with actual fps of my game.

My overall performance seems to be ok: animations are still smooth but only the drag operations behaves jerky.
When my finger is on (x2,y2) the body continues to remain in (x1, y1). After 0.2 sec my finger is in (x3,y3) and my body is in (x2, y2) without passing the points between (x1, y1) and (x2, y2).

I can't explain why!
I tested dragging circles in the Confined example of the testbed. I see no problems with jerkiness.
Maybe it's an iphone cpu limit.

Original thread: https://box2d.org/forum/viewtopic.php?t=4427