pub struct GpuBroadphaseGrid {
pub cell_size: f64,
pub nx: usize,
pub ny: usize,
pub nz: usize,
pub cells: Vec<Vec<usize>>,
}Expand description
A uniform-grid broadphase accelerator.
The 3-D domain is partitioned into nx × ny × nz axis-aligned cells.
Particles are inserted by position and can be queried by neighbourhood.
Fields§
§cell_size: f64Size of one cell along each axis.
nx: usizeNumber of cells along X.
ny: usizeNumber of cells along Y.
nz: usizeNumber of cells along Z.
cells: Vec<Vec<usize>>Flattened cell storage: cells[flat_index] is the list of particle IDs.
Implementations§
Source§impl GpuBroadphaseGrid
impl GpuBroadphaseGrid
Sourcepub fn new(cell_size: f64, nx: usize, ny: usize, nz: usize) -> Self
pub fn new(cell_size: f64, nx: usize, ny: usize, nz: usize) -> Self
Create a new broadphase grid.
§Arguments
cell_size– edge length of each cubic cell.nx,ny,nz– cell counts along each axis.
Sourcepub fn insert(&mut self, particle_id: usize, pos: [f64; 3])
pub fn insert(&mut self, particle_id: usize, pos: [f64; 3])
Insert particle_id at world-space position pos.
Positions that fall outside the grid are clamped to the nearest cell.
Sourcepub fn cell_index(&self, pos: [f64; 3]) -> (usize, usize, usize)
pub fn cell_index(&self, pos: [f64; 3]) -> (usize, usize, usize)
Map a world-space position to grid-cell indices (ix, iy, iz).
Result is clamped so it always lies within [0, nx-1] × [0, ny-1] × [0, nz-1].
Sourcepub fn query_neighbors(&self, pos: [f64; 3]) -> Vec<usize>
pub fn query_neighbors(&self, pos: [f64; 3]) -> Vec<usize>
Return all particle IDs in the cell containing pos and its 26 neighbours.
Sourcepub fn cell_count(&self) -> usize
pub fn cell_count(&self) -> usize
Total number of cells in the grid.
Trait Implementations§
Source§impl Clone for GpuBroadphaseGrid
impl Clone for GpuBroadphaseGrid
Source§fn clone(&self) -> GpuBroadphaseGrid
fn clone(&self) -> GpuBroadphaseGrid
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GpuBroadphaseGrid
impl RefUnwindSafe for GpuBroadphaseGrid
impl Send for GpuBroadphaseGrid
impl Sync for GpuBroadphaseGrid
impl Unpin for GpuBroadphaseGrid
impl UnsafeUnpin for GpuBroadphaseGrid
impl UnwindSafe for GpuBroadphaseGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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