Broccoli
Broccoli is a broad-phase collision detection library.
The base data structure is a hybrid between a KD Tree and Sweep and Prune.
Checkout it out on github and on crates.io. Documentation at docs.rs.
Screenshot
Screen capture from the inner demo project.
Optimisation
I've focused mainly on making finding colliding pairs as fast as possible primarily in distributions where there are a lot of overlapping aabbs.
Quick rundown of what i've spent effort on and a rough estimate of performance cost of each algorithm in general.
| Algorithm | Cost | Effort spent |
|---|---|---|
| Construction | 7 | 10 |
| Colliding Pairs | 8 | 10 |
| Collide With | 3 | 2 |
| knearest | 1 | 2 |
| raycast | 1 | 2 |
| rect | 1 | 2 |
| nbody | 10 | 1 |
Numbers are out of 10 and are just rough made up numbers. For more in-depth analysis, see the broccoli book.
Example
use rect;
Name
If you shorten "broad-phase collision" to "broad colli" and say it fast, it sounds like broccoli. Broccoli are also basically small trees and broccoli uses a tree data structure.