Skip to main content

Crate roxlap_cavegen

Crate roxlap_cavegen 

Source
Expand description

Procedural cave generation for the roxlap voxel engine.

Builds voxlap-format Vxl worlds from a Worley-noise + Perlin- overlay classification scheme. The crate ships two presets (BlueCaveGenerator, MagCaveGenerator) tuned to match Ken Silverman + Tom Dobrowolski’s 2003 “Justfly” reference screenshots (caveblue2m.jpg, cavemag3m.jpg).

§Pipeline

  1. Generator::generate consumes CaveParams (seed + shape knobs) and produces a Vxl.
  2. Internally, generators sample a dense (VSID × VSID × MAXZDIM) voxel mask + colour grid via Worley distance classification + Perlin overlay.
  3. pack_dense_grid_to_vxl folds the dense grid into voxlap’s slab-RLE column format — much faster than feeding voxels through the set_spans edit pipeline for whole-world creation.

Structs§

BlueCaveGenerator
Blue-cave preset matching Ken’s caveblue2m.jpg.
CaveParams
Parameters for the procedural cave generators.
MagCaveGenerator
Magenta-cave preset matching Ken’s cavemag3m.jpg.
PerlinNoise3D
3D Perlin noise sampler with a deterministic permutation table.
Seed
One Worley seed point.
Vxl
Parsed .vxl map. Round-trips byte-equally via parse + serialize.

Constants§

MAXZDIM
Voxlap’s MAXZDIM (voxlap5.h:10) — world height, one byte per z value → 256 voxels.

Traits§

Generator
Procedural world generator. Implementors produce a Vxl from CaveParams (or their own typed parameter struct).

Functions§

classify_voxel
Classify a single voxel as solid (true) or air (false) against the seed set. The voxel position (x, y, z) is in integer voxel coordinates.
classify_voxel_with_perlin
Like classify_voxel but adds a Perlin-noise overlay to the distance-to-air-seed term. Voxel is air iff d_air + overlay < d_solid, where overlay = perlin_amplitude × fbm(x, y, z, octaves) × PERLIN_VOXEL_SCALE.
pack_dense_grid_to_vxl
Build a Vxl from a dense voxel-mask + colour grid.
place_seeds
Place params.seed_count deterministic random seeds across the vsid × vsid × MAXZDIM volume. The first params.air_ratio × params.seed_count (rounded) are tagged air; the rest solid.
worley_classify_grid
Build the dense (VSID × VSID × MAXZDIM) solidness grid by classifying every voxel against the seed set. Output: 1 byte per voxel; non-zero = solid.