World Structure
The world is organized hierarchically defined insource/world.h:32-65:
Coordinate Systems
fCavEX uses multiple coordinate spaces:World Coordinates
Signed 32-bit coordinates spanning the entire world:Chunk Coordinates
Local coordinates within a 16x16x16 chunk:Section Coordinates
Chunk positions in the world grid:World Sections
The world is divided into vertical columns (sections) containing 8 chunks. Sections use a 64-bit ID encoding X and Z coordinates for hash table lookups:Chunk Management
Chunks are reference-counted to handle their lifecycle across multiple systems (rendering, meshing, world storage):Finding Chunks
The world maintains a single-entry cache for fast repeated lookups:Block Operations
Getting Blocks
Block retrieval fromsource/world.c:176-188:
Setting Blocks
Block modification with lighting updates fromsource/world.c:221-268:
Heightmap
Each section maintains a 16x16 heightmap for fast sky lighting calculations:Chunk Visibility
The renderer uses breadth-first search (BFS) with reachability masks for occlusion culling. Fromsource/world.c:78-149:
Lighting System
Lighting updates are deferred and processed one per frame:Collision Detection
AABB intersection testing fromsource/world.c:574-619: