Struct BroadphaseBvh
pub struct BroadphaseBvh<const MAX_LEAVES: usize = 256> {
pub leaves: [BvhLeafEntry; MAX_LEAVES],
pub cluster_aabbs: [Aabb3D; MAX_LEAVES],
pub active_count: usize,
pub fat_margin: f32,
pub refit_count: u64,
}Expand description
Zero-heap dynamic broadphase BVH with fat-AABB hysteresis.
Maintains up to MAX_LEAVES colliders alongside an upper-level spatial cluster partition
so queries skip non-overlapping regions without heap allocation.
Fields§
§leaves: [BvhLeafEntry; MAX_LEAVES]§cluster_aabbs: [Aabb3D; MAX_LEAVES]Cluster bounding boxes (groups of 8 leaves per cluster node).
active_count: usize§fat_margin: f32Hysteresis expansion margin (meters) added when updating fat_aabb.
refit_count: u64Total number of fat-AABB hysteresis refits performed.
Implementations§
§impl<const MAX_LEAVES: usize> BroadphaseBvh<MAX_LEAVES>
impl<const MAX_LEAVES: usize> BroadphaseBvh<MAX_LEAVES>
pub fn new(fat_margin: f32) -> BroadphaseBvh<MAX_LEAVES>
pub fn new(fat_margin: f32) -> BroadphaseBvh<MAX_LEAVES>
Creates an empty BroadphaseBvh with the specified fat_margin (meters).
pub fn insert(&mut self, collider_id: u32, tight_aabb: Aabb3D) -> Option<usize>
pub fn insert(&mut self, collider_id: u32, tight_aabb: Aabb3D) -> Option<usize>
Inserts a collider with its initial tight_aabb, returning the assigned leaf slot index.
pub fn update(&mut self, leaf_slot: usize, new_tight_aabb: Aabb3D) -> bool
pub fn update(&mut self, leaf_slot: usize, new_tight_aabb: Aabb3D) -> bool
Updates a collider’s tight_aabb with fat-AABB margin hysteresis.
Returns true if the tight_aabb exited the cached fat_aabb and triggered a cluster refit,
or false if absorbed by hysteresis without refitting.
pub fn overlap_aabb(
&self,
query_aabb: &Aabb3D,
out_collider_ids: &mut [u32],
) -> usize
pub fn overlap_aabb( &self, query_aabb: &Aabb3D, out_collider_ids: &mut [u32], ) -> usize
Writes all collider IDs whose tight_aabb overlaps query_aabb into out_collider_ids.
Returns the number of collider IDs written.
pub fn collect_overlapping_pairs(&self, out_pairs: &mut [(u32, u32)]) -> usize
pub fn collect_overlapping_pairs(&self, out_pairs: &mut [(u32, u32)]) -> usize
Generates all broadphase collision pairs (collider_a, collider_b) whose tight AABBs overlap.
Trait Implementations§
§impl<const MAX_LEAVES: usize> Clone for BroadphaseBvh<MAX_LEAVES>
impl<const MAX_LEAVES: usize> Clone for BroadphaseBvh<MAX_LEAVES>
§fn clone(&self) -> BroadphaseBvh<MAX_LEAVES>
fn clone(&self) -> BroadphaseBvh<MAX_LEAVES>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more