Overview
Broccoli is a broadphase 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.
Inner projects
The broccoli_demo
inner project is meant to show case the use of these algorithms.
The report inner project generates benches used in the broccoli book.
Screenshot
Screen capture from the inner broccoli_demo
project.
Example
use broccoli::{bbox, prelude::*, rect};
fn main() {
let mut inner1 = 0;
let mut inner2 = 0;
let mut inner3 = 0;
let mut aabbs = [
bbox(rect(0isize, 10, 0, 10), &mut inner1),
bbox(rect(15, 20, 15, 20), &mut inner2),
bbox(rect(5, 15, 5, 15), &mut inner3),
];
let mut tree = broccoli::new(&mut aabbs);
tree.find_colliding_pairs_mut(|a, b| {
**a.unpack_inner() += 1;
**b.unpack_inner() += 1;
});
assert_eq!(inner1, 1);
assert_eq!(inner2, 0);
assert_eq!(inner3, 1);
}