VoxelConfig

Compile-time limits and default dimensions of the voxel world and its .vwr file format.

Location

Headerinclude/GalaxyEggbert/Worlds/VoxelConfig.hpp (header-only)
NamespaceGalaxyEggbert::Worlds
Kindstruct 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.

ConstantTypeValueMeaning
FormatVersionuint8_t2The 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).
ChunkSizeuint8_t10Blocks along one chunk axis. Stored in both headers and checked on load.
ChunkVolumesize_t1000ChunkSize³, the block count of a chunk.
WorldChunksPerAxisuint8_t10The default World constructor argument.
WorldBlocksPerAxisuint16_t100ChunkSize × WorldChunksPerAxis.
MaxBlockTypeuint16_t4095Largest 12-bit block type. The game uses 0-440 (BlockDefinitionRegistry::MaxObjectMIcon).
MaxBlockMetadatauint8_t15Largest 4-bit metadata value.
MaxPaletteEntriesuint16_t256Distinct 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

Related pages