fix(render): Phase A8 RR7.3 — dat-driven BFS in BuildingLoader

RR7.2 fix made the indoor branch fire (119K frames vs 0), but visual
verification showed missing interior textures — the inn's floor + lower
wall sections rendered as fog-color clear instead of cell-mesh polygons.
Root cause: BFS short-circuited at registry-build time on intermediate
cells that hadn't yet streamed in. The Holtburg Inn has 2 entry portals
+ 209 interior leaves; if any intermediate cell wasn't loaded when lbInfo
arrived, BFS stopped, EnvCellIds was a tiny subset of the building's true
cells, camCellIds at the gate excluded most inn cells, and IndoorPass
skipped their mesh entities → flat fog-color floor.

Fix: walk the dat directly in BFS via `dats.Get<EnvCell>(cellId)
  .CellPortals` (matches WB PortalService.cs:67-79). BFS now completes
deterministically at registry-build time regardless of cell load
ordering. Exit-portal polygon collection (Step C) also gets a dat
fallback so the stencil mask is complete on first indoor frame.

BuildingLoader.Build signature gains two optional params:
  - dats: DatCollection? — null in unit tests preserves old behavior
  - landblockOrigin: Vector3 — translation for dat-side polygons

Tests: 11/11 pass (unit-test path unchanged via dats == null).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-27 12:18:57 +02:00
parent efe35201fc
commit 56673e1b1e
2 changed files with 154 additions and 47 deletions

View file

@ -5895,7 +5895,17 @@ public sealed class GameWindow : IDisposable
uint lbRegistryKey = lb.LandblockId & 0xFFFF0000u;
_buildingRegistries[lbRegistryKey] =
AcDream.App.Rendering.Wb.BuildingLoader.Build(
lbInfo, lb.LandblockId, _cellVisibility.AllLoadedCells);
lbInfo,
lb.LandblockId,
_cellVisibility.AllLoadedCells,
// RR7.3: dat-driven BFS — completes regardless of which
// cells have streamed into _cellVisibility by the time
// lbInfo arrives. Without this, large multi-room
// buildings (Holtburg Inn = 209 leaves, 2 entry portals)
// had EnvCellIds short of the building's actual cell
// set when intermediate cells weren't yet loaded.
dats: _dats,
landblockOrigin: origin);
}
}