pub struct VoxelsChunkRef<'a> {
pub my_id: usize,
pub parent: &'a Voxels,
pub states: &'a [VoxelState; 512],
pub key: &'a Point<i32>,
}Expand description
A reference to a voxel chunk.
Fields§
§my_id: usizeThe linear index of this chunk within the Voxels shape.
parent: &'a VoxelsThe voxel shape this chunk is part of.
states: &'a [VoxelState; 512]The fill status of each voxel from this chunk.
key: &'a Point<i32>The spatial index of this chunk.
Implementations§
Source§impl<'a> VoxelsChunkRef<'a>
impl<'a> VoxelsChunkRef<'a>
Sourcepub fn local_aabb(&self) -> Aabb
pub fn local_aabb(&self) -> Aabb
The AABB of this chunk of voxels.
Note that this return the AABB of the whole chunk, without taking into account the fact that some voxels are empty.
Sourcepub fn voxel_at_point_unchecked(&self, pt: Point<f32>) -> Point<i32>
pub fn voxel_at_point_unchecked(&self, pt: Point<f32>) -> Point<i32>
Returns the spatial index of the voxel containing the given point.
Sourcepub fn voxel_state(&self, voxel_key: Point<i32>) -> Option<VoxelState>
pub fn voxel_state(&self, voxel_key: Point<i32>) -> Option<VoxelState>
The state of the voxel with key voxel_key.
Sourcepub fn clamp_voxel(&self, voxel_key: Point<i32>) -> Point<i32>
pub fn clamp_voxel(&self, voxel_key: Point<i32>) -> Point<i32>
Clamps the voxel_key so it is within the bounds of self.
Sourcepub fn voxel_aabb_unchecked(&self, voxel_key: Point<i32>) -> Aabb
pub fn voxel_aabb_unchecked(&self, voxel_key: Point<i32>) -> Aabb
The AABB of the voxel with this key.
Returns a result even if the voxel doesn’t belong to this chunk.
Sourcepub fn flat_id(&self, voxel_key: Point<i32>) -> Option<u32>
pub fn flat_id(&self, voxel_key: Point<i32>) -> Option<u32>
Convert a voxel index (expressed relative to the main Voxels shape, not relative to the
chunk alone) into a flat index within a voxel chunk.
Returns None if the voxel isn’t part of this chunk.
Sourcepub fn voxels(&self) -> impl Iterator<Item = VoxelData> + '_
pub fn voxels(&self) -> impl Iterator<Item = VoxelData> + '_
Iterates through all the voxels in this chunk.
Note that this yields both empty and non-empty voxels within the range. This does not
include any voxel that falls outside Self::domain.
Sourcepub fn voxels_in_range(
self,
mins: Point<i32>,
maxs: Point<i32>,
) -> impl Iterator<Item = VoxelData> + use<'a>
pub fn voxels_in_range( self, mins: Point<i32>, maxs: Point<i32>, ) -> impl Iterator<Item = VoxelData> + use<'a>
Iterate through the data of all the voxels within the given (semi-open) voxel grid indices.
Note that this yields both empty and non-empty voxels within the range. This does not
include any voxel that falls outside Self::domain.
Trait Implementations§
Source§impl<'a> Clone for VoxelsChunkRef<'a>
impl<'a> Clone for VoxelsChunkRef<'a>
Source§fn clone(&self) -> VoxelsChunkRef<'a>
fn clone(&self) -> VoxelsChunkRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> RayCast for VoxelsChunkRef<'a>
impl<'a> RayCast for VoxelsChunkRef<'a>
Source§fn cast_local_ray_and_get_normal(
&self,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<RayIntersection>
fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>
Source§fn cast_local_ray(
&self,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<f32>
fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>
Source§fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool
fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool
Source§fn cast_ray(
&self,
m: &Isometry<f32>,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<f32>
fn cast_ray( &self, m: &Isometry<f32>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>
Source§fn cast_ray_and_get_normal(
&self,
m: &Isometry<f32>,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<RayIntersection>
fn cast_ray_and_get_normal( &self, m: &Isometry<f32>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>
impl<'a> Copy for VoxelsChunkRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for VoxelsChunkRef<'a>
impl<'a> RefUnwindSafe for VoxelsChunkRef<'a>
impl<'a> Send for VoxelsChunkRef<'a>
impl<'a> Sync for VoxelsChunkRef<'a>
impl<'a> Unpin for VoxelsChunkRef<'a>
impl<'a> UnwindSafe for VoxelsChunkRef<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.