It’s tempting to do them independently (in parallel), but this makes convergence
much slower. We’re now moving nodes while they’re in the quadtree, which means
we could miss a few collisions; but since the tree is rebuilt on each iteration
that should probably be fine.
This reverts part of 95354e8470, though it retains
the area-biased resolution and the performance improvements.
Fix#25. We now resolve collisions for all nodes independently, rather than
moving one node at a time. And since we’re not mutating the quadtree while
resolving, the quadtree can now store the maximum radius for each quadrant,
accelerating search! We can also optimize resolution a little bit since now
resolutions are always symmetric.
Collision resolutions are now biased so that the acceleration is inversely
proportional to the circle’s area, such that larger circles (which are more
likely to overlap many small circles) are more stable.
Also: only jiggle if two circles are overlapping.
Fixes#23. This doesn’t catch all degenerate configurations, such as when x = y,
but it at least handles a common case for geometric constraints. As an added
bonus, this commit avoids extraneous jiggling in the many-body force when
visiting testing the target node’s quadtree cell.