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<VoxelWorld, CnResult>
fn from_baked(bytes: &[u8]) -> Result<VoxelWorld, 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.Source§fn slot(s: &ComponentStorage) -> &Column<VoxelWorld>
fn slot(s: &ComponentStorage) -> &Column<VoxelWorld>
Source§fn slot_mut(s: &mut ComponentStorage) -> &mut Column<VoxelWorld>
fn slot_mut(s: &mut ComponentStorage) -> &mut Column<VoxelWorld>
Source§impl Debug for VoxelWorld
impl Debug for VoxelWorld
Source§impl Default for VoxelWorld
impl Default for VoxelWorld
Source§fn default() -> VoxelWorld
fn default() -> VoxelWorld
Source§impl<'de> Deserialize<'de> for VoxelWorldwhere
VoxelWorld: Default,
impl<'de> Deserialize<'de> for VoxelWorldwhere
VoxelWorld: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<VoxelWorld, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<VoxelWorld, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<VoxelWorld> for ComponentAsset
impl From<VoxelWorld> for ComponentAsset
Source§fn from(c: VoxelWorld) -> ComponentAsset
fn from(c: VoxelWorld) -> ComponentAsset
impl RuntimeComponent for VoxelWorld
Source§impl Serialize for VoxelWorld
impl Serialize for VoxelWorld
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for VoxelWorld
impl RefUnwindSafe for VoxelWorld
impl Send for VoxelWorld
impl Sync for VoxelWorld
impl Unpin for VoxelWorld
impl UnsafeUnpin for VoxelWorld
impl UnwindSafe for VoxelWorld
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().