pub struct VoxelWorld {
pub seed: u64,
pub chunk_blocks: [u32; 3],
pub block_size: f32,
pub view_radius: u32,
pub impostor_radius: u32,
pub impostor_step: u32,
pub load_budget: u32,
pub palette: Vec<AssetId>,
pub material: Option<MaterialHandle>,
}Expand description
An infinite, procedurally generated voxel world.
Where a VoxelChunk is one authored chunk compiled to a fixed
mesh at build time, a VoxelWorld describes an unbounded world: chunks are
generated on demand from seed as the camera moves and streamed in and out
around it. The grid is infinite on X/Z and a single chunk tall on Y.
Declaring one opts the world into chunk streaming; with no VoxelWorld
present nothing changes.
The palette lists BlockType assets; the generator uses index
0 as air, index 1 as the surface block, and index 2 (when present) as the
subsurface block. material supplies the textures and lighting shared by
every chunk.
Fields§
§seed: u64Deterministic terrain seed. The same seed always generates the same world, so a chunk regenerates identically each time it streams back in.
chunk_blocks: [u32; 3]Blocks per chunk [dx, dy, dz]. Y is the world’s fixed vertical extent.
block_size: f32World units per block edge.
view_radius: u32Chunk radius streamed around the camera at full voxel detail.
impostor_radius: u32Outer chunk radius streamed as cheap coarse impostors. Chunks farther
than view_radius but within impostor_radius render as a low-detail
surface mesh instead of full voxel geometry. 0 (the default) or any
value <= view_radius disables impostors.
impostor_step: u32Coarse-grid step (in blocks) for distant-chunk impostors: the surface is
sampled every impostor_step blocks. Higher = cheaper and coarser.
load_budget: u32Maximum number of chunks generated and loaded per frame.
palette: Vec<AssetId>BlockType asset names. Index 0 is air; 1 is the surface block; 2, when present, is the subsurface block.
material: Option<MaterialHandle>Material shared by every chunk: textures and lighting.
Implementations§
Source§impl VoxelWorld
impl VoxelWorld
Sourcepub fn chunk_blocks(&self) -> [u32; 3]
pub fn chunk_blocks(&self) -> [u32; 3]
Blocks per chunk, each axis floored at 1 so a chunk is never degenerate.
Sourcepub fn block_size(&self) -> f32
pub fn block_size(&self) -> f32
World units per block edge, floored at a small positive value.
Sourcepub fn chunk_world_size(&self) -> (f32, f32)
pub fn chunk_world_size(&self) -> (f32, f32)
World-space (x, z) size of one chunk.
Sourcepub fn view_radius(&self) -> i32
pub fn view_radius(&self) -> i32
View radius in chunks, floored at 0 and capped so a typo cannot ask for a multi-thousand-chunk window.
Sourcepub fn impostor_radius(&self) -> i32
pub fn impostor_radius(&self) -> i32
Effective impostor (far) radius in chunks. Capped well above the
full-detail cap since impostors are cheap, and floored at view_radius
(a smaller value disables impostors, there is no far band to fill).
Sourcepub fn impostor_step(&self) -> u32
pub fn impostor_step(&self) -> u32
Coarse-grid step in blocks for distant impostors, floored at 1 and capped so a typo cannot collapse the whole surface to a single quad on a huge chunk (still valid, just degenerate).
Sourcepub fn impostors_enabled(&self) -> bool
pub fn impostors_enabled(&self) -> bool
Whether the distant-impostor far band is active: an impostor radius strictly beyond the full-detail radius.
Sourcepub fn load_budget(&self) -> usize
pub fn load_budget(&self) -> usize
Per-frame chunk load budget as a usize, floored at 1 so a stray 0
cannot wedge streaming permanently.
Trait Implementations§
Source§impl Clone for VoxelWorld
impl Clone for VoxelWorld
Source§fn clone(&self) -> VoxelWorld
fn clone(&self) -> VoxelWorld
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for VoxelWorld
impl Component for VoxelWorld
Source§const NAME: &'static str = "VoxelWorld"
const NAME: &'static str = "VoxelWorld"
Source§fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Source§impl ComponentSlot for VoxelWorld
impl ComponentSlot for VoxelWorld
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.