perf(vfx): port retail particle visibility degradation

Resolve DAT-authored particle ranges from the hardware GfxObj, apply retail distance and completed-cell visibility gates, and preserve the exact finite/infinite off-view update semantics. This removes dense-world simulation work without shortening terrain, entity, fog, or streaming distance.

Publish doorway-clipped outdoor cells through a focused frame controller, retain effect cell identity for outdoor statics, reject hidden emitters before particle-slot scans, and offer an explicit opt-in Extended particle range.

Release build succeeds and all 5,857 tests pass with five intentional skips. Retail-conformance, architecture, and adversarial review cycles are clean; connected Aerlinthe visual/performance gate pending.

Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-17 15:27:36 +02:00
parent 82789eea88
commit f1ba147ac5
29 changed files with 1810 additions and 125 deletions

View file

@ -0,0 +1,119 @@
using System.Numerics;
using AcDream.App.Rendering;
namespace AcDream.App.Tests.Rendering;
public sealed class TerrainParticleCellVisibilityTests
{
[Fact]
public void CollectVisibleCells_PublishesLandscapeCellsWithoutEntitySurvivors()
{
var cells = new HashSet<uint>();
TerrainModernRenderer.CollectVisibleCells(
cells,
0xA9B4FFFFu,
Vector3.Zero,
zMin: 0f,
zMax: 20f,
frustum: null,
Matrix4x4.Identity,
ReadOnlySpan<Vector4>.Empty);
Assert.Equal(64, cells.Count);
Assert.Contains(0xA9B40001u, cells);
Assert.Contains(0xA9B40040u, cells);
}
[Fact]
public void CollectVisibleCells_ForceDrawnParentStillUsesCellFrustum()
{
var cells = new HashSet<uint>();
FrustumPlanes frustum = FrustumPlanes.FromViewProjection(Matrix4x4.Identity);
// The parent landblock may have entered TerrainModernRenderer's draw
// list through neverCullLandblockId. The cell collector deliberately
// receives no such bypass and still rejects its off-frustum cells.
TerrainModernRenderer.CollectVisibleCells(
cells,
0xA9B4FFFFu,
new Vector3(100f, 100f, 100f),
zMin: 100f,
zMax: 120f,
frustum,
Matrix4x4.Identity,
ReadOnlySpan<Vector4>.Empty);
Assert.Empty(cells);
}
[Fact]
public void CollectVisibleCells_RejectsCellsOutsideDoorwayClipPlanes()
{
var cells = new HashSet<uint>();
var planes = new[] { new Vector4(-1f, 0f, 0f, -2f) };
TerrainModernRenderer.CollectVisibleCells(
cells,
0xA9B4FFFFu,
Vector3.Zero,
zMin: 0f,
zMax: 20f,
frustum: null,
Matrix4x4.Identity,
planes);
Assert.Empty(cells);
}
[Fact]
public void CollectVisibleCells_RejectsCellsOutsideDoorwayScissorAabb()
{
var cells = new HashSet<uint>();
TerrainModernRenderer.CollectVisibleCells(
cells,
0xA9B4FFFFu,
Vector3.Zero,
zMin: 0f,
zMax: 20f,
frustum: null,
Matrix4x4.Identity,
ReadOnlySpan<Vector4>.Empty,
ndcClipAabb: new Vector4(-4f, -4f, -2f, -2f));
Assert.Empty(cells);
}
[Fact]
public void CollectVisibleCells_UnionsCellsFromEveryLandscapeSlice()
{
var cells = new HashSet<uint>();
TerrainModernRenderer.CollectVisibleCells(
cells,
0xA9B4FFFFu,
Vector3.Zero,
zMin: 0f,
zMax: 20f,
frustum: null,
Matrix4x4.Identity,
ReadOnlySpan<Vector4>.Empty,
ndcClipAabb: new Vector4(1f, -1_000f, 23f, 1_000f));
TerrainModernRenderer.CollectVisibleCells(
cells,
0xA9B4FFFFu,
Vector3.Zero,
zMin: 0f,
zMax: 20f,
frustum: null,
Matrix4x4.Identity,
ReadOnlySpan<Vector4>.Empty,
ndcClipAabb: new Vector4(49f, -1_000f, 71f, 1_000f));
Assert.Equal(16, cells.Count);
Assert.Contains(0xA9B40001u, cells);
Assert.Contains(0xA9B40011u, cells);
Assert.DoesNotContain(0xA9B40009u, cells);
}
}