Original Post
This is a common problem, but the search terms for it are far too general, so I can’t find anything. Anyone who has made a generic circle/line physics engine should know of this problem. For now, I am using only circles. Things are 100% perfect if I do not use gravity, and allow things to just bounce off each other. When I apply gravity, things fall down and eventually come to rest on the ground, which I created using a series of more circles that don’t move. The common problem is that, thanks to floating-point errors at such low velocities, the circles are able to slowly melt through the ground and eventually fall through. I would like to know the common methods for defeating this problem. The problem is that when the objects rest on each other (but not embedded), their distances are 0, which in collision detection means they infinitely collide with each other. But I have to allow this because the distance at the time of collision between moving objects is also 0. My first approach: When objects collide, I move forward in time to JUST BEFORE the collision (then resolve their vectors to bounce away), so they don’t cause another collision in the recursive call afterwards. This solved nothing. My second approach: When objects are detected as being embedded, they are pushed out of each other directly away from their center points. So when the circles start to melt into the ground, they are pushed back up, and things are almost flawless because they can only melt when at low speeds, so it does not create a jitter in the object’s path. But the problem is when more circles are introduced. Now Circle A gets pushed upwards, out of Circle B (the ground circle), but Circle C is resting on Circle A, and now THEY are embedded. The routine continues, and then pushes Circle A back down, to unembed it from Circle C. Now it is embedded into Circle B again, which allows it to melt into the ground again. I can remove this by starting the routine over after each unembedding, but this causes tremendous slowdown. Because of the speed issues, the second approach won’t work. So what are other common ways of handling this? Speed is very important because this is going to be running in several PlayStation Portable games, which is not a fast machine. Thank you. YogurtEmperor