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);
|
||||
|
||||
@@ -10,7 +10,10 @@ import {
|
||||
import { createBoxBrush } from "../../src/document/brushes";
|
||||
import { createScenePath } from "../../src/document/paths";
|
||||
import { createDefaultProjectTimeSettings } from "../../src/document/project-time-settings";
|
||||
import { createTerrain } from "../../src/document/terrains";
|
||||
import {
|
||||
createTerrain,
|
||||
createTerrainFoliageMask
|
||||
} from "../../src/document/terrains";
|
||||
import {
|
||||
createEmptyProjectDocument,
|
||||
createEmptyProjectScene,
|
||||
@@ -44,6 +47,8 @@ import { createProjectSequence } from "../../src/sequencer/project-sequences";
|
||||
import { createModelInstance } from "../../src/assets/model-instances";
|
||||
import { createProjectAssetStorageKey, type AudioAssetRecord } from "../../src/assets/project-assets";
|
||||
import { buildRuntimeSceneFromDocument } from "../../src/runtime-three/runtime-scene-build";
|
||||
import { BUNDLED_FOLIAGE_PROTOTYPES } from "../../src/foliage/bundled-foliage-manifest";
|
||||
import { createFoliageLayer } from "../../src/foliage/foliage";
|
||||
import { createFixtureLoadedModelAssetFromGeometry } from "../helpers/model-collider-fixtures";
|
||||
|
||||
const defaultMovementTemplate = createPlayerStartMovementTemplate();
|
||||
|
||||
Reference in New Issue
Block a user