4 ms·
I don't have much experience either, but here's my best attempt: Speculative Contacts is a fairly new technique for collision detection - solving the problem o
by philh 16y ago
I don't have much experience either, but here's my best attempt:
Speculative Contacts is a fairly new technique for collision detection - solving the problem of are any objects trying to occupy the same space at the same time? without taking too long over it.
This blog is talking about one advantage of SC, which is stability. Physics engines are hard to write, and stability is one problem that you come across when trying.
Suppose you have a ball falling towards a plane. You move the ball, then discover that it's intersecting with the plane, so you move the ball back a little until it's not.
But now suppose you have two balls. When you move the first ball back, now it's intersecting with the second ball. If you try to solve that, you might run into problems with a third ball, or with the plane again. And so on.
Stability is the problem of solving all these constraints in a way that looks good. Roughly, that means the balls should be touching but not visibly intersecting, and they shouldn't be jittering (moving a few pixels per frame, but staying in roughly the same position). This is a hard problem.
Usually you run the constraint solver (moving things so they're not colliding, but potentially generating new collisions) multiple times to try to get stability, and there are other techniques available. What the blog post is saying is that none of that is necessary with SC: it gives you stable simulations with only one pass of the constraint solver and without running any other fancy algorithmhs.
- JoeAltmaier 16y agoThe description seems to ignore elastic collision - contact always occurs on a frame boundary which is noticeable wrong when higher velocities occur. Wouldn't the described solution result in 'sticking'?
- philh 16y agoNo, because the rebound velocity doesn't depend on how far two bodies intersect. To answer the wider question - when a contact is detected, you can immediately calculate the new velocity of the two bodies. Then you move things around to be nonintersecting. Then next frame, everything has the correct velocity. (In fact, this will be done in two passes. Collision detection will generate a list of contacts, containing properties like the initial velocities of the two bodies. Then the collision resolution phase will change the velocities.)
- JoeAltmaier 16y agoIts harder than that - the rebound path can generate more collisions. Its iterative and can take an indefinite amount of time to calculate a frame.