Struct Batch

Source
pub struct Batch<T: VoxelTrait> { /* private fields */ }
Expand description

Accumulates per-node voxel modifications, enabling efficient bulk updates for an octree.

§Type parameters

Implementations§

Source§

impl<T: VoxelTrait> Batch<T>

Source

pub fn new(max_depth: MaxDepth) -> Self

Creates a new Batch for a tree of the given maximum depth. Returns a new, empty Batch ready to record set, clear, or fill operations.

§Arguments
  • max_depth - Maximum depth (levels) of the target octree.
§Example
use voxelis::{Batch, MaxDepth};

let batch = Batch::<u8>::new(MaxDepth::new(4));
Source

pub fn masks(&self) -> &Vec<(u8, u8)>

Returns the internal vector of (set_mask, clear_mask) pairs per node.

Source

pub fn values(&self) -> &Vec<[T; 8]>

Returns the buffered voxel values array for each child of every node.

Source

pub fn to_fill(&self) -> Option<T>

Returns the uniform fill value if fill was invoked; otherwise None.

Source

pub fn size(&self) -> usize

Counts and returns the number of recorded set or clear operations.

Source

pub fn has_patches(&self) -> bool

Indicates whether any operations have been recorded in this batch.

Source

pub fn just_set(&mut self, position: IVec3, voxel: T) -> bool

Records a voxel set or clear operation at the specified 3D position. Returns true indicating that the state has changed.

§Arguments
  • position - 3D coordinates of the voxel to modify.
  • voxel - The voxel value to set; T::default() clears the voxel.
§Panics

Panics if position is out of bounds for the configured max_depth.

Trait Implementations§

Source§

impl<T: Debug + VoxelTrait> Debug for Batch<T>

Source§

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

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

impl<T: VoxelTrait> VoxOpsWrite<T> for Batch<T>

Source§

fn set( &mut self, _interner: &mut VoxInterner<T>, position: IVec3, voxel: T, ) -> bool

Records a set or clear operation for the given position, delegating to just_set. Records a voxel set or clear operation at the specified 3D position. Returns true indicating that the state has changed.

§Arguments
  • position - 3D coordinates of the voxel to modify.
  • voxel - The voxel value to set; T::default() clears the voxel.
§Panics

Panics if position is out of bounds for the configured max_depth.

Source§

fn fill(&mut self, interner: &mut VoxInterner<T>, value: T)

Clears existing operations and sets a uniform fill value for the batch.

Source§

fn clear(&mut self, _interner: &mut VoxInterner<T>)

Resets all recorded operations, clearing masks, values, and fill state.

Auto Trait Implementations§

§

impl<T> Freeze for Batch<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Batch<T>
where T: RefUnwindSafe,

§

impl<T> Send for Batch<T>
where T: Send,

§

impl<T> Sync for Batch<T>
where T: Sync,

§

impl<T> Unpin for Batch<T>
where T: Unpin,

§

impl<T> UnwindSafe for Batch<T>
where T: 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.