From 6ee1eb9c69b1c5cf8bceb1e98b028581c368ed1c Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 2 May 2026 04:13:39 +0200 Subject: [PATCH] Feature: Track foliage mask value keys in viewport host and brush stroke --- src/viewport-three/viewport-host.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index 6106d28e..23d3d683 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -9585,6 +9585,7 @@ export class ViewportHost { dirtyBounds: TerrainBrushDirtySampleBounds | null; heightSampleIndices: number[]; paintWeightIndices: number[]; + foliageMaskValueKeys: string[]; lastAppliedPoint: { x: number; z: number; @@ -9601,6 +9602,7 @@ export class ViewportHost { dirtyBounds: null, heightSampleIndices: [], paintWeightIndices: [], + foliageMaskValueKeys: [], lastAppliedPoint: from }; } @@ -9609,6 +9611,7 @@ export class ViewportHost { let dirtyBounds: TerrainBrushDirtySampleBounds | null = null; const heightSampleIndices = new Set(); const paintWeightIndices = new Set(); + const foliageMaskValueKeys = new Set(); let lastAppliedPoint = from; const stepCount = Math.floor(distance / spacing); const mergeDirtyBounds = (nextBounds: TerrainBrushDirtySampleBounds | null) => { @@ -9659,6 +9662,14 @@ export class ViewportHost { for (const paintWeightIndex of result.paintWeightIndices) { paintWeightIndices.add(paintWeightIndex); } + for (const foliageMaskValueIndex of result.foliageMaskValueIndices) { + foliageMaskValueKeys.add( + createTerrainFoliageMaskValueKey( + foliageMaskValueIndex.layerId, + foliageMaskValueIndex.index + ) + ); + } lastAppliedPoint = point; } @@ -9667,6 +9678,7 @@ export class ViewportHost { dirtyBounds, heightSampleIndices: [...heightSampleIndices], paintWeightIndices: [...paintWeightIndices], + foliageMaskValueKeys: [...foliageMaskValueKeys], lastAppliedPoint }; } @@ -9675,7 +9687,7 @@ export class ViewportHost { stroke: ActiveTerrainBrushStroke, result: Pick< ReturnType, - "heightSampleIndices" | "paintWeightIndices" + "heightSampleIndices" | "paintWeightIndices" | "foliageMaskValueIndices" > ) { for (const sampleIndex of result.heightSampleIndices) { @@ -9685,6 +9697,15 @@ export class ViewportHost { for (const paintWeightIndex of result.paintWeightIndices) { stroke.paintWeightIndices.add(paintWeightIndex); } + + for (const foliageMaskValueIndex of result.foliageMaskValueIndices) { + stroke.foliageMaskValueKeys.add( + createTerrainFoliageMaskValueKey( + foliageMaskValueIndex.layerId, + foliageMaskValueIndex.index + ) + ); + } } private beginTerrainBrushStroke(event: PointerEvent): boolean {