Checkpoint of the unified retail-faithful indoor render. The two-week HANG/grey is fixed and the interior seals (live-verified by the user). Commits the session render-rewrite foundation together with the fixes that made it functional. - HANG fix: PortalVisibilityBuilder.Build portal flood did not terminate (the faithful ProjectToClip near-side clip drifts per round, defeating the CellView dedup; the BFS had no bound after U.2a removed MaxReprocessPerCell). Fix = drift-tolerant snapped/canonical CellView.Add dedup (PortalView.cs) plus restored MaxReprocessPerCell=16 bounded re-enqueue (PortalVisibilityBuilder.cs). Re-enqueue is kept (load-bearing for late-slice propagation, Build_ViewGrowthAfterDoneCell_PropagatesNewSlicesToExit); only its count is capped. CellViewDedupTests added. - Seal (DrawCells Task 2): RetailPViewRenderer.DrawEnvCellShells draws EVERY visible cell via IndoorDrawPlan.ShellPass (was gated on the ClipFrameAssembler slot filter, leaving slot-less cells grey). - Look-in FPS: GameWindow exterior look-in candidates limited to the player landblock +-1 (was all ~81 loaded LBs iterated every outdoor frame). No behaviour change (far cells were >48m, already culled). Remaining dominant issue = the FLAP at transitions: viewer-cell metastability (render roots at the camera-eye cell, which oscillates outdoor-indoor as the 3rd-person boom drifts across the doorway, confirmed in render-sig). SEPARATE fix, NOT the DrawCells port. Full handoff + flap fix plan + tracked follow-ups (#78 terrain, look-in-from-inside, look-in FPS, L-spotlight): docs/research/2026-06-07-indoor-render-session-handoff.md. Baselines: build 0 err; App.Tests 210/210; Core.Tests 1331 pass / 4 fail (pre-existing) / 1 skip. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 lines
2.6 KiB
C#
64 lines
2.6 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Rendering;
|
|
using Xunit;
|
|
|
|
namespace AcDream.App.Tests.Rendering;
|
|
|
|
// Regression tests for the indoor-render HANG (2026-06-06): the portal-visibility flood
|
|
// re-queues a cell whenever its CellView grows, so it only terminates when CellView.Add's
|
|
// dedup catches a duplicate. Across BFS rounds the same region comes back float-drifted,
|
|
// vertex-rotated, or with a ±1 vertex count; the old exact index-by-index SamePolygon
|
|
// (eps 1e-4) missed all three, so the region grew forever -> CPU-spin hang in CellView.Add.
|
|
// A drift-tolerant, rotation-invariant dedup makes the key space finite, so the flood
|
|
// converges (and these duplicates collapse).
|
|
public class CellViewDedupTests
|
|
{
|
|
private static ViewPolygon Quad(float ox, float oy) => new(new[]
|
|
{
|
|
new Vector2(ox - 0.5f, oy - 0.5f), new Vector2(ox + 0.5f, oy - 0.5f),
|
|
new Vector2(ox + 0.5f, oy + 0.5f), new Vector2(ox - 0.5f, oy + 0.5f),
|
|
});
|
|
|
|
[Fact]
|
|
public void Add_DropsSubGridDriftDuplicate()
|
|
{
|
|
var v = new CellView();
|
|
Assert.True(v.Add(Quad(0f, 0f)));
|
|
// Same quad, every vertex nudged 3e-4 — beyond the old 1e-4 SamePolygon eps,
|
|
// within the 1e-3 dedup grid. This is the per-round float drift that caused the hang.
|
|
var drifted = new ViewPolygon(new[]
|
|
{
|
|
new Vector2(-0.5f + 3e-4f, -0.5f - 3e-4f), new Vector2(0.5f + 3e-4f, -0.5f - 3e-4f),
|
|
new Vector2(0.5f + 3e-4f, 0.5f - 3e-4f), new Vector2(-0.5f + 3e-4f, 0.5f - 3e-4f),
|
|
});
|
|
Assert.False(v.Add(drifted));
|
|
Assert.Single(v.Polygons);
|
|
}
|
|
|
|
[Fact]
|
|
public void Add_DropsRotatedStartDuplicate()
|
|
{
|
|
var v = new CellView();
|
|
Assert.True(v.Add(Quad(0f, 0f)));
|
|
// Same 4 corners (same CCW cycle), but emitted starting at the 2nd vertex — what
|
|
// Sutherland-Hodgman can do when the subject order differs across rounds.
|
|
var rotated = new ViewPolygon(new[]
|
|
{
|
|
new Vector2(0.5f, -0.5f), new Vector2(0.5f, 0.5f),
|
|
new Vector2(-0.5f, 0.5f), new Vector2(-0.5f, -0.5f),
|
|
});
|
|
Assert.False(v.Add(rotated));
|
|
Assert.Single(v.Polygons);
|
|
}
|
|
|
|
[Fact]
|
|
public void Add_KeepsGenuinelyDistinctPolygons()
|
|
{
|
|
// The fix must NOT over-merge: two regions 0.4 NDC apart (far beyond the 1e-3 grid)
|
|
// remain distinct, so a real second portal opening is not silently dropped.
|
|
var v = new CellView();
|
|
Assert.True(v.Add(Quad(0f, 0f)));
|
|
Assert.True(v.Add(Quad(0.4f, 0f)));
|
|
Assert.Equal(2, v.Polygons.Count);
|
|
}
|
|
}
|