test(render): Phase W Stage 4/5 — assembler OutsideView AABB + PView BFS + entity-clip tests
ClipFrameAssemblerTests (3 new): - Assemble_OutsideViewWithExitPortal_HasOutsideViewTrue_AabbMatchesBounds - Assemble_OutsideViewMultiPolygon_ScissorMode_HasOutsideViewTrue_AabbValid - Assemble_EmptyOutsideView_HasOutsideViewFalse_AabbZero PortalVisibilityBuilderTests (3 new): - Build_ExitPortalVisible_OutsideViewNonEmpty - Build_NoExitPortal_OutsideViewEmpty - Build_RootCellAlwaysFirstInOrderedVisibleCells EntityClipTests (new file, 5 tests): - EntityClip_ParentInVisibleSet_Included - EntityClip_ParentNotInVisibleSet_Excluded - EntityClip_NullVisibleSet_IncludesAll - EntityClip_NullParentCell_NullVisibleSet_Included - EntityClip_NullParentCell_NonNullVisibleSet_Included WbDrawDispatcher.EntityPassesVisibleCellGate changed private → internal static (AcDream.App already has InternalsVisibleTo AcDream.App.Tests; no new seam needed). 160 → 171 tests, all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ce2edad66a
commit
a8b831c23b
4 changed files with 231 additions and 1 deletions
|
|
@ -159,6 +159,80 @@ public class ClipFrameAssemblerTests
|
|||
Assert.Equal(TerrainClipMode.Planes, asm.TerrainMode);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Phase W Stage 4: HasOutsideView + OutsideViewNdcAabb
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
[Fact]
|
||||
public void Assemble_OutsideViewWithExitPortal_HasOutsideViewTrue_AabbMatchesBounds()
|
||||
{
|
||||
// A single convex quad in OutsideView reduces to Planes. HasOutsideView must
|
||||
// be true and OutsideViewNdcAabb must match the polygon's own Min/Max values.
|
||||
var pv = new PortalVisibilityFrame();
|
||||
var poly = Square(-0.3f, 0.2f, 0.25f);
|
||||
pv.OutsideView.Add(poly);
|
||||
// No interior cells needed for this assertion.
|
||||
|
||||
var frame = ClipFrame.NoClip();
|
||||
var asm = ClipFrameAssembler.Assemble(frame, pv);
|
||||
|
||||
Assert.True(asm.HasOutsideView);
|
||||
Assert.Equal(TerrainClipMode.Planes, asm.TerrainMode);
|
||||
|
||||
// The OutsideViewNdcAabb must equal the CellView's accumulated Min/Max.
|
||||
var expected = new System.Numerics.Vector4(
|
||||
pv.OutsideView.MinX, pv.OutsideView.MinY,
|
||||
pv.OutsideView.MaxX, pv.OutsideView.MaxY);
|
||||
Assert.Equal(expected, asm.OutsideViewNdcAabb);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Assemble_OutsideViewMultiPolygon_ScissorMode_HasOutsideViewTrue_AabbValid()
|
||||
{
|
||||
// Two polygons in OutsideView → union (non-convex) → ClipPlaneSet forces
|
||||
// scissor fallback. HasOutsideView must still be true, TerrainMode must be
|
||||
// Scissor, and OutsideViewNdcAabb must equal the union bounds (same values
|
||||
// as TerrainScissorNdcAabb in this mode).
|
||||
var pv = new PortalVisibilityFrame();
|
||||
pv.OutsideView.Add(Square(-0.6f, 0f, 0.15f));
|
||||
pv.OutsideView.Add(Square(0.6f, 0f, 0.15f));
|
||||
|
||||
var frame = ClipFrame.NoClip();
|
||||
var asm = ClipFrameAssembler.Assemble(frame, pv);
|
||||
|
||||
Assert.True(asm.HasOutsideView);
|
||||
Assert.Equal(TerrainClipMode.Scissor, asm.TerrainMode);
|
||||
|
||||
// Union bounds from the CellView (spans both squares).
|
||||
var expectedAabb = new System.Numerics.Vector4(
|
||||
pv.OutsideView.MinX, pv.OutsideView.MinY,
|
||||
pv.OutsideView.MaxX, pv.OutsideView.MaxY);
|
||||
Assert.Equal(expectedAabb, asm.OutsideViewNdcAabb);
|
||||
|
||||
// In Scissor mode OutsideViewNdcAabb and TerrainScissorNdcAabb are the same
|
||||
// value (both are the union CellView bounds).
|
||||
Assert.Equal(asm.TerrainScissorNdcAabb, asm.OutsideViewNdcAabb);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Assemble_EmptyOutsideView_HasOutsideViewFalse_AabbZero()
|
||||
{
|
||||
// An empty OutsideView means no exit portal was in view → TerrainMode.Skip,
|
||||
// HasOutsideView false, OutsideViewNdcAabb degenerate zero.
|
||||
const uint cellA = 0xA9B40100;
|
||||
var pv = new PortalVisibilityFrame();
|
||||
pv.CellViews[cellA] = ViewOf(Square(0f, 0f, 0.3f));
|
||||
pv.OrderedVisibleCells.Add(cellA);
|
||||
// OutsideView left empty (no exit portal).
|
||||
|
||||
var frame = ClipFrame.NoClip();
|
||||
var asm = ClipFrameAssembler.Assemble(frame, pv);
|
||||
|
||||
Assert.False(asm.HasOutsideView);
|
||||
Assert.Equal(TerrainClipMode.Skip, asm.TerrainMode);
|
||||
Assert.Equal(System.Numerics.Vector4.Zero, asm.OutsideViewNdcAabb);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reset_ReusesFrame_NoSlotLeakAcrossAssemblies()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue