0

I've implemented a simple disk-line segment collision detection and response algorithm. It's not swept, so if going fast enough it can clip, and fact that the collision detection occurs "after" the instant the disk hits the line (usually it'll've penetrated a tiny tiny amount in, because of how the physics works) can cause energy to leave the system, but the timestep is small enough and the colliders slow enough that it won't be a problem-- it's something I can do later.

It works perfectly with one segment. But with multiple it shows some pretty bad issues. It can escape a narrowing pair of lines like:

image of bad situation

I heard I could try to only respond to the collision that the disk has done "first"-- the one with the least depth (in the image that's the lower line, I guess). But that did not fix the problem.

What about adding together all the collision normals and normalising it to get a new virtual surface to bounce off? A horizontal one. But then how would I handle things like mass and restitution? Would I just "average" them out and perform one collision? Would that still be physically correct? What do I do? Some advice about it would be helpful.

Where should I draw lines of abstraction in the whole process? What in the process should be generic, and what can I bring out of my code into other functions to return values to simplify it?

Tachytaenius
  • 111
  • 5
  • 2
    Have you considered switching to a swept algorithm that will let you detect the time of impact, so you can resolve the earliest collision first (which may not necessarily be the deepest)? For something as simple as a disc and a line, a swept test isn't much more complicated than an instantaneous overlap check. – DMGregory Sep 01 '21 at 11:15
  • There are some meaningful tradeoffs going this way. This is one of them. Sometimes such tradeoffs can't be avoided when you resort to simpler approximations. – AturSams Sep 01 '21 at 14:48

0 Answers0