From aa1bc272ab865802ca09a6508de7df6ba88899de Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 13 May 2026 00:46:36 +0200 Subject: [PATCH] Refactor terrain layer validation to use min/max range and update paint weight calculation --- src/document/scene-document-validation.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/document/scene-document-validation.ts b/src/document/scene-document-validation.ts index 298e1ae4..14b5a06a 100644 --- a/src/document/scene-document-validation.ts +++ b/src/document/scene-document-validation.ts @@ -3023,12 +3023,15 @@ function validateTerrain( } } - if (terrain.layers.length !== TERRAIN_LAYER_COUNT) { + if ( + terrain.layers.length < MIN_TERRAIN_LAYER_COUNT || + terrain.layers.length > MAX_TERRAIN_LAYER_COUNT + ) { diagnostics.push( createDiagnostic( "error", "invalid-terrain-layer-count", - `Terrain layers must contain exactly ${TERRAIN_LAYER_COUNT} authored layer slots.`, + `Terrain layers must contain between ${MIN_TERRAIN_LAYER_COUNT} and ${MAX_TERRAIN_LAYER_COUNT} authored layer slots.`, `${path}.layers` ) ); @@ -3054,7 +3057,9 @@ function validateTerrain( } const expectedPaintWeightCount = - terrain.sampleCountX * terrain.sampleCountZ * (TERRAIN_LAYER_COUNT - 1); + terrain.sampleCountX * + terrain.sampleCountZ * + getTerrainStoredPaintWeightCount(terrain.layers.length); if (terrain.paintWeights.length !== expectedPaintWeightCount) { diagnostics.push(