I am a computer science student and I came across the Verlet Cloth simulation. An implementation is here. I was interested in how such computation would lend itself to parallelization.
The problem looks like a variant of N-body computation where we could compute constraints on each point and them move the points based on the effect of the constraint. I tried along those lines and ended up with "logical" errors. I am sure my understanding of the physics is incomplete.
Here is what I tried. Assume a constraint C between A and B. Instead of trying to resolve C once and update both A and B, I tried resolving C twice once along with A's constraints and update just A and once along with B's constraints and just update B.
From this link, I am wondering whether the constraint resolution for each point can be done independently of the other, when each point is constrained by multiple other points.
dist = Math.abs(A - B)
diff = (dist - r) / dist
moveBy = 0.5 * diff * dist
A = A + moveBy
B = B - moveBy
Doing this for each constraint works. But the moment, I compute all these "moveBy" values for all constraints together and move the points by the sum of these values, things don't work. This makes me think that the order in which the points are resolved for constraints and the order in which constraints are applied matters.Is that right?