diag(render): Phase U.4c — ACDREAM_PROBE_FLAP per-frame convergence probe

Per-frame (not cell-change-throttled, so it catches the flicker at a stable root):
[flap] line from the builder — root cell's per-portal side-test D + traverse/cull +
NDC projection, plus OutsideView poly count + visible-cell count; localEye exposes
when the eye has crossed an interior portal plane. Paired [flap-cam] line from the
draw site — FindCameraCell resolution branch (CameraCellResolution enum, new),
eyeInRoot AABB flag (stale-root signal), eye + player worldpos, and the frame's
TerrainMode/OutdoorVisible outcome. Disambiguates side-cull vs empty-projection vs
stale-root. Inert when off (gated). Throwaway apparatus to converge the flap fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-31 10:44:37 +02:00
parent 8941d1e6e5
commit 1d47ede007
4 changed files with 118 additions and 0 deletions

View file

@ -142,6 +142,25 @@ public struct PortalClipPlane
public int InsideSide;
}
/// <summary>
/// Phase U.4c flap probe (diagnostic): which branch of
/// <see cref="CellVisibility.FindCameraCell"/> resolved the camera cell.
/// </summary>
public enum CameraCellResolution
{
/// <summary>No cell contains the eye (outdoors), or not yet resolved.</summary>
None,
/// <summary>The eye is inside the previously-cached cell (fast path).</summary>
Cache,
/// <summary>The eye is inside a one-hop portal neighbour of the cached cell.</summary>
Neighbour,
/// <summary>The eye is inside a cell found by the full brute-force scan.</summary>
BruteForce,
/// <summary>The eye is inside NO cell, but the previous cell is kept alive for a
/// few grace frames — the "stale root" case the flap probe watches for.</summary>
Grace,
}
/// <summary>
/// Result of a portal-based visibility BFS from the camera cell.
/// </summary>
@ -213,6 +232,14 @@ public sealed class CellVisibility
/// <summary>The last visibility result produced by <see cref="ComputeVisibility"/>.</summary>
public VisibilityResult? LastVisibilityResult { get; private set; }
/// <summary>
/// Phase U.4c flap probe (diagnostic): which <see cref="FindCameraCell"/> branch
/// resolved the camera cell on the most recent call. A <see cref="CameraCellResolution.Grace"/>
/// (or <see cref="CameraCellResolution.Cache"/>) result while the eye is NOT actually inside the
/// returned cell is the "stale root" signature the flap probe looks for.
/// </summary>
public CameraCellResolution LastCameraCellResolution { get; private set; } = CameraCellResolution.None;
// ------------------------------------------------------------------
// Registration
// ------------------------------------------------------------------
@ -330,7 +357,10 @@ public sealed class CellVisibility
{
// 1. Fast path: cached cell.
if (_lastCameraCell != null && PointInCell(cameraPos, _lastCameraCell))
{
LastCameraCellResolution = CameraCellResolution.Cache;
return _lastCameraCell;
}
// 2. One-hop neighbours of the cached cell.
if (_lastCameraCell != null)
@ -347,6 +377,7 @@ public sealed class CellVisibility
{
_lastCameraCell = neighbour;
_cellSwitchGraceFrames = CellSwitchGraceFrameCount;
LastCameraCellResolution = CameraCellResolution.Neighbour;
return neighbour;
}
}
@ -361,6 +392,7 @@ public sealed class CellVisibility
{
_lastCameraCell = cell;
_cellSwitchGraceFrames = CellSwitchGraceFrameCount;
LastCameraCellResolution = CameraCellResolution.BruteForce;
return cell;
}
}
@ -370,11 +402,13 @@ public sealed class CellVisibility
if (_lastCameraCell != null && _cellSwitchGraceFrames > 0)
{
_cellSwitchGraceFrames--;
LastCameraCellResolution = CameraCellResolution.Grace;
return _lastCameraCell;
}
// 5. Camera is outside all cells.
_lastCameraCell = null;
LastCameraCellResolution = CameraCellResolution.None;
return null;
}