Terrain edit (VK): brush/selection area overlay not rendered, and edited terrain updates seconds late #235

Closed
opened 2026-10-01 22:47:22 +00:00 by sky_line · 0 comments
Owner

Problems (Vulkan)

  1. Terrain edit mode: the selection / affected-area overlay doesn't render. Edit > Terrain (land brush / select land) shows no outline of the area being edited.
  2. Terrain doesn't update instantly when edited. After a raise / lower / smooth / flatten stroke, the ground changes seconds later instead of as you paint.

Causes (from code reading)

1. Tool overlay never drawn

The VK world-overlay block (llappviewer.cpp, vk_worldOverlays, inside beginWorldOverlay() / endWorldOverlay()) draws:

  • renderSelections, LLTracker::render3D;
  • LLWorld::renderPropertyLines;
  • LLViewerParcelMgr::render / renderParcelCollision.

It never calls the current tool's render(). LL calls LLToolMgr::getInstance()->getCurrentTool()->render() from the (diverted) GL pipeline path. So LLToolBrushLand::render() / renderOverlay() (lltoolbrush.cpp), the brush area outline over the land, never runs under VK.

Fix: call the current tool's render() inside the world-overlay scope (world camera loaded, depth test on, no depth write), gated as LL gates it. Check other tools' render() too: the select-land tool's parcel selection and any manip whose 3D render was LL-pipeline-only. Each may need a VK-safe path (immediate-mode through the LLRender backend is fine here).

2. Terrain patch re-ingest waits for the sweep

Under VK, terrain geometry is rebuilt by vkIngestTerrainPatch() (llcleaningest.cpp), straight from the region heightfield. It is only reached from the ingest sweep (sweepIngestObject -> PARTITION_TERRAIN). The sweep is time-sliced and drops to 1/8 rate when idle, so an edited patch waits for the cursor to come round: seconds.

LL marks edited patches dirty (LLSurfacePatch::dirtyZ() / LLVOSurfacePatch::dirtyPatch() / dirtyGeom) when height data arrives from the sim (LLSurface::decompressDCTPatch / layer data) or from the local preview of a brush stroke.

Fix: hook the patch-dirty path to push the patch object onto the priority ingest (LLCleanIngest::noteObjectChanged(patchObj) or a dedicated terrain-dirty queue):

  • re-generate that patch and its neighbours (shared seam rows / normals) the next frame;
  • de-dup per frame (a stroke dirties many patches repeatedly);
  • keep captureTerrain's identical-rebuild de-dup.

Also check:

  • Normals and composition: edited heights change normals at the patch border, so neighbours must be re-ingested too, or seams show lighting steps.
  • Terrain BLAS / RT shadows: a rebuilt patch must update its BLAS (slot change -> rtSlotChanged), or RT shadows lag the new ground.
  • Reflection probes / water: probe captures near the edit go stale. Optional: dirty probes whose box contains the edited patch.

Test

  1. On land you can edit, select Edit > Terrain.
  2. Hover and paint with each brush (flatten, raise, lower, smooth, roughen, revert) at several sizes.
  3. Check that the area outline shows, follows the mouse and matches the brush size.
  4. Check that ground changes appear immediately as you paint, with no seams at patch borders.
  5. Check that RT shadows on the new ground are correct.
  6. Repeat on a region border.
## Problems (Vulkan) 1. **Terrain edit mode: the selection / affected-area overlay doesn't render.** Edit > Terrain (land brush / select land) shows no outline of the area being edited. 2. **Terrain doesn't update instantly when edited.** After a raise / lower / smooth / flatten stroke, the ground changes seconds later instead of as you paint. ## Causes (from code reading) ### 1. Tool overlay never drawn The VK world-overlay block (`llappviewer.cpp`, `vk_worldOverlays`, inside `beginWorldOverlay()` / `endWorldOverlay()`) draws: - `renderSelections`, `LLTracker::render3D`; - `LLWorld::renderPropertyLines`; - `LLViewerParcelMgr::render` / `renderParcelCollision`. It **never calls the current tool's `render()`**. LL calls `LLToolMgr::getInstance()->getCurrentTool()->render()` from the (diverted) GL pipeline path. So `LLToolBrushLand::render()` / `renderOverlay()` (`lltoolbrush.cpp`), the brush area outline over the land, never runs under VK. Fix: call the current tool's `render()` inside the world-overlay scope (world camera loaded, depth test on, no depth write), gated as LL gates it. Check other tools' `render()` too: the select-land tool's parcel selection and any manip whose 3D render was LL-pipeline-only. Each may need a VK-safe path (immediate-mode through the LLRender backend is fine here). ### 2. Terrain patch re-ingest waits for the sweep Under VK, terrain geometry is rebuilt by `vkIngestTerrainPatch()` (`llcleaningest.cpp`), straight from the region heightfield. It is **only reached from the ingest sweep** (`sweepIngestObject` -> `PARTITION_TERRAIN`). The sweep is time-sliced and drops to 1/8 rate when idle, so an edited patch waits for the cursor to come round: seconds. LL marks edited patches dirty (`LLSurfacePatch::dirtyZ()` / `LLVOSurfacePatch::dirtyPatch()` / `dirtyGeom`) when height data arrives from the sim (`LLSurface::decompressDCTPatch` / layer data) or from the local preview of a brush stroke. Fix: hook the patch-dirty path to push the patch object onto the priority ingest (`LLCleanIngest::noteObjectChanged(patchObj)` or a dedicated terrain-dirty queue): - re-generate that patch **and its neighbours** (shared seam rows / normals) the next frame; - de-dup per frame (a stroke dirties many patches repeatedly); - keep `captureTerrain`'s identical-rebuild de-dup. Also check: - **Normals and composition**: edited heights change normals at the patch border, so neighbours must be re-ingested too, or seams show lighting steps. - **Terrain BLAS / RT shadows**: a rebuilt patch must update its BLAS (slot change -> `rtSlotChanged`), or RT shadows lag the new ground. - **Reflection probes / water**: probe captures near the edit go stale. Optional: dirty probes whose box contains the edited patch. ## Test 1. On land you can edit, select Edit > Terrain. 2. Hover and paint with each brush (flatten, raise, lower, smooth, roughen, revert) at several sizes. 3. Check that the area outline shows, follows the mouse and matches the brush size. 4. Check that ground changes appear immediately as you paint, with no seams at patch borders. 5. Check that RT shadows on the new ground are correct. 6. Repeat on a region border.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream#235
No description provided.