phys2d question on iterations

what does changing the number of iterations do…?

should i just use 1 iteration in my program…?

I’m not really sure about that, but i think it is something like that : the number of iteration is the number of test that are done to detect a collision in one step. If you increase the number of iteration, you will increase the chance that Phys2D do not miss a collision, but you increase the calculation time for one step.

I didn’t fixe this number myself for my game, the best is may be to just do some tests : start with a low number; test your game and if some high speed object pass throught another, increase the number of iteration.

Iterations is more to do with accuracy of response in this case, rather than sampling more often to make accurucy of collision better. If you imagine a whole series of bodies interacting with each other it’s a complicated thing to work out what the resulting forces are - the iterative solver (i.e. the number of interations) applies the impulses of the bodies to each other over and over eventually resulting in the forces coming out of the collision - the number of iterations per frame is how many times the solver will reapply the impulses before deciding that it’s “close enough”.

Either way, the response was correct - the number of iterations is a balance between performance and accurcy and you need to experiment with your particular simulation to determine a good number. For a rough figure I generally find 10 is plenty and I’ve never had to go above 20.

The lack of cotinuous collision detection causes me a problem way before that :wink:

Kev

hmmm i see~

so i should start with a low number first and then increase it later if necessary…?

thanks :slight_smile:

i found out more about iterations…

if you have a iteration of 1, very little force is produced when 2 bodies collide - even if both bodies have a restitution of 1.0f

i tested it out on my program, using 1 ball bouncing on a body and another ball bouncing on a staticbody…

apparently i had to increase the number of iterations to 10 to achieve a similar collision result from both balls…


in other words, the number of iterations determine the accuracy of the force produced from a collision between 2 bodies. is my understand correct…?
feedback appreciated. :slight_smile:

The number of iterations changes the accuracy of response. Yes.

Kev