Skip to main content

SpatialHashGrid3D

Struct SpatialHashGrid3D 

Source
pub struct SpatialHashGrid3D { /* private fields */ }
Expand description

O(1) uniform-cell 3D spatial hash grid with reusable scratch buffers and zero steady-state allocations.

Implementations§

Source§

impl SpatialHashGrid3D

Zero-allocation open-addressed uniform-cell 3D spatial hash grid operations.

Source

pub fn new(cell_size: f32) -> Self

Creates an empty SpatialHashGrid3D with uniform cell_size.

§Arguments
  • f32 - Cell edge length (clamped to >= 1e-4).
§Returns
  • Self - Pre-allocated 3D spatial hash grid.
Source

pub fn clear(&mut self)

Clears all entries in O(active_cells) time while retaining every internal buffer’s capacity.

Source

pub fn insert_aabb(&mut self, id: u64, bounds: AxisAlignedBox3D)

Inserts an item (id, bounds) into every 3D cell overlapped by bounds.

§Arguments
  • u64 - Entity identifier.
  • AxisAlignedBox3D - World-space 3D bounding box.
Source

pub fn insert_point(&mut self, id: u64, position: Vec3)

Inserts a 3D point (id, position) into its enclosing grid cell.

§Arguments
  • u64 - Entity identifier.
  • Vec3 - World-space 3D position.
Source

pub fn query_aabb_into(&self, query_box: AxisAlignedBox3D, out: &mut Vec<u64>)

Queries all items overlapping query_box, writing deduplicated IDs into out.

§Arguments
  • AxisAlignedBox3D - Query 3D bounding box.
  • &mut Vec<u64> - Reusable output buffer.
Source

pub fn query_sphere_into(&self, center: Vec3, radius: f32, out: &mut Vec<u64>)

Queries all items intersecting sphere (center, radius), writing deduplicated IDs into out.

§Arguments
  • Vec3 - Query sphere center.
  • f32 - Query sphere radius.
  • &mut Vec<u64> - Reusable output buffer.
Source

pub fn query_sphere(&mut self, center: Vec3, radius: f32) -> &[u64]

Queries items intersecting (center, radius) into the grid’s internal reusable scratch slice.

§Arguments
  • Vec3 - Query sphere center.
  • f32 - Query sphere radius.
§Returns
  • &[u64] - Deduplicated matching IDs stored in the internal scratch buffer.
Source§

impl SpatialHashGrid3D

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_cell_size(&self) -> f32

Source

pub fn get_mut_cell_size(&mut self) -> &mut f32

Source

pub fn set_cell_size(&mut self, val: f32) -> &mut Self

Source

pub fn get_inv_cell_size(&self) -> f32

Source

pub fn get_mut_inv_cell_size(&mut self) -> &mut f32

Source

pub fn set_inv_cell_size(&mut self, val: f32) -> &mut Self

Source

pub fn get_occupied_buckets(&self) -> usize

Source

pub fn get_mut_occupied_buckets(&mut self) -> &mut usize

Source

pub fn set_occupied_buckets(&mut self, val: usize) -> &mut Self

Trait Implementations§

Source§

impl Clone for SpatialHashGrid3D

Source§

fn clone(&self) -> Self

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
Source§

impl Debug for SpatialHashGrid3D

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for SpatialHashGrid3D

§

impl Freeze for SpatialHashGrid3D
where *const u8 is !null: Freeze, PhantomData<SpatialHashBucket3D>: Freeze, PhantomData<usize>: Freeze, PhantomData<SpatialHashEntry3D>: Freeze, PhantomData<u64>: Freeze,

§

impl Move for SpatialHashGrid3D

§

impl RefUnwindSafe for SpatialHashGrid3D

§

impl Send for SpatialHashGrid3D
where RawVecInner: Send,

§

impl Sync for SpatialHashGrid3D
where RawVecInner: Sync,

§

impl Unpin for SpatialHashGrid3D
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for SpatialHashGrid3D
where *const u8 is !null: UnsafeUnpin, PhantomData<SpatialHashBucket3D>: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, PhantomData<SpatialHashEntry3D>: UnsafeUnpin, PhantomData<u64>: UnsafeUnpin,

§

impl UnwindSafe for SpatialHashGrid3D
where RawVecInner: UnwindSafe,

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
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
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.

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.