Issue181VisFlapReplayTests: headless flood replay at the live parked pose names cell 0x8A020181 - +-0.5mm eye perturbations flip its admission (at yaw15/pitch-20 for every direction). Issue181CameraParkStabilityTests: the camera loop parks BIT-EXACT with static inputs (0.00um over 2000 frames) - the live ~1mm/frame wander is the wall-press equilibrium (sought steps a*gap ~4mm into the wall per frame, the clip lands within adjust_to_plane's parametric 0.02 window; player physics bit-frozen per [resolve]). That wobble is retail-class. The defect is OURS: the A7 adaptation scopes light application to the camera flood's per-frame admission, so a sliver cell flapping flips whole lit regions; retail computes light reach once at registration (Render::add_static_light -> CObjCell::add_lights), camera-independent. Fix direction: registration-time per-light reach sets via the portal graph (pseudocode docs/research/2026-07-06-a7-per-cell-lighting-pseudocode.md). ISSUES #181 updated with the full chain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
105 lines
4.5 KiB
C#
105 lines
4.5 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Numerics;
|
||
using AcDream.App.Rendering;
|
||
using DatReaderWriter;
|
||
using DatReaderWriter.Options;
|
||
using Xunit;
|
||
using Xunit.Abstractions;
|
||
|
||
namespace AcDream.App.Tests.Rendering;
|
||
|
||
/// <summary>
|
||
/// #181 — the portal-flood admitted set flaps 31↔32 on MICRON eye noise at a
|
||
/// parked camera (live: launch-176-leakfix.log, root 0x8A020142, vis flips
|
||
/// every ~100–200 frames for 517k frames; the swept eye carries ~7 µm
|
||
/// float-roundtrip noise). The flapping cell's visibility-scoped lights + the
|
||
/// union-AABB scissor rect strobe = the #176 washed-region flicker.
|
||
///
|
||
/// This replay hunts the knife edge headlessly: at the live parked eye
|
||
/// (49.15, −38.62, −3.98), sweep gazes and perturb the eye by ±0.5 mm per
|
||
/// axis; ANY admitted-set difference at sub-mm perturbation is the #181
|
||
/// instability, and the symmetric difference names the flapping cell.
|
||
/// </summary>
|
||
public class Issue181VisFlapReplayTests
|
||
{
|
||
private const uint FacilityHub = 0x8A020000u;
|
||
private const uint LiveRoot = FacilityHub | 0x0142u;
|
||
|
||
private static readonly Vector3 LiveEye = new(49.15f, -38.62f, -3.98f);
|
||
|
||
private readonly ITestOutputHelper _out;
|
||
public Issue181VisFlapReplayTests(ITestOutputHelper output) => _out = output;
|
||
|
||
private static Matrix4x4 ViewProjFor(Vector3 eye, Vector3 gazeDir)
|
||
{
|
||
var view = Matrix4x4.CreateLookAt(eye, eye + gazeDir, Vector3.UnitZ);
|
||
var proj = Matrix4x4.CreatePerspectiveFieldOfView(MathF.PI / 3f, 16f / 9f, 0.1f, 5000f);
|
||
return view * proj;
|
||
}
|
||
|
||
private static List<uint> Flood(
|
||
Dictionary<uint, LoadedCell> cells, uint rootId, Vector3 eye, Vector3 gazeDir)
|
||
{
|
||
Func<uint, LoadedCell?> lookup = id => cells.TryGetValue(id, out var c) ? c : null;
|
||
var frame = PortalVisibilityBuilder.Build(
|
||
cells[rootId], eye, lookup, ViewProjFor(eye, gazeDir),
|
||
buildingMembership: null,
|
||
drawLiftZ: PortalVisibilityBuilder.ShellDrawLiftZ);
|
||
var result = new List<uint>(frame.OrderedVisibleCells);
|
||
result.Sort();
|
||
return result;
|
||
}
|
||
|
||
private static string CellSetString(IEnumerable<uint> ids)
|
||
=> string.Join(" ", ids.Select(id => $"{id & 0xFFFFu:X4}"));
|
||
|
||
[Fact]
|
||
public void Diagnostic_SubMillimeterEyePerturbation_MustNotChangeAdmission()
|
||
{
|
||
var datDir = CornerFloodReplayTests.ResolveDatDir();
|
||
if (datDir is null) { _out.WriteLine("SKIP: no dat dir"); return; }
|
||
using var dats = new DatCollection(datDir, DatAccessType.Read);
|
||
var cells = Issue120ReciprocalPingPongTests.LoadAllInteriorCells(dats, FacilityHub);
|
||
Assert.True(cells.ContainsKey(LiveRoot), "live root 0x0142 not loaded");
|
||
|
||
// ±0.5 mm per axis — an order of magnitude above the live µm noise, well
|
||
// below anything visually meaningful.
|
||
var perturbations = new[]
|
||
{
|
||
new Vector3( 0.0005f, 0, 0), new Vector3(-0.0005f, 0, 0),
|
||
new Vector3(0, 0.0005f, 0), new Vector3(0, -0.0005f, 0),
|
||
new Vector3(0, 0, 0.0005f), new Vector3(0, 0, -0.0005f),
|
||
};
|
||
|
||
int unstableGazes = 0;
|
||
for (int yawDeg = 0; yawDeg < 360; yawDeg += 15)
|
||
{
|
||
foreach (float pitchDeg in new[] { 0f, -20f, -35f })
|
||
{
|
||
float yaw = yawDeg * MathF.PI / 180f, pitch = pitchDeg * MathF.PI / 180f;
|
||
var gaze = new Vector3(
|
||
MathF.Cos(pitch) * MathF.Cos(yaw),
|
||
MathF.Cos(pitch) * MathF.Sin(yaw),
|
||
MathF.Sin(pitch));
|
||
|
||
var baseline = Flood(cells, LiveRoot, LiveEye, gaze);
|
||
foreach (var d in perturbations)
|
||
{
|
||
var perturbed = Flood(cells, LiveRoot, LiveEye + d, gaze);
|
||
if (perturbed.SequenceEqual(baseline)) continue;
|
||
|
||
unstableGazes++;
|
||
var removed = baseline.Except(perturbed).ToList();
|
||
var added = perturbed.Except(baseline).ToList();
|
||
_out.WriteLine(FormattableString.Invariant(
|
||
$"UNSTABLE yaw={yawDeg} pitch={pitchDeg} d=({d.X * 1000:F1},{d.Y * 1000:F1},{d.Z * 1000:F1})mm base={baseline.Count} pert={perturbed.Count} removed=[{CellSetString(removed)}] added=[{CellSetString(added)}]"));
|
||
}
|
||
}
|
||
}
|
||
|
||
_out.WriteLine($"unstable (gaze, perturbation) pairs: {unstableGazes}");
|
||
// Diagnostic first: report, don't assert — the fix turns this into a hard pin.
|
||
}
|
||
}
|