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
impl EstNormCache
Sourcepub fn build(
world_data: &[u8],
column_offsets: &[u32],
vsid: u32,
x0: i32,
y0: i32,
x1: i32,
y1: i32,
) -> Self
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.
Sourcepub fn build_with_reader<'r>(
column_reader: impl Fn(i32, i32) -> Option<&'r [u8]>,
x0: i32,
y0: i32,
x1: i32,
y1: i32,
) -> Self
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.
Sourcepub fn estnorm(&self, x: i32, y: i32, z: i32) -> [f32; 3]
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§
impl Freeze for EstNormCache
impl RefUnwindSafe for EstNormCache
impl Send for EstNormCache
impl Sync for EstNormCache
impl Unpin for EstNormCache
impl UnsafeUnpin for EstNormCache
impl UnwindSafe for EstNormCache
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> 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 more