From 1b98fb5a17e60fc2bb32593a8b24b03452038153 Mon Sep 17 00:00:00 2001 From: beezm Date: Sat, 8 Aug 2026 19:52:33 -0400 Subject: [PATCH] fix: double crater carve on aliased maps when the curve is off (terrain-water task 10) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pass-2c restructure carved sequentially through both map references; with TerrainCurve off the classify map aliases the height map, so the second Lerp re-carved already-carved cells — a deeper bowl and shifted crater-adjacent water/biomes on curve-off runs only. Caught by the task-10 continuity oracle (md5 vs the batch-08 curve-off baseline); curve-on runs were unaffected (separate arrays, oracle 24/24). Both values are now read before either write. Co-Authored-By: Claude Fable 5 --- Tools/Scripts/MapGenerator.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Tools/Scripts/MapGenerator.cs b/Tools/Scripts/MapGenerator.cs index ccbc7fb..40528cb 100644 --- a/Tools/Scripts/MapGenerator.cs +++ b/Tools/Scripts/MapGenerator.cs @@ -540,8 +540,13 @@ public partial class MapGenerator : TextureRect float craterDepth = 1.0f - (distToCrater / physicalCraterRadius); // Dialed back to -0.15f as per your excellent instinct! float carveTarget = GetSeaLevel(_tempMap[x, y]) - 0.15f; - _heightMapClassify[x, y] = Mathf.Lerp(_heightMapClassify[x, y], carveTarget, craterDepth * 0.9f); - _heightMap[x, y] = Mathf.Lerp(_heightMap[x, y], carveTarget, craterDepth * 0.9f); + // Read BOTH before writing EITHER: with the curve off the two maps + // alias the same array, and a sequential read-modify-write carved + // the crater twice (caught by the task-10 continuity oracle). + float preClassify = _heightMapClassify[x, y]; + float preCurved = _heightMap[x, y]; + _heightMapClassify[x, y] = Mathf.Lerp(preClassify, carveTarget, craterDepth * 0.9f); + _heightMap[x, y] = Mathf.Lerp(preCurved, carveTarget, craterDepth * 0.9f); } } }