HeightAtPixel read a single heightmap cell after truncating the coordinate with (int). Road path points are fractional and spaced under a metre apart, so consecutive points truncated into the same cell (flat), then tipped into the next one (a full inter-cell jump) — a metre-scale staircase under F2's fix. It now reads the four surrounding cells and blends them bilinearly using the fractional part of the coordinate, so height varies continuously with position. Edge clamping is preserved: at the map border the second cell clamps back onto the first, making the blend a no-op rather than an out-of-range read. Only the sampling helper changed. Signature and both callers are untouched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| Scripts | ||
| README.md | ||
Server Module - IslaApocalypse
Phase 2 Status: Active (Authoritative Chunk Management Online)
Overview
The Server directory contains the authoritative logic for the 3D Voxel Engine. It acts as the bridge between the static 2D WorldBlueprint residing in RAM and the physical 3D environment generated around the player. This architecture ensures that in a future multiplayer environment, the server dictates the terrain and sends chunk data to the clients.
Key Architecture & Components
1. The Authoritative Node (ServerChunkManager.cs)
Attached to the root of the Main.tscn world scene, this script manages the lifecycle of the entire 3D environment.
- Initialization: Upon boot, it reads the
WorldBlueprintand dynamically locates the exact X/Y pixel coordinates of theCapitolcity to use as the initial world spawn point. - Coordinate Translation: Converts 2D pixel coordinates into 3D chunk grid coordinates (e.g., Map Pixel [2048, 2048] becomes Chunk [64, 64]).
- Memory Management: Maintains an
_activeChunksdictionary to track which chunks are currently loaded in RAM, preventing duplicate generation and allowing for future chunk culling/unloading when the player moves away.
2. Terrain Math & Generation
- True Vertical Scaling: Height calculation directly multiplies the raw
FastNoiseLitefloat (0.0 to 1.0) againstConstants.CHUNK_HEIGHT(256 meters). This avoids heightmap compression and allows for towering, AAA-scale mountain cliffs. - Density Calculation: Uses exact surface interpolation to calculate the signed 3D distance of every voxel relative to the surface. This prevents terrain collapsing on horizontal edges and creates mathematically perfect slopes for the Marching Cubes algorithm.
- Biome Injection: Samples the
BiomeMapat the exact X/Z world coordinate to assign a specificBlockID(viaBiomePalette) to every voxel in the chunk.
Next Immediate Steps (Phase 2, Step 4)
- A Road Carving:* The Server Chunk Manager needs to be updated to cross-reference the
HighwaysandBranchRoadsvectors from the blueprint. If a chunk contains a road, the server must mathematically flatten theexactSurfaceYand override theBlockIDtoASPHALT.