pub struct Collider { /* private fields */ }Expand description
Face BVH matching the C++ Collider’s storage layout exactly: one interleaved
node array (leaves at even indices, internals at odd), the radix-tree
topology, and parent links for bottom-up box refits. Leaf boxes live inside
node_bbox — no separate leaf copy, and the morton codes are consumed at
construction rather than stored, which matters because a collider is cached
on every ManifoldImpl.
Implementations§
Source§impl Collider
impl Collider
Sourcepub fn new(leaf_bbox: Vec<BBox>, leaf_morton: Vec<u32>) -> Self
pub fn new(leaf_bbox: Vec<BBox>, leaf_morton: Vec<u32>) -> Self
Create a new Collider from leaf bounding boxes and morton codes. Like the C++ constructor, leaves must already be sorted by morton code — every production caller builds them from a morton-sorted source (sort_geometry sorts faces, merge sorts open verts).
Sourcepub fn collisions_one<R: FnMut(usize, usize)>(
&self,
query: &BBox,
query_idx: usize,
record: R,
)
pub fn collisions_one<R: FnMut(usize, usize)>( &self, query: &BBox, query_idx: usize, record: R, )
Run a single query box against the BVH, invoking record(query_idx, leaf_idx) per overlap. Same traversal as collisions_fn for one
index — the per-query entry point for parallel callers (&self only,
so queries can run concurrently with thread-local recording).
Sourcepub fn collisions_fn<F, R>(&self, query_box_fn: F, n: usize, record: R)
pub fn collisions_fn<F, R>(&self, query_box_fn: F, n: usize, record: R)
BVH-accelerated collision query with function-generated query boxes. For each query index 0..n, calls query_box_fn(i) to get the query AABB, then traverses the BVH to find overlapping leaves.
Sourcepub fn collisions_with_boxes<F: FnMut(usize, usize)>(
&self,
queries: &[BBox],
self_collision: bool,
record: F,
)
pub fn collisions_with_boxes<F: FnMut(usize, usize)>( &self, queries: &[BBox], self_collision: bool, record: F, )
BVH-accelerated collision query with pre-computed query boxes.
Sourcepub fn collisions_point<F, R>(&self, point_fn: F, n: usize, record: R)
pub fn collisions_point<F, R>(&self, point_fn: F, n: usize, record: R)
Point-based collision query using BVH.
Sourcepub fn update_boxes(&mut self, leaf_bbox: Vec<BBox>)
pub fn update_boxes(&mut self, leaf_bbox: Vec<BBox>)
Replace the leaf boxes (given in leaf/tree order — for a face collider that is face order, since faces are morton-sorted) and refit the internal boxes. Tree topology is untouched (C++ UpdateBoxes).
Sourcepub fn transform(&mut self, transform: &Mat3x4)
pub fn transform(&mut self, transform: &Mat3x4)
Map every node box through an axis-aligned transform (C++ Collider::Transform) — no refit needed since axis-aligned transforms map AABBs to exact AABBs.