Expand description
§Overview
broadphase-rs is a broadphase collision detection library. It transforms object bounds into a lightweight spatial index representation. These indices are integer values which are sorted directly to yield a result which is a topologically-sorted Morton order, after which full-system collision detection can be accomplished by a single pass over the sorted list with only a minimal auxiliary stack necessary to maintain state. Collision tests between indices are accomplished with simple bitwise shifts, masks, and XORs.
This method is capable of supporting objects of varying scale (unlike uniform grids), while having a straightforward, non-hierarchical structure in memory (unlike quad- or oct-trees), as the entire representation exists in a single vector of index/object pairs.
§Usage
Layer is the “main” struct of broadphase — this is where the sorted list of
spatial indices is stored.
The usual sequence of operations on a Layer is as follows:
extern crate zvxryb_broadphase as broadphase;
use broadphase::{Bounds, Layer, LayerBuilder, Index64_3D};
type ID = u64;
let mut layer: Layer<Index64_3D, ID> = LayerBuilder::new().build();
// clears existing object index-ID pairs:
layer.clear();
// appends an iterator of object bounds-ID pairs to the layer:
layer.extend(system_bounds, objects);
// scans the layer for collisions:
let potential_collisions = layer.scan();Structs§
- Bounds
- An axis-aligned bounding box
- Index32_
2D - Index64_
2D - Index64_
3D - Layer
- A group of collision data
- Layer
Builder - A builder for
Layers - RayTest
Geometry - A type implementing
TestGeometryfor rays
Traits§
- Spatial
Index - An index representing an object’s position and scale
- System
Bounds - System bounds supporting conversions between local and global coordinates
- Test
Geometry - A trait for implementing individual geometry tests