From eb251639cfc8e11604bd036661eb5ea4b18e30dd Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 08:37:19 -0700 Subject: [PATCH] fix(editor): NaN-safe baseHeight propagation in addAdjacentTile Source tile's chunks[0].position[2] could be NaN if mid-edit terrain hadn't run stitchEdges yet. Fall back to 100.0 so the adjacent tile doesn't start with poisoned base. --- tools/editor/editor_app.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_app.cpp b/tools/editor/editor_app.cpp index 2d06fe83..8d336520 100644 --- a/tools/editor/editor_app.cpp +++ b/tools/editor/editor_app.cpp @@ -1514,7 +1514,11 @@ void EditorApp::addAdjacentTile(int offsetX, int offsetY) { int newY = loadedTileY_ + offsetY; if (newX < 0 || newX > 63 || newY < 0 || newY > 63) return; - auto adj = TerrainEditor::createBlankTerrain(newX, newY, terrain_.chunks[0].position[2], + // Source base height could be NaN if mid-edit terrain hadn't stitched — + // fall back to a safe default so the new tile starts clean. + float baseHeight = terrain_.chunks[0].position[2]; + if (!std::isfinite(baseHeight)) baseHeight = 100.0f; + auto adj = TerrainEditor::createBlankTerrain(newX, newY, baseHeight, Biome::Grassland); // Stitch edge heights from current tile to adjacent tile