Skip to main content

EstNormCache

Struct EstNormCache 

Source
pub struct EstNormCache { /* private fields */ }
Expand description

Pre-built expandbit256 grid covering a 2D bounding region — (x1 - x0 + 2*RAD) × (y1 - y0 + 2*RAD) columns. Trades 32 bytes per column of memory for O(1) bit-window lookups during the estnorm 5×5 neighbourhood vote.

This is the conceptual equivalent of voxlap’s xbsbuf cache — just batch-pre-built rather than rotated row-by-row through the bake. Memory cost stays manageable: a 448×448 bake (the diag_down_lit oracle scope, which extends to 452×452 with padding) needs about 6.4 MB.

Implementations§

Source§

impl EstNormCache

Source

pub fn build( world_data: &[u8], column_offsets: &[u32], vsid: u32, x0: i32, y0: i32, x1: i32, y1: i32, ) -> Self

Build the bit-grid cache covering the bounding region [x0..x1) × [y0..y1) extended by ESTNORMRAD padding on each side. Calling Self::estnorm for any (x, y) inside the original [x0..x1) × [y0..y1) box is then a pure read.

Wraps Self::build_with_reader with a flat-table closure.

Source

pub fn build_with_reader<'r>( column_reader: impl Fn(i32, i32) -> Option<&'r [u8]>, x0: i32, y0: i32, x1: i32, y1: i32, ) -> Self

S4B.4.b: chunk-aware cache build. The closure column_reader(x, y) returns the slab bytes of the column at world-or-grid-local position (x, y), or None for an implicit-air / out-of-grid column (matching build’s OOB “treat as full air” semantics).

No vsid bound — the reader owns OOB handling. Per-chunk bakes use a closure that resolves (x, y) to a neighbour chunk via Grid::chunk(IVec3) so the 2-voxel padding extends seamlessly across chunk boundaries.

The cache’s Self::vsid field is left at 0 for chunk- aware builds — the field is dead-code anyway, preserved only for voxlap-parity inspection.

Source

pub fn estnorm(&self, x: i32, y: i32, z: i32) -> [f32; 3]

Estimate the surface normal at (x, y, z) from a 5×5×5 voxel-solid neighbourhood vote. Mirror of voxlap5.c:1501 (estnorm, ESTNORMRAD == 2 branch).

(x, y) must lie inside the cache’s [x0..x1) × [y0..y1) region (panics otherwise — caller guarantees this via the bounding-box iteration). z is unconstrained (handled via air/solid clamping).

Auto Trait Implementations§

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, 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.