Skip to main content

getcube

Function getcube 

Source
pub fn getcube(
    slab_buf: &[u8],
    column_offsets: &[u32],
    vsid: u32,
    x: i32,
    y: i32,
    z: i32,
) -> Cube
Expand description

Look up the voxel at (x, y, z) in a column-slab world.

slab_buf + column_offsets + vsid describe the world the same way the rasterizer takes them: slab_buf is the concatenated raw slab bytes, column_offsets[i]..column_offsets[i + 1] is column i = y * vsid + x’s slab range, and vsid is the square map dimension. column_offsets.len() == vsid² + 1.

Out-of-bounds (x, y) returns Cube::Air (matches voxlap C’s (uint32_t)(x|y) >= VSID early return). z is not range-checked — the caller is expected to clamp to [0, MAXZDIM) if needed.

§Panics

Panics on a malformed column whose slab walker would step past the column’s data range. Voxlap’s loader (roxlap-formats::vxl::parse) validates slab structure on parse, so any Vxl that round-trips the parser is safe to query.