As you can see we have costs order n 2 . Let s assume we have a scenery with a road, some cars, trees and some airplanes flying around in the air. So it would be pleasant, if we would check only objects, that actually can collide. The easiest way is to define some collision groups. Objects can only collide, when they are in at least one common group.
Every car is in the group vehicles and in the group ground objects .
Every airplane is in the group airplanes and in the group air objects . Trees are in ground objects and in trees . Rocks are in Stones . So in that example an airplane can t collide with a car, cause they have no common group. Let s say, we have a ghost walking around in our scenery.