Skip to main content

BroadphaseBvh

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: f32

Hysteresis expansion margin (meters) added when updating fat_aabb.

§refit_count: u64

Total number of fat-AABB hysteresis refits performed.

Implementations§

§

impl<const MAX_LEAVES: usize> 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>

Inserts a collider with its initial tight_aabb, returning the assigned leaf slot index.

pub fn remove(&mut self, leaf_slot: usize) -> bool

Removes a leaf slot from the BVH.

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

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

Generates all broadphase collision pairs (collider_a, collider_b) whose tight AABBs overlap.

pub fn query_ray_candidates( &self, origin: [f32; 3], dir: [f32; 3], max_toi: f32, out_collider_ids: &mut [u32], ) -> usize

Collects candidate collider IDs whose fat AABB is intersected by the ray (origin, dir, max_toi).

Trait Implementations§

§

impl<const MAX_LEAVES: usize> Clone for BroadphaseBvh<MAX_LEAVES>

§

fn clone(&self) -> BroadphaseBvh<MAX_LEAVES>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<const MAX_LEAVES: usize> Debug for BroadphaseBvh<MAX_LEAVES>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<const MAX_LEAVES: usize> Default for BroadphaseBvh<MAX_LEAVES>

§

fn default() -> BroadphaseBvh<MAX_LEAVES>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const MAX_LEAVES: usize> Freeze for BroadphaseBvh<MAX_LEAVES>

§

impl<const MAX_LEAVES: usize> RefUnwindSafe for BroadphaseBvh<MAX_LEAVES>

§

impl<const MAX_LEAVES: usize> Send for BroadphaseBvh<MAX_LEAVES>

§

impl<const MAX_LEAVES: usize> Sync for BroadphaseBvh<MAX_LEAVES>

§

impl<const MAX_LEAVES: usize> Unpin for BroadphaseBvh<MAX_LEAVES>

§

impl<const MAX_LEAVES: usize> UnsafeUnpin for BroadphaseBvh<MAX_LEAVES>

§

impl<const MAX_LEAVES: usize> UnwindSafe for BroadphaseBvh<MAX_LEAVES>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,