Refactor: Improve type handling and robustness for foliage mask indices and keys in terrain brush stamps.

This commit is contained in:
2026-05-02 04:13:56 +02:00
parent 6ee1eb9c69
commit c7f3ad78f7

View File

@@ -9685,10 +9685,14 @@ export class ViewportHost {
private mergeTerrainBrushStampIndices(
stroke: ActiveTerrainBrushStroke,
result: Pick<
ReturnType<typeof applyTerrainBrushStampInPlace>,
"heightSampleIndices" | "paintWeightIndices" | "foliageMaskValueIndices"
>
result: {
heightSampleIndices: readonly number[];
paintWeightIndices: readonly number[];
foliageMaskValueIndices?: ReturnType<
typeof applyTerrainBrushStampInPlace
>["foliageMaskValueIndices"];
foliageMaskValueKeys?: readonly string[];
}
) {
for (const sampleIndex of result.heightSampleIndices) {
stroke.heightSampleIndices.add(sampleIndex);
@@ -9698,7 +9702,7 @@ export class ViewportHost {
stroke.paintWeightIndices.add(paintWeightIndex);
}
for (const foliageMaskValueIndex of result.foliageMaskValueIndices) {
for (const foliageMaskValueIndex of result.foliageMaskValueIndices ?? []) {
stroke.foliageMaskValueKeys.add(
createTerrainFoliageMaskValueKey(
foliageMaskValueIndex.layerId,
@@ -9706,6 +9710,10 @@ export class ViewportHost {
)
);
}
for (const foliageMaskValueKey of result.foliageMaskValueKeys ?? []) {
stroke.foliageMaskValueKeys.add(foliageMaskValueKey);
}
}
private beginTerrainBrushStroke(event: PointerEvent): boolean {