Original Post
Okay, here is my collision detection loop:
time = time_delta;
while (time != 0)
{
c = check_for_collisions (simulator, time);
/* c is the earliest collision */
if (!c) break;
integrate (c.time);
handle_collision(c.e1,c.e2);
time = time - c.time;
}
integrate(time);
I am using the collision response developed in chris heckers articles. So after I detect a collision, I adjust the colliding entities velocities, and then re-check. What happens is that I will get another collision right away, because I moved the entities to the point that they collided. Now to avoid this, I would only move the entities until they where just about to collide [ integrate (c.time * 0.99)]. But this breaks down sometimes and then I get in to an infiniteloop. So I added a collision count, so I would only handle 5 collisions per step. But this doesn''t really solve the problem properly.
Any suggestions on how to solve this problem?