Original Post
Hey guys, been working on something all day and haven't been able to make any progress whatsoever.. I've been trying out continuous collision detection through an approach of "find time of impact, if it's within the next frame integrate positions to that time, solve, then resume simulating" which should work fine. I've been looking at a few implementations, namely Andre Michelle's PopShapes physics engine (and his other one, Revive, but I think his site's down just now). I understand the method and the theory behind it but when it comes to implementation I can never seem to get it quite right, it'll detect first collisions and attempt to solve them but it can easily.. go wrong.
Here's an example of the sort of thing I'm doing:
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?
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?