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.
This commit is contained in:
Kelsi 2026-05-06 08:37:19 -07:00
parent b7e3266c7a
commit eb251639cf

View file

@ -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