fix(G.3): register portals-only connector cells for visibility (#133 ramp grey)
The grey "barrier" at a dungeon ramp was a one-cell registration gap. The ramp's connector cell (0x0007014D) is a portals-only pass-through — CellMesh.Build yields 0 drawable sub-meshes for it (you walk through it on adjacent floors). But the whole registration block — including the portal-VISIBILITY registration (BuildLoadedCell -> _cellVisibility) — was gated behind `if (cellSubMeshes.Count > 0)`. So that cell was never added to the visibility graph; the flood lookup-missed it (PortalVisibilityBuilder :369), couldn't traverse it to the room below, and the grey clear color showed through. Confirmed live via two added probes: [cellreg] registered=204/205 (only 0x014D missing) + [pv-trace] p4->0x0007014D skip=lookup-miss. After the fix: registered=205, hasRamp=True, skip=lookup-miss gone, the room below renders. Fix: compute the cell transforms and call BuildLoadedCell (visibility) for EVERY cell with a valid cellStruct, regardless of drawable sub-meshes — matching retail, which keeps the whole landblock cell array resident before the flood runs. Drawing (RegisterCell, _pendingCellMeshes) and the physics BSP (CacheCellStruct) stay gated on drawable geometry (a portals-only connector has nothing to draw and no collision surface). Not a regression from the FPS-collapse work — a pre-existing gate the now-navigable dungeon exposed (every ramp/stair/cellar mouth would show it). TEMP diagnostics retained for the residual angle-grey investigation (strip after): [cellreg] (GameWindow), the 0x0007 [pv-trace] gate widen + raw-NDC bbox (PortalVisibility- Builder). Three earlier render-math theories (portal_side, on-screen clip, near-eye projection) were each refuted by apparatus/probe before shipping — this is the verified one. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7d8da99f79
commit
d90c5385d2
2 changed files with 77 additions and 33 deletions
|
|
@ -61,6 +61,7 @@ public sealed class GameWindow : IDisposable
|
|||
// though the title-bar FPS is only updated every 0.5s.
|
||||
private double _lastFps = 60.0;
|
||||
private double _lastFrameMs = 16.7;
|
||||
private string _lastCellRegSig = ""; // TEMP #133 ramp-flood-collapse [cellreg] dedup
|
||||
|
||||
// Phase I.2: per-frame counters surfaced through the ImGui DebugPanel
|
||||
// VM closures. Computed once per render pass alongside the frustum
|
||||
|
|
@ -5664,26 +5665,42 @@ public sealed class GameWindow : IDisposable
|
|||
// Static objects inside the cell continue to flow through the dispatcher
|
||||
// as WorldEntity records below — they have real GfxObj MeshRefs that work
|
||||
// fine; EnvCellRenderer.RegisterCell receives an empty staticObjects list.
|
||||
// Transforms — needed by the portal-visibility cell (unlifted) AND the
|
||||
// render/physics path. Computed for EVERY cell with a valid cellStruct,
|
||||
// not just drawable ones. Keep the small render lift out of physics; retail
|
||||
// BSP contact planes use the EnvCell origin verbatim. The lift constant is
|
||||
// shared with every draw-space consumer of portal polygons (OutsideView
|
||||
// gate, seal/punch fans) — PortalVisibilityBuilder.ShellDrawLiftZ (#130).
|
||||
var physicsCellOrigin = envCell.Position.Origin + lbOffset;
|
||||
var cellOrigin = physicsCellOrigin + new System.Numerics.Vector3(
|
||||
0f, 0f, AcDream.App.Rendering.PortalVisibilityBuilder.ShellDrawLiftZ);
|
||||
var cellTransform =
|
||||
System.Numerics.Matrix4x4.CreateFromQuaternion(envCell.Position.Orientation) *
|
||||
System.Numerics.Matrix4x4.CreateTranslation(cellOrigin);
|
||||
var physicsCellTransform =
|
||||
System.Numerics.Matrix4x4.CreateFromQuaternion(envCell.Position.Orientation) *
|
||||
System.Numerics.Matrix4x4.CreateTranslation(physicsCellOrigin);
|
||||
|
||||
// PORTAL VISIBILITY: register EVERY cell with a valid cellStruct, regardless
|
||||
// of whether CellMesh.Build produced drawable sub-meshes. A portals-only
|
||||
// pass-through connector (a ramp / stair / cellar mouth) yields 0 render
|
||||
// sub-meshes but MUST be in the visibility graph so the flood can traverse it
|
||||
// to the cells beyond — otherwise the flood lookup-misses the unregistered
|
||||
// neighbour and the grey clear shows through the opening (#133: ramp
|
||||
// neighbour 0x0007014D had 0 sub-meshes → unregistered → vis=1 grey barrier
|
||||
// at the ramp; confirmed via [cellreg] registered=204/205 + [pv-trace]
|
||||
// skip=lookup-miss). Retail keeps the whole landblock cell array resident
|
||||
// before the flood runs; BuildLoadedCell reads the cellStruct portals, NOT
|
||||
// the render sub-meshes. The +0.02 m render lift is a DRAW concern only and
|
||||
// is intentionally NOT fed into the visibility transform (#119-residual: the
|
||||
// lift shifted horizontal portal planes 2 cm, side-culling deck/stair cells).
|
||||
BuildLoadedCell(envCellId, envCell, cellStruct, physicsCellOrigin, physicsCellTransform);
|
||||
|
||||
var cellSubMeshes = AcDream.Core.Meshing.CellMesh.Build(envCell, cellStruct, _dats);
|
||||
if (cellSubMeshes.Count > 0)
|
||||
{
|
||||
_pendingCellMeshes[envCellId] = cellSubMeshes;
|
||||
|
||||
// Keep the small render lift out of physics; retail BSP
|
||||
// contact planes use the EnvCell origin verbatim. The lift
|
||||
// constant is shared with every draw-space consumer of
|
||||
// portal polygons (OutsideView gate, seal/punch fans) —
|
||||
// see PortalVisibilityBuilder.ShellDrawLiftZ (#130).
|
||||
var physicsCellOrigin = envCell.Position.Origin + lbOffset;
|
||||
var cellOrigin = physicsCellOrigin + new System.Numerics.Vector3(
|
||||
0f, 0f, AcDream.App.Rendering.PortalVisibilityBuilder.ShellDrawLiftZ);
|
||||
var cellTransform =
|
||||
System.Numerics.Matrix4x4.CreateFromQuaternion(envCell.Position.Orientation) *
|
||||
System.Numerics.Matrix4x4.CreateTranslation(cellOrigin);
|
||||
var physicsCellTransform =
|
||||
System.Numerics.Matrix4x4.CreateFromQuaternion(envCell.Position.Orientation) *
|
||||
System.Numerics.Matrix4x4.CreateTranslation(physicsCellOrigin);
|
||||
|
||||
// Phase A8: register the cell with EnvCellRenderer for rendering.
|
||||
// staticObjects is empty — cell stabs continue as separate WorldEntity
|
||||
// records via the dispatcher (see lines below for the unchanged stab path).
|
||||
|
|
@ -5697,23 +5714,8 @@ public sealed class GameWindow : IDisposable
|
|||
cellRotation: envCell.Position.Orientation,
|
||||
staticObjects: System.Array.Empty<(uint, System.Numerics.Vector3, System.Numerics.Quaternion, bool, System.Numerics.Matrix4x4)>());
|
||||
|
||||
// Step 4: build LoadedCell for portal visibility — with the
|
||||
// PHYSICS (unlifted) transform. The +0.02 m render lift above
|
||||
// is a DRAW concern (shell z-fighting vs terrain); feeding it
|
||||
// into the visibility graph shifted every HORIZONTAL portal
|
||||
// plane 2 cm up, putting an eye standing on a deck/landing
|
||||
// 10–20 mm BELOW the lifted plane — outside the side test's
|
||||
// ±10 mm in-plane window — so the cell behind the portal was
|
||||
// side-culled: the tower-top staircase vanish + roof flap
|
||||
// (#119-residual; captured live at eye z=126.803 vs the
|
||||
// 010A→0107 plane at 126.80, reproduced ONLY with the lift in
|
||||
// TowerAscentReplayTests.CapturedTopOfStairs_*). Vertical
|
||||
// doorways were immune (the lift slides their planes along
|
||||
// themselves), which is why this hit exactly stairs, decks,
|
||||
// and cellar mouths.
|
||||
BuildLoadedCell(envCellId, envCell, cellStruct, physicsCellOrigin, physicsCellTransform);
|
||||
|
||||
// Cache CellStruct physics BSP for indoor collision (UNCHANGED).
|
||||
// Cache CellStruct physics BSP for indoor collision (UNCHANGED — gated
|
||||
// on drawable cells; a portals-only connector has no collision surface).
|
||||
_physicsDataCache.CacheCellStruct(envCellId, envCell, cellStruct, physicsCellTransform);
|
||||
}
|
||||
}
|
||||
|
|
@ -7689,6 +7691,25 @@ public sealed class GameWindow : IDisposable
|
|||
playerCellId: playerRoot?.CellId ?? 0u,
|
||||
lights: Lighting);
|
||||
|
||||
// TEMP (#133 ramp-flood-collapse): cell-registration completeness for the
|
||||
// player's dungeon landblock. If the ramp neighbour (0x....014D in 0x0007)
|
||||
// is absent from _cellVisibility, the portal flood can't admit it (lookup-miss
|
||||
// at PortalVisibilityBuilder.cs:369) and the grey clear shows through. Logs only
|
||||
// when the count or ramp-presence changes (dedup) — pairs with [pv-trace] skip=.
|
||||
if (AcDream.Core.Rendering.RenderingDiagnostics.ProbeFlapEnabled && playerRoot is not null)
|
||||
{
|
||||
uint plb = playerRoot.CellId >> 16;
|
||||
int reg = _cellVisibility.GetCellsForLandblock(plb).Count;
|
||||
uint rampId = (plb << 16) | 0x014Du;
|
||||
bool hasRamp = _cellVisibility.TryGetCell(rampId, out _);
|
||||
string sig = plb.ToString("X4") + ":" + reg + ":" + hasRamp;
|
||||
if (sig != _lastCellRegSig)
|
||||
{
|
||||
_lastCellRegSig = sig;
|
||||
Console.WriteLine($"[cellreg] lb=0x{plb:X4} registered={reg} hasRamp0x{rampId:X8}={hasRamp} playerCell=0x{playerRoot.CellId:X8}");
|
||||
}
|
||||
}
|
||||
|
||||
// Never cull the landblock the player is currently on.
|
||||
uint? playerLb = null;
|
||||
if (_playerMode && _playerController is not null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue