docs: bring all READMEs current with actual code (post-sweep-10 truth pass)

Every README was read first, checked against the code in its directory, then
rewritten to describe what the code actually does now.

Corrected throughout: map size is config-driven (8192 default) not a fixed
4096; chunks are 24x24x256 not 32x32; road carving is implemented for all four
tiers, not a 'next step'; Data/ and Resources/ are empty, not populated.

Also fixed MATH_MARCHING_CUBES.md, which documented the density sign convention
exactly backwards — it claimed positive was underground, where the code treats
positive as above the surface and counts a corner inside when density < iso.
Getting that backwards inverts every normal, a bug this project has hit before.

The root README now carries accurate run steps: F5 runs the map generator (not
the game), F6 on Scenes/Main.tscn runs the 3D world, and ChunkRadius is a load
radius that should be dropped to 4-8 while iterating.

Docs only. No code changed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stewart Howe 2026-08-05 05:23:58 -04:00
parent f9ea2da3f4
commit d72ffc0183
13 changed files with 579 additions and 409 deletions

View file

@ -1,47 +1,37 @@
# 🎬 /Tools/Scenes - Developer Environments
## Overview
This directory contains the standalone Godot scenes (`.tscn` files) used to execute our offline generation scripts. These scenes act as isolated "sandboxes" for the developers to build the world data.
**CRITICAL RULE:** These scenes must **never** be added to the main game's build export or scene tree. They are run strictly inside the Godot Editor by pressing **F6 (Play Current Scene)**.
---
## 🏗️ Core Scenes
### 1. `MapPreview.tscn`
The original 2D map generation scene.
* **Root Node:** `TextureRect`
* **Attached Script:** `MapGenerator.cs`
* **Function:** Runs the FastNoiseLite math, builds the `_heightMap`, and executes the `_Draw()` commands to visually plot the A* road networks and town circles.
### 2. `MapCaptureTool.tscn` (The Wrapper)
The master scene used to actually execute and capture the map generation.
* **Root Node:** `SubViewportContainer`
* **Child Nodes:** `SubViewport` -> `MapPreview`
* **Function:** Acts as a massive, invisible "virtual monitor" to capture the high-resolution PNG of the map without the Godot UI layout engine interfering.
---
## ⚔️ The Great 4096 Struggle (Beating the UI Engine)
When we upgraded *Isla Apocalypse* from a 1024 to a 4096 (1:1 scale) map, we encountered a massive rendering roadblock. Godot's UI Layout Engine is designed to make things fit on a player's physical monitor.
When we asked `MapPreview` to render a 4096x4096 texture, Godot panicked. It saw that the developer's monitor was only 1080p, so it violently crushed the map down to fit the screen, resulting in exported PNGs that were either 1KB postage stamps or completely black.
#### The "Virtual Monitor" Solution
To bypass the UI engine, we had to build `MapCaptureTool.tscn`.
1. **The Container Trap:** We initially used a `SubViewportContainer` with "Stretch" enabled. This was a trap. It locked the resolution to the editor window. We had to forcefully disable `Stretch` in the C# code.
2. **The `SubViewport`:** We placed `MapPreview` inside a `SubViewport` set explicitly to 4096x4096. This acts as an offscreen virtual monitor that doesn't care about the physical screen size.
3. **The `MapDrawProxy`:** We realized that `Texture.GetImage()` only grabs the base pixels, completely ignoring the colored roads and towns drawn by `_Draw()`. We had to dynamically instantiate a `Control` proxy node to stamp the roads onto the virtual monitor *before* taking the picture.
4. **The Flash Timing:** Generating a 4096 map takes time. We had to implement `await ToSignal(GetTree(), "process_frame");` to let Godot unlock the scene tree, and `await ToSignal(RenderingServer... FramePostDraw)` to force the camera to wait until the GPU physically finished painting the roads before snapping the photo.
---
## 🚀 How to Generate a New World
1. Open `MapCaptureTool.tscn` in the Godot Editor.
2. Ensure you do **not** click the main Play button.
3. Press **F6** (Play Current Scene).
4. The editor will freeze for 10-30 seconds while the `ExportMapData` function writes the binary `.dat` file.
5. Once the console prints the success message, check your `user://` folder for the massive, full-resolution `.png` and the `.dat` blueprint.
# /Tools/Scenes — developer environments
Standalone scenes used to run the offline generation scripts. **Never add these to a game export.**
## `MapPreview.tscn`
The 2D map generator itself.
- **Root:** `TextureRect` · **Script:** `MapGenerator.cs`
- Runs the noise maths, builds the heightmap and biome map, plots the A\* road network, writes the
`.dat`, and draws the map via `_Draw()`.
⚠ **This is the project's main scene** (`project.godot` → `run/main_scene`). That means **pressing
F5 anywhere in the project runs this**, regenerating the world and overwriting your `.dat` — it does
not start the game. To view the 3D world, open `Scenes/Main.tscn` and press **F6** instead.
## `MapCaptureTool.tscn`
*(Lives in `/Scenes`, wraps this directory's scene.)* A `SubViewportContainer` → `SubViewport`
(4096×4096) → `MapPreview`. It exists purely to render the map offscreen at full resolution: Godot's
UI layout engine would otherwise scale a 4096-pixel render down to the editor window, producing a
tiny or black PNG.
Note the generator writes the `.dat` on its own — the capture wrapper only matters for the
full-resolution image.
## Generating a new world
1. Open `MapPreview.tscn` (or `Scenes/MapCaptureTool.tscn` for the full-resolution PNG).
2. Press **F6** — *Play Current Scene*.
3. **Expect minutes, not seconds**, and expect the editor to be unresponsive. The A\* road stage is
the slow part and can stall long enough to be worth abandoning; watch the console for
`[A*] 1/4 … 4/4` progress. See `/Tools/Scripts/README.md`.
4. On success the console prints the export path. Files land in `user://` —
`~/.local/share/godot/app_userdata/islaApocolypse/`.
**Then update `ServerConfig.json`'s `WorldSeed`** to match the new `.dat`, or the 3D scene will fail
to load it.