Verlet integration is a great start, but Position Based Dynamics (PBD) is the modern standard for stable, high-performance physics. Used in Nvidia PhysX and AAA titles for cloth, ropes, and hair, it is significantly more robust than traditional force-based solvers.
In traditional physics (Newtonian), you calculate:
Force -> Acceleration -> Velocity -> Position
The problem is that if the force is too high, the object “overshoots” its target in one frame, leading to an explosion. PBD skips the middleman and directly manipulates the Position.
projectedPos).Velocity = (FinalPos - OldPos) / dt.Because you are directly moving the particles to their “correct” locations, the system can never accumulate infinite energy. If you pull a PBD rope too hard, it simply stays at its maximum length. It cannot “explode” because it is not relying on acceleration to fix its state.
void StepPBD(float dt) {
// 1. Prediction
foreach (var p in particles) {
p.predictedPos = p.pos + (p.velocity * dt) + (gravity * dt * dt);
}
// 2. Solver Iterations
for (int i = 0; i < solverIterations; i++) {
foreach (var c in constraints) {
c.Resolve(particles); // Directly shifts predictedPos
}
}
// 3. Finalize
foreach (var p in particles) {
p.velocity = (p.predictedPos - p.pos) / dt;
p.pos = p.predictedPos;
}
}