Collision demos

This is a set of similar demos showing how to make simplified collision detection and handling, based on spherical animated object and static convex polyhedra. If you need something more complex than that, maybe you should try a physics engine.

0. Interactive collision detection with no dynamics

This first example only shows how collision detection works. A single sphere can be moved by WASD keys, and if it collides with the polyhedron, it is moved away.


1. Collision detection and handling, many spheres and one polyhedron

This demo shows a number of spheres bouncing off each other and a polyhedron. Thus, basic physics is handled and it worked pretty well. However, this is a simple case.


2. Surfaces

A number of spheres are bouncing down a few planes. This is a case where this simplified system works really well. It is hard to see any cases that fail.


3. Pile

This example shows a case where our model is not sufficient. The failure is intentional; I want to show what the limitations are. Piling things on top of each other is a typical case where simplified physics fail. In this case, we don't get any problems with stability, but the positions of the spheres are not pretty.


4. Nasty

The final case is one where we get less problems than expected. The case is the chute, two planes that narrow with a steep angle. Even full-fledged physics engines have had problems with this. I provided two cases, one which works well despite fairly steep slope, and one even worse where some errors are visible.


A real physics system would add a lot to this. The first improvement to add would be data structures to improve performance for large worlds, e.g. octrees or similar.

What the demo needs most of all to be really nice is shadows, but shadows is not the focus of the demo. That is why there are none.


Updated 2017 for Linux Mint and for using MicroGlut for Linux.


Download:


collision-demo.tar.gz


This page is maintained by Ingemar Ragnemalm.