Simply Grasping Collisions and Contacts

Started by
17 comments, last by BennettSteele 11 years, 10 months ago
Yeah, those make complete sense, and I know exactly know why it is like that: because you are checking each axis. But something more complex, like... having rigid-body physics... :-\

Im looking forward to something like that. Thats why I read that book about it, but it did not explain it in such a matter that helped me completely understand it.
Advertisement
There are two major problems:

  1. The physics of arbitrary collisions without rotation isn't natural, so requires assumptions from the programmer.
  2. Single collisions are easy(ish), multiple simultaneous collisions are hard. Proper physics engines have solvers that take many iterations to try and resolve the many constraint violations caused by solving the collisions locally. So for example, if blocks A, B and C are in a line and hit on the end by block D, firstly momentum will be transferred to block C. But that causes a collision with block B. Solving that causes a collision with block A. If block A is "free" it can then shoot off like a Newton's Cradle. If block A is pressed up against a wall, then this needs to be propagated all the way back to D.

Basically I'm saying that if you're trying to do single collisions, that's cool and probably easy. Anything else... is really a hard problem, so no wonder it's confusing you.
XD Yep. And since this is my first time doing everything, its a lot harder. laugh.png

I bet if like the way i have come along, which is to start as simple as possible, then progress to harder things, i might be able to learn something. But if anyone has any links or tutorials even, it would be greatly appreciated. happy.png
I appreciate your struggle, it can definitely be a lot to wrap your head around (I don't really feel like I truly understand anything about collision yet either).

One resource that you might find edifying is Paul Firth's excellent tutorial, which covers a lot of material: http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

Personally, one concept which has really helped me better understand collision is Minkowski sums (or differences); for your example of two axis-aligned rectangles, imagine reducing the width and height of box A to 0 (so that the box becomes a point) while simultaneously increasing the width and height of box B by the same amount -- you now have a point A and a box B, which is simpler to visualize/think about, and completely equivalent to the original problem.

Separating collision detection (geometric queries) from how you use the results (collision resolution/solving) can also help make the problem easier to understand. In terms of solving a set of constraints, this is another great overview to start with: http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/
Thanks for posting those links Raigan :)

The OP might also appreciate this article, in which I describe generating the full contact set (among many other things) from the closest feature pairs returned by SAT, or minkowski difference:

http://www.wildbunny.co.uk/blog/2011/06/07/how-to-make-angry-birds-part-2/

Just part of implementing a physics engine capable of playing angry birds - hence the title :)

Cheers, Paul.
Thanks! :P

These look really good, I plan on reading them all tonight. It looks really well made, too. :)
So im doing some testing, and got point-box collisions working well. although since the game runs slow sometimes, the dots will pass through walls... but i can fix that.

[color=#666666][size=2][background=transparent]

[background=transparent]
[/background][/background]

But it runs fine regularly... and im hoping to move on to some other different collisions...

well for point to box you can specially design a "closer distance contact" function to avoid passing through boxes.
(raycasting) this function is made by solving the system made of the equations of a line (your ray) and the planes of the boxes.
in this case you would have implemented "swept collision".
also, you need to run your physics/collision loop in a fixed time step.
also, an idea for later, some engines does not run the collision detection at every simulation step.
Well, since it it tile based, it checks for collisions each time it crosses over to another block. it is slow because i have never wanted to take the time to make it more efficient, and im using fraps. :P

Since it uses it's velocity to check for the next box, when it is slow it will check far away. if you use +1 to its position, it will bounce when 1 unit away. if you use just its position, it will get stuck. :-\

This topic is closed to new replies.

Advertisement