pub struct GpuSdfGrid {
pub data: Vec<f64>,
pub nx: usize,
pub ny: usize,
pub nz: usize,
pub origin: [f64; 3],
pub cell_size: f64,
}Expand description
A 3-D SDF grid filled analytically via generate_sdf_grid.
Separate from the existing SdfGrid to keep naming unambiguous.
Fields§
§data: Vec<f64>Flat storage: index = ix * ny * nz + iy * nz + iz.
nx: usizeNumber of cells in x.
ny: usizeNumber of cells in y.
nz: usizeNumber of cells in z.
origin: [f64; 3]World-space origin of the (0,0,0) corner.
cell_size: f64Uniform cell spacing.
Implementations§
Source§impl GpuSdfGrid
impl GpuSdfGrid
Sourcepub fn new(
nx: usize,
ny: usize,
nz: usize,
origin: [f64; 3],
cell_size: f64,
) -> Self
pub fn new( nx: usize, ny: usize, nz: usize, origin: [f64; 3], cell_size: f64, ) -> Self
Create a new grid filled with zeros.
Sourcepub fn index(&self, ix: usize, iy: usize, iz: usize) -> usize
pub fn index(&self, ix: usize, iy: usize, iz: usize) -> usize
Flat index for cell (ix, iy, iz).
Sourcepub fn cell_center(&self, ix: usize, iy: usize, iz: usize) -> [f64; 3]
pub fn cell_center(&self, ix: usize, iy: usize, iz: usize) -> [f64; 3]
World-space centre of cell (ix, iy, iz).
Sourcepub fn sample_trilinear(&self, p: [f64; 3]) -> f64
pub fn sample_trilinear(&self, p: [f64; 3]) -> f64
Trilinear interpolation of the SDF at world-space point p.
Points outside the grid are clamped to the nearest grid value.
Trait Implementations§
Source§impl Clone for GpuSdfGrid
impl Clone for GpuSdfGrid
Source§fn clone(&self) -> GpuSdfGrid
fn clone(&self) -> GpuSdfGrid
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 GpuSdfGrid
impl RefUnwindSafe for GpuSdfGrid
impl Send for GpuSdfGrid
impl Sync for GpuSdfGrid
impl Unpin for GpuSdfGrid
impl UnsafeUnpin for GpuSdfGrid
impl UnwindSafe for GpuSdfGrid
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