collision detection loop

Started by
0 comments, last by ttb 20 years ago
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?
Advertisement
-Don''t intercept collisions when bodies are moving apart
-How I do it: avoid any collision. Just measure distances between bodies and if a certain threshold is reached, apply collision response. By doing so you know exactly when bodies (or "colliding" features) are moving apart because you have the measured distance vector to compare with the relative speed of colliding features. At the same time you can handle as many colliding features on one body as you want (multiple collisions)

This topic is closed to new replies.

Advertisement