RE: https://mastodon.gamedev.place/@runevision/115736639369756581

What are good approaches to enforce minimum distances in a simulated web of “springs”?

I have forces that both push and pull to approach an ideal distance between nodes, but avoiding too short distances should take priority over avoiding too long ones. If I just make the pull forces weaker, things converge slower, which is not great.

@runevision Maybe an asymmetric spring-damper? Change your force constants if the distance is less than a "too close" distance.

Something like f = d < d_min ? (k_min * (d_min - d) - c_min * min(v,0)) : (k_max * (d - d_max) - c_max * max(v, 0))

Obviously this can become a stiff spring that will blow up your integrator so choose a large k_min wisely, or improve the integrator.

You could also make the <d_min spring exponential for possibly better animation.