0
\$\begingroup\$

I've been trying to figure this out for weeks but every resource only provides answers for a single body. As far as I can tell for a single body you

  1. Find the time of impact
  2. Step up to that time
  3. Resolve collision
  4. Restart from 1 until there's no impact until present frame

I've also seen some engines limit these "sub steps". The closest I could find is that an engine steps each body to their first collision. But what if A and B collide at 0.1 and A and C collide at 0.4. If we resolve the AB collision, the AC collision may not exist, thus stepping C up to 0.4 would be incorrect.

My question is, for multi body systems, how do you go about resolving and stepping continuous collision?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I wrote this free article last month that you may find useful: Perfect, Infinite-Precision, Game Physics in Python. It covers multiple collisions. Although I used Python, the math and methods work for any language. It also has links to other discussions and references. The biggest surprise for me was that Newtonian physics is (at best) incomplete and (at worst) non-deterministic.

  • Carl enter image description here
\$\endgroup\$
6
  • \$\begingroup\$ This is currently a link-only answer. If the link to your article ever rots, a user reading this post won't gain any insights about how to resolve multiple collisions. Can you edit this post to at least briefly outline an answer, linking to the article for further details? If not, I can convert this answer to a comment for you. \$\endgroup\$
    – DMGregory
    Commented Dec 17, 2022 at 19:42
  • \$\begingroup\$ In case it doesn't get updated, I looked at the article. It's doing what I effectively felt was too heavy. Basically testing all collision pairs, only advancing to the first, resolving, then testing all pairs again since the first being resolved will affect the simulation. So that is evidently one completely acceptable way to do it. I'm curious if there's any more standard approaches used in game physics that aren't as heavy. But for now this is how i'll implement mine. \$\endgroup\$
    – gjh33
    Commented Dec 17, 2022 at 22:26
  • \$\begingroup\$ [This is Carl, who shared the link. Here are more details] As gjh33 says, I look at all pairs of collisions and then resolve all the one(s) that happen first. When multiple collisions happen at the same time, my simulator assumes that we can order them randomly to get a plausible outcome. They still get resolved at the same time, just in random order. This adds non-determinism and can mess up symmetry, but I think it is never-the-less a reasonable assumption (I think this is a common assumption in game physics.) \$\endgroup\$
    – Carl
    Commented Dec 18, 2022 at 23:08
  • \$\begingroup\$ [more carl] If two objects are not involved in any of the resolved collisions, we don't need to recompute the time of their next collision, instead we can just update the time we got from previous calculations. (This optimization is discussed in Part 4, also it doesn't update objects that are not moving.) In theory, this could turn a quadradic calculation (all pairs) to linear, but in my experience, it didn't help that much because the most costly-to-compute calculations involve many objects at the same time. \$\endgroup\$
    – Carl
    Commented Dec 18, 2022 at 23:13
  • \$\begingroup\$ [more carl] The article gives exact formulas for the time of the next collision of two moving circles (without gravity) and circle moving to an infinite wall. [Sorry, they are too long to give here.] The article also gives the formulas for how a collision changes the velocities of two circles and circle/wall-of-infinite-mass. The formulas assume perfect elasticity. All the formulas are derived using a free computer algebra system available in Python. \$\endgroup\$
    – Carl
    Commented Dec 18, 2022 at 23:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .