Question

I'm writing a physics engine that uses Verlet integration, and i can't get some constraints to work right. Some (like a bond/weld constraint) are extra "soggy" and aren't stiff enough, while others (like an area constraint) are extra bouncy and send atoms flying. The code for my update ethod in my physics simulator is like this:

    ProcessRemovedItems();
    ProcessAddedItems();
    _colliderManager.Update(timestepSize);
    foreach (Atom atom in _atomList)
    {
        atom.Update(timestepSize);
    }
    for (int i = 0; i < _iterations; i++)
    {
        foreach (IConstraint constraint in _constraintList)
        {
            constraint.Update();
        }
    }

I've tried all idfferent combinations of update orders and none help. I have a vague idea of something about using iterations but have no clue what else would help. Any suggestions?

Was it helpful?

Solution

You are correct in your assumptions of iterations.

By running the verlet integrator part multiple times in a frame, the stiffer and better the simulation works).

This is due to the following: say you have 5 atoms next to each other, and when the last atom gets integrated, it is moved a bit. unfortunately it is moved i to the atom next to it. It takes a complete frame, before the integration is done again and this is fixed (due to the constraints). How ever, chances are, the atoms again are placed inside the others.

so to counter this effect, the more iterations you do (so the more times per frame you call the integrator), the better the simulation will work and conform to your constraints,

however, you'll notice that the more you run the integrator per frame, the more processor power it will use. So there is a sweet spot somewhere which you have to find manually

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top