VoxelConfig
Compile-time limits and default dimensions of the voxel world and its .vwr file format.
Location
| Header | include/GalaxyEggbert/Worlds/VoxelConfig.hpp (header-only) |
|---|---|
| Namespace | GalaxyEggbert::Worlds |
| Kind | struct VoxelConfig final with static constexpr members only |
Purpose
One place for the numbers that Block, Chunk,
the bit-packing helpers and World must agree on. Nothing outside
src/GalaxyEggbert/Worlds/ and the headers next to it reads these constants directly;
the rest of the game asks a World for blocksPerAxis().
Constants
Values verified in VoxelConfig.hpp as of 2026-11-10.
| Constant | Type | Value | Meaning |
|---|---|---|---|
FormatVersion | uint8_t | 2 | The version byte of the VWR1 world header. World::loadFromFile() accepts exactly this value. Raised from 1 on 2026-07-09 when the sky region and the four world-level fields were added; version 1 files no longer load. Independent of the chunk payload's own version (also 2). |
ChunkSize | uint8_t | 10 | Blocks along one chunk axis. Stored in both headers and checked on load. |
ChunkVolume | size_t | 1000 | ChunkSize³, the block count of a chunk. |
WorldChunksPerAxis | uint8_t | 10 | The default World constructor argument. |
WorldBlocksPerAxis | uint16_t | 100 | ChunkSize × WorldChunksPerAxis. |
MaxBlockType | uint16_t | 4095 | Largest 12-bit block type. The game uses 0-440 (BlockDefinitionRegistry::MaxObjectMIcon). |
MaxBlockMetadata | uint8_t | 15 | Largest 4-bit metadata value. |
MaxPaletteEntries | uint16_t | 256 | Distinct block values per chunk; palette indices need at most 8 bits. |
Only cubic worlds. The header stores one
chunksPerAxis. A non-cubic header with separate X/Y/Z chunk counts is described in
World Format.md as a possible future version; it is not implemented.Usage
// src/GalaxyEggbert/Worlds/World.cpp
std::uint16_t World::blocksPerAxis() const noexcept {
return static_cast<std::uint16_t>(chunksPerAxis_) * VoxelConfig::ChunkSize;
}
...
if (version != VoxelConfig::FormatVersion) {
throw std::runtime_error("Unsupported world format version");
}
Tests
WorldTests.ConstructorAndWorldDimensionsAreConsistent,WorldSerializationTests.LoadRejectsV1FormatVersionandBlockTests.MakeSupportsMaximumValuesdepend on these values;BitPackingTests.BitsNeededForPaletteBoundarieschecks the 256-entry limit.