pub trait ChunkGenerator:
Debug
+ Send
+ Sync {
// Required method
fn generate(&self, chunk_idx: IVec3) -> Vxl;
// Provided method
fn should_generate(&self, _chunk_idx: IVec3) -> bool { ... }
}Expand description
Pluggable per-chunk procedural generator.
Grid instances optionally carry a Box<dyn ChunkGenerator>.
When the streaming layer (or a direct
Grid::ensure_chunk_generated
call) needs a chunk that is not yet materialised, it asks the
generator to produce one. The returned Vxl is moved into the
grid’s sparse chunk map at the requested index.
Generators are expected to be deterministic functions of
chunk_idx plus their own configuration: calling generate with
the same index twice should return equivalent chunks. This is
what makes “evict + re-stream” sound under crate::Grid’s
no-persistence default (see S7 scope brief, decision 5).
Send + Sync is required so S7.3 can dispatch generation onto a
background rayon pool without per-call locking. Debug is
required so crate::Grid can derive Debug while holding a
Box<dyn ChunkGenerator>.
Required Methods§
Provided Methods§
Sourcefn should_generate(&self, _chunk_idx: IVec3) -> bool
fn should_generate(&self, _chunk_idx: IVec3) -> bool
Per-chunk filter consulted by crate::Scene::pump_streaming
(+ the synchronous crate::Grid::ensure_chunk_generated
helper) before dispatching generate. Returning false
skips the chunk entirely — it never enters the grid’s chunk
map and origin_chunk_z (etc.) reflect only the indices the
generator actually materialises.
Used to avoid creating placeholder bedrock-only chunks for
layers the generator has no real content for (e.g. the
streaming-hills demo’s HillsChunkGenerator declines
chunk_idx.z != 0 so the camera can fly above the world
without triggering the S4B.6.j cross-chunk look-down
limitation).
Default returns true — pre-fix behaviour, every dispatched
chunk gets generated.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".