SpatialHashGrid

Struct SpatialHashGrid 

Source
pub struct SpatialHashGrid<D: Sized> { /* private fields */ }
Expand description

Spatial hash data structure. see crate docs for usage.

Implementations§

Source§

impl<D: Sized> SpatialHashGrid<D>

Source

pub fn new<V>(x: usize, y: usize, z: usize, filler: V) -> Self
where V: FnMut() -> D,

x,y,z set the dimentsions, filler is a function that is used to initialize contents.

Source

pub fn size(&self) -> Vector3<usize>

Get the size/bounds of the area under spatial hash.

Source

pub fn get_mut(&mut self, idx: usize) -> Option<&mut D>

Safely retrieve element by index, will do runtime OOB checks

Source

pub fn get(&mut self, idx: usize) -> Option<&D>

Safely retrieve element by index, will do runtime OOB checks

Source

pub fn pos_to_index(&self, v: Vector3<u32>) -> Option<usize>

Convert given position into index in this spatial hash grid

Source

pub fn iter_cube_indices( &self, min: Vector3<u32>, max: Vector3<u32>, ) -> BoxIdxIterator

Iterate over cube indices in given bounds [min, max]

Source

pub fn iter_cubes( &self, min: Vector3<u32>, max: Vector3<u32>, ) -> BoxIterator<'_, D>

Iterate over cubes in given bounds [min, max] inside the main cube in read only state

Source

pub fn iter_cubes_mut( &mut self, min: Vector3<u32>, max: Vector3<u32>, ) -> BoxIteratorMut<'_, D>

Iterate over cubes in given bounds [min, max] in read and write state.

Trait Implementations§

Source§

impl<D: Debug> Debug for SpatialHashGrid<D>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<D: Sized> Index<Vector3<u32>> for SpatialHashGrid<D>

Source§

fn index(&self, index: Vector3<u32>) -> &Self::Output

Retrieve reference to element by position

Source§

type Output = D

The returned type after indexing.
Source§

impl<D: Sized> Index<usize> for SpatialHashGrid<D>

Source§

fn index(&self, index: usize) -> &Self::Output

Retrieve reference to element by index

Source§

type Output = D

The returned type after indexing.
Source§

impl<D: Sized> IndexMut<Vector3<u32>> for SpatialHashGrid<D>

Source§

fn index_mut(&mut self, index: Vector3<u32>) -> &mut Self::Output

Retrieve mutable reference to element by position

Source§

impl<D: Sized> IndexMut<usize> for SpatialHashGrid<D>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Retrieve mutable reference to element by index

Auto Trait Implementations§

§

impl<D> Freeze for SpatialHashGrid<D>

§

impl<D> RefUnwindSafe for SpatialHashGrid<D>
where D: RefUnwindSafe,

§

impl<D> Send for SpatialHashGrid<D>
where D: Send,

§

impl<D> Sync for SpatialHashGrid<D>
where D: Sync,

§

impl<D> Unpin for SpatialHashGrid<D>
where D: Unpin,

§

impl<D> UnwindSafe for SpatialHashGrid<D>
where D: 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.