Feature: Track foliage mask value keys in viewport host and brush stroke

This commit is contained in:
2026-05-02 04:13:39 +02:00
parent 0c323670a5
commit 6ee1eb9c69

View File

@@ -9585,6 +9585,7 @@ export class ViewportHost {
dirtyBounds: TerrainBrushDirtySampleBounds | null; dirtyBounds: TerrainBrushDirtySampleBounds | null;
heightSampleIndices: number[]; heightSampleIndices: number[];
paintWeightIndices: number[]; paintWeightIndices: number[];
foliageMaskValueKeys: string[];
lastAppliedPoint: { lastAppliedPoint: {
x: number; x: number;
z: number; z: number;
@@ -9601,6 +9602,7 @@ export class ViewportHost {
dirtyBounds: null, dirtyBounds: null,
heightSampleIndices: [], heightSampleIndices: [],
paintWeightIndices: [], paintWeightIndices: [],
foliageMaskValueKeys: [],
lastAppliedPoint: from lastAppliedPoint: from
}; };
} }
@@ -9609,6 +9611,7 @@ export class ViewportHost {
let dirtyBounds: TerrainBrushDirtySampleBounds | null = null; let dirtyBounds: TerrainBrushDirtySampleBounds | null = null;
const heightSampleIndices = new Set<number>(); const heightSampleIndices = new Set<number>();
const paintWeightIndices = new Set<number>(); const paintWeightIndices = new Set<number>();
const foliageMaskValueKeys = new Set<string>();
let lastAppliedPoint = from; let lastAppliedPoint = from;
const stepCount = Math.floor(distance / spacing); const stepCount = Math.floor(distance / spacing);
const mergeDirtyBounds = (nextBounds: TerrainBrushDirtySampleBounds | null) => { const mergeDirtyBounds = (nextBounds: TerrainBrushDirtySampleBounds | null) => {
@@ -9659,6 +9662,14 @@ export class ViewportHost {
for (const paintWeightIndex of result.paintWeightIndices) { for (const paintWeightIndex of result.paintWeightIndices) {
paintWeightIndices.add(paintWeightIndex); paintWeightIndices.add(paintWeightIndex);
} }
for (const foliageMaskValueIndex of result.foliageMaskValueIndices) {
foliageMaskValueKeys.add(
createTerrainFoliageMaskValueKey(
foliageMaskValueIndex.layerId,
foliageMaskValueIndex.index
)
);
}
lastAppliedPoint = point; lastAppliedPoint = point;
} }
@@ -9667,6 +9678,7 @@ export class ViewportHost {
dirtyBounds, dirtyBounds,
heightSampleIndices: [...heightSampleIndices], heightSampleIndices: [...heightSampleIndices],
paintWeightIndices: [...paintWeightIndices], paintWeightIndices: [...paintWeightIndices],
foliageMaskValueKeys: [...foliageMaskValueKeys],
lastAppliedPoint lastAppliedPoint
}; };
} }
@@ -9675,7 +9687,7 @@ export class ViewportHost {
stroke: ActiveTerrainBrushStroke, stroke: ActiveTerrainBrushStroke,
result: Pick< result: Pick<
ReturnType<typeof applyTerrainBrushStampInPlace>, ReturnType<typeof applyTerrainBrushStampInPlace>,
"heightSampleIndices" | "paintWeightIndices" "heightSampleIndices" | "paintWeightIndices" | "foliageMaskValueIndices"
> >
) { ) {
for (const sampleIndex of result.heightSampleIndices) { for (const sampleIndex of result.heightSampleIndices) {
@@ -9685,6 +9697,15 @@ export class ViewportHost {
for (const paintWeightIndex of result.paintWeightIndices) { for (const paintWeightIndex of result.paintWeightIndices) {
stroke.paintWeightIndices.add(paintWeightIndex); stroke.paintWeightIndices.add(paintWeightIndex);
} }
for (const foliageMaskValueIndex of result.foliageMaskValueIndices) {
stroke.foliageMaskValueKeys.add(
createTerrainFoliageMaskValueKey(
foliageMaskValueIndex.layerId,
foliageMaskValueIndex.index
)
);
}
} }
private beginTerrainBrushStroke(event: PointerEvent): boolean { private beginTerrainBrushStroke(event: PointerEvent): boolean {