Improve foliage rendering and visibility synchronization in ViewportHost
This commit is contained in:
@@ -18,7 +18,6 @@ import {
|
||||
} from "./foliage-render-batches";
|
||||
import type {
|
||||
FoliageLayerRegistry,
|
||||
FoliagePrototype,
|
||||
FoliagePrototypeRegistry
|
||||
} from "./foliage";
|
||||
import {
|
||||
@@ -203,7 +202,7 @@ export class FoliageInstancedRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
void this.rebuildBatchesAsync(requestId, batches, prototypeRegistry);
|
||||
void this.rebuildBatchesAsync(requestId, batches);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
@@ -232,8 +231,7 @@ export class FoliageInstancedRenderer {
|
||||
|
||||
private async rebuildBatchesAsync(
|
||||
requestId: number,
|
||||
batches: readonly FoliageRenderBatch[],
|
||||
_prototypeRegistry: FoliagePrototypeRegistry
|
||||
batches: readonly FoliageRenderBatch[]
|
||||
) {
|
||||
const nextBatchGroup = new Group();
|
||||
nextBatchGroup.name = "foliageInstancedBatches";
|
||||
|
||||
@@ -1706,6 +1706,7 @@ export class ViewportHost {
|
||||
|
||||
this.applyViewModePose();
|
||||
this.applyAdvancedRenderingCameraFar(this.currentAdvancedRenderingSettings);
|
||||
this.syncFoliageVisibility();
|
||||
this.syncTerrainBrushPreview();
|
||||
|
||||
if (this.currentAdvancedRenderingSettings !== null) {
|
||||
@@ -1720,6 +1721,7 @@ export class ViewportHost {
|
||||
|
||||
this.displayMode = displayMode;
|
||||
this.applyWorld();
|
||||
this.syncFoliageVisibility();
|
||||
|
||||
if (this.currentDocument !== null) {
|
||||
this.updateDocument(this.currentDocument);
|
||||
@@ -2550,6 +2552,11 @@ export class ViewportHost {
|
||||
applyAdvancedRenderingRenderableShadowFlags(renderObjects.group, false);
|
||||
}
|
||||
|
||||
applyAdvancedRenderingRenderableShadowFlags(
|
||||
this.foliageRenderer.group,
|
||||
shadowsEnabled
|
||||
);
|
||||
|
||||
for (const renderGroup of this.modelRenderObjects.values()) {
|
||||
applyAdvancedRenderingRenderableShadowFlags(renderGroup, shadowsEnabled);
|
||||
}
|
||||
@@ -6629,6 +6636,20 @@ export class ViewportHost {
|
||||
this.syncTerrainBrushPreview();
|
||||
}
|
||||
|
||||
private syncFoliageVisibility() {
|
||||
this.foliageRenderer.group.visible =
|
||||
this.viewMode === "perspective" && this.displayMode !== "wireframe";
|
||||
}
|
||||
|
||||
private rebuildFoliage(document: SceneDocument) {
|
||||
this.syncFoliageVisibility();
|
||||
this.foliageRenderer.sync({
|
||||
terrains: document.terrains,
|
||||
foliageLayers: document.foliageLayers,
|
||||
foliagePrototypes: document.foliagePrototypes
|
||||
});
|
||||
}
|
||||
|
||||
private createTerrainRenderObjects(terrain: Terrain): TerrainRenderObjects {
|
||||
const detailMaterial = this.createTerrainMaterial(terrain);
|
||||
const distantMaterial = this.createTerrainDistantMaterial(terrain);
|
||||
|
||||
Reference in New Issue
Block a user