Rust voxel sandbox (wgpu + wasm + axum multiplayer)
Chunks are now isotropic 16×16×16 cubes stacked in all three axes,
keyed by IVec3(cx, cy, cz). The world has no Y ceiling and no Y
floor — set_block lazily creates a chunk if one doesn't exist, so
building 1000 blocks straight up just creates 60-ish empty chunks
above the surface on demand.
world.rs:
- CHUNK_HEIGHT removed. Single CHUNK_SIZE (=16) for all three axes.
- Chunk allocates 16³ = 4096 blocks.
- Chunk::get/set bound-check 0..CHUNK_SIZE on every axis.
- block_to_chunk returns full 3D (cx, cy, cz) + (lx, ly, lz).
- get_block has no Y bound — outside any chunk = Air (sky).
- set_block: chunks.entry(c).or_insert_with(...) creates on demand.
- HeightMap is keyed by IVec2(cx, cz) column. from_world_column scans
every existing cubic chunk in that column top-down for the topmost
solid block. Heightmap invalidation in set_block drops the column,
not just the single chunk.
- column_top_y, World::heightmap signature both take (cx, cz) directly.
- World::new pre-generates chunks at cy in -1..=2 (4 vertical levels
of pre-gen, ~1.1k chunks total, ~4.6 MB) covering the natural
surface band. Above/below grows lazily.
- generate_chunk takes the full 3D chunk coord; computes oy, fills
blocks for this slice of the column. Trees that straddle a chunk
boundary deterministically fill in their portion (each chunk uses
the same hash, writes only its slice).
- natural_surface_y returns the topmost-solid Y (preserved old
semantic so all collision / spawn tests still hold).
- 2 new tests pin the lazy-chunk-creation invariant (above and
below pre-gen ranges).
mesh.rs:
- dims is [CHUNK_SIZE; 3]; iteration loops are cubic.
- base_y added so neighbor lookups + corner positions account for
the chunk's vertical offset.
- warm_heightmaps_around takes (cx, cz) column coords now.
sim/spawn.rs:
- find_safe_spawn no longer caps at CHUNK_HEIGHT-2. Safety bound
is surface_y + 200 (pathological tower depth before giving up).
sim/lighting.rs:
- SUN_RAY_TOP_Y bumped from 128 to 4096 (was matching the old
fixed world height). Ray DDA still terminates at the cap.
sim/visibility.rs:
- Chunk AABB is CHUNK_SIZE on all three axes; the chunk's cy now
contributes to the AABB min Y (was hardcoded 0).
render/mod.rs:
- Heightmap warming + comment updates for column-keyed semantics.
Tests: 65/65 pass (was 63, +2 new). Native + wasm release clean.
Smoke-tested live: 88 fps, alive, spawn at y=8. All four UI
scenarios pass.
This is the foundation for the LOD pyramid you directed earlier —
isotropic chunks downsample cleanly (a LOD-N chunk represents a
(2^N)³ region with 16³ entries), and unbounded Y lets the LOD
tree extend in any direction without special cases.
|
||
|---|---|---|
| server | ||
| src | ||
| test | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| ARCHITECTURE.md | ||
| build-web.sh | ||
| Caddyfile | ||
| Cargo.lock | ||
| Cargo.toml | ||
| DEPLOY.md | ||
| docker-compose.prod.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| run.sh | ||