Here's an example of the sort of thing I'm doing:
var dt = 1.;
var pair = new CirclePair(cs[0], cs[1]);
while (pair.willCollide(dt)) {
pair.c1.integrate(pair.toi);
pair.c2.integrate(pair.toi);
dt -= pair.toi;
pair.resolve();
}
for (c in cs) {
c.integrate(dt);
// Reset forces etc
c.fx = 0;
c.fy = c.mass*gravity;
}
This works in certains situations, though in others will just completely lock up. If I add a breaking term, for instance incrementing a variable each step and terminating the while loop if it exceeds a certain value, then it never crashes but penetration occurs. What could be the cause of this?



















