pub struct OccupancyGrid {
pub data: Vec<bool>,
pub resolution: usize,
pub scene_bound: f32,
}Expand description
3D occupancy grid for fast ray marching.
The scene is assumed to span [-scene_bound, scene_bound]^3.
The grid has resolution^3 voxels.
Fields§
§data: Vec<bool>Flat bool occupancy: [resolution * resolution * resolution].
resolution: usizeGrid resolution per axis.
scene_bound: f32Scene half-extent: scene spans [-bound, bound]^3.
Implementations§
Source§impl OccupancyGrid
impl OccupancyGrid
Sourcepub fn new(resolution: usize, scene_bound: f32) -> NerfResult<Self>
pub fn new(resolution: usize, scene_bound: f32) -> NerfResult<Self>
Sourcepub fn set(
&mut self,
ix: usize,
iy: usize,
iz: usize,
occupied: bool,
) -> NerfResult<()>
pub fn set( &mut self, ix: usize, iy: usize, iz: usize, occupied: bool, ) -> NerfResult<()>
Mark a voxel as occupied/empty.
§Errors
Returns HashLevelOutOfRange if any index exceeds the resolution.
Sourcepub fn get(&self, ix: usize, iy: usize, iz: usize) -> NerfResult<bool>
pub fn get(&self, ix: usize, iy: usize, iz: usize) -> NerfResult<bool>
Query occupancy of a voxel.
§Errors
Returns HashLevelOutOfRange if any index exceeds the resolution.
Sourcepub fn is_occupied_world(&self, xyz: [f32; 3]) -> bool
pub fn is_occupied_world(&self, xyz: [f32; 3]) -> bool
Query if a world-space point lies in an occupied voxel.
Points outside [-scene_bound, scene_bound]^3 are considered empty.
Sourcepub fn update_from_density(
&mut self,
density: &[f32],
threshold: f32,
) -> NerfResult<()>
pub fn update_from_density( &mut self, density: &[f32], threshold: f32, ) -> NerfResult<()>
Update occupancy from density values using a threshold.
density must have exactly resolution^3 elements.
§Errors
Returns DimensionMismatch if sizes don’t match.
Trait Implementations§
Source§impl Clone for OccupancyGrid
impl Clone for OccupancyGrid
Source§fn clone(&self) -> OccupancyGrid
fn clone(&self) -> OccupancyGrid
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 OccupancyGrid
impl RefUnwindSafe for OccupancyGrid
impl Send for OccupancyGrid
impl Sync for OccupancyGrid
impl Unpin for OccupancyGrid
impl UnsafeUnpin for OccupancyGrid
impl UnwindSafe for OccupancyGrid
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