Wednesday, July 01, 2009

Spacial Partitioning - Quad Trees

An important element needed for various things in the engine are Quad Trees.
Here is an example of a Rectangle checking collisions against random pixels on a bitmap data.

Quad tree

As you see with a quad tree it can easily handle 100'000 objects and do collision detection. If it wasn't for the long loading time it could even be a million or more.

The quad tree in the example isn't fully optimized and visualisation slows down performance of course.

Here is another example testing rectangles vs. a rectangle:

Quad tree 2


Post a Comment

<< Home