Five indoor-cell probe flags (ProbeIndoorWalk/Lookup/Upload/Xform/Cull) + IndoorAll master cascade, seeded from ACDREAM_PROBE_INDOOR_* env vars. Mirrors L.2a PhysicsDiagnostics pattern exactly. IsEnvCellId helper for call-site filtering (low-16 ≥ 0x0100 = EnvCell). Zero warnings. Spec: docs/superpowers/specs/2026-05-19-indoor-cell-rendering-fix-design.md Plan task 1: docs/superpowers/plans/2026-05-19-indoor-cell-rendering-phase1-diagnostics.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
109 lines
4.8 KiB
C#
109 lines
4.8 KiB
C#
using System;
|
||
|
||
namespace AcDream.Core.Rendering;
|
||
|
||
/// <summary>
|
||
/// 2026-05-19 — runtime-toggleable diagnostic flags for the indoor cell
|
||
/// rendering pipeline. Initialized from env vars at process start;
|
||
/// flippable at runtime via the DebugPanel mirror. Log call sites read
|
||
/// these statics so a checkbox toggle takes effect on the next frame
|
||
/// without relaunching.
|
||
///
|
||
/// <para>
|
||
/// Mirrors the L.2a <see cref="AcDream.Core.Physics.PhysicsDiagnostics"/>
|
||
/// pattern. The master <see cref="IndoorAll"/> toggle is the user's
|
||
/// common case — flipping it cascades to all five probe flags.
|
||
/// </para>
|
||
///
|
||
/// <para>
|
||
/// Spec: <c>docs/superpowers/specs/2026-05-19-indoor-cell-rendering-fix-design.md</c>.
|
||
/// </para>
|
||
/// </summary>
|
||
public static class RenderingDiagnostics
|
||
{
|
||
/// <summary>
|
||
/// When true, <c>WbDrawDispatcher.WalkVisibleEntities</c> emits one
|
||
/// <c>[indoor-walk]</c> line per visible cell entity per second:
|
||
/// entity id, world position, parent cell id, landblock visible flag,
|
||
/// AABB-visible flag, "in visible cells" flag, drew flag.
|
||
/// Initial state from <c>ACDREAM_PROBE_INDOOR_WALK=1</c>.
|
||
/// </summary>
|
||
public static bool ProbeIndoorWalkEnabled { get; set; } =
|
||
Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_WALK") == "1"
|
||
|| Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_ALL") == "1";
|
||
|
||
/// <summary>
|
||
/// When true, <c>WbDrawDispatcher</c> emits one <c>[indoor-lookup]</c>
|
||
/// line per visible cell entity per second: render-data hit/miss,
|
||
/// IsSetup flag, SetupParts count, parts-hit / parts-miss tallies.
|
||
/// Initial state from <c>ACDREAM_PROBE_INDOOR_LOOKUP=1</c>.
|
||
/// </summary>
|
||
public static bool ProbeIndoorLookupEnabled { get; set; } =
|
||
Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_LOOKUP") == "1"
|
||
|| Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_ALL") == "1";
|
||
|
||
/// <summary>
|
||
/// When true, <c>WbMeshAdapter</c> emits two lines per EnvCell id:
|
||
/// <c>[indoor-upload] requested</c> on first IncrementRefCount and
|
||
/// <c>[indoor-upload] completed</c> when WB's staged drain produces
|
||
/// its <c>ObjectMeshData</c>. Missing "completed" lines indicate WB
|
||
/// silently returned null (hypothesis H1).
|
||
/// Initial state from <c>ACDREAM_PROBE_INDOOR_UPLOAD=1</c>.
|
||
/// </summary>
|
||
public static bool ProbeIndoorUploadEnabled { get; set; } =
|
||
Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_UPLOAD") == "1"
|
||
|| Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_ALL") == "1";
|
||
|
||
/// <summary>
|
||
/// When true, <c>WbDrawDispatcher</c> emits one <c>[indoor-xform]</c>
|
||
/// line per visible cell entity per second: cell-geometry SetupPart's
|
||
/// composed world matrix translation. Disambiguates transform
|
||
/// double-apply (hypothesis H5).
|
||
/// Initial state from <c>ACDREAM_PROBE_INDOOR_XFORM=1</c>.
|
||
/// </summary>
|
||
public static bool ProbeIndoorXformEnabled { get; set; } =
|
||
Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_XFORM") == "1"
|
||
|| Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_ALL") == "1";
|
||
|
||
/// <summary>
|
||
/// When true, <c>WbDrawDispatcher.WalkVisibleEntities</c> emits one
|
||
/// <c>[indoor-cull]</c> line per cell entity that gets culled, with
|
||
/// the reason (visibleCellIds-miss, frustum, landblock). Disambiguates
|
||
/// cull bugs (hypothesis H3).
|
||
/// Initial state from <c>ACDREAM_PROBE_INDOOR_CULL=1</c>.
|
||
/// </summary>
|
||
public static bool ProbeIndoorCullEnabled { get; set; } =
|
||
Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_CULL") == "1"
|
||
|| Environment.GetEnvironmentVariable("ACDREAM_PROBE_INDOOR_ALL") == "1";
|
||
|
||
/// <summary>
|
||
/// Master toggle. Reading reflects the AND of all five flags
|
||
/// (true only when every probe is on). Writing cascades — setting
|
||
/// to <see langword="true"/> turns ALL five flags on; setting to
|
||
/// <see langword="false"/> turns ALL five off.
|
||
/// </summary>
|
||
public static bool IndoorAll
|
||
{
|
||
get => ProbeIndoorWalkEnabled
|
||
&& ProbeIndoorLookupEnabled
|
||
&& ProbeIndoorUploadEnabled
|
||
&& ProbeIndoorXformEnabled
|
||
&& ProbeIndoorCullEnabled;
|
||
set
|
||
{
|
||
ProbeIndoorWalkEnabled = value;
|
||
ProbeIndoorLookupEnabled = value;
|
||
ProbeIndoorUploadEnabled = value;
|
||
ProbeIndoorXformEnabled = value;
|
||
ProbeIndoorCullEnabled = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Helper for probe call sites. Returns <see langword="true"/> when
|
||
/// the low 16 bits of <paramref name="id"/> are ≥ 0x0100 — the AC
|
||
/// convention for EnvCell (indoor) cells, as opposed to outdoor cells
|
||
/// in the 8×8 landblock grid (0x0001–0x0040).
|
||
/// </summary>
|
||
public static bool IsEnvCellId(ulong id) => (id & 0xFFFFu) >= 0x0100u;
|
||
}
|