test(A.5 T3): StreamingRegion two-radius constructor

Add NearRadius/FarRadius properties and a four-arg constructor
(centerX, centerY, nearRadius, farRadius). Radius is set to farRadius
so existing hysteresis math (unload threshold = Radius+2) uses the
outer ring as the bookkeeping boundary. Old three-arg constructor
becomes a thin wrapper: this(cx, cy, radius, radius) — no behaviour
change, 25 pre-existing streaming tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-09 22:27:50 +02:00
parent 21550ecff2
commit 7fd9c82954
2 changed files with 30 additions and 6 deletions

View file

@ -13,6 +13,8 @@ public sealed class StreamingRegion
public int CenterX { get; private set; } public int CenterX { get; private set; }
public int CenterY { get; private set; } public int CenterY { get; private set; }
public int Radius { get; } public int Radius { get; }
public int NearRadius { get; }
public int FarRadius { get; }
// Strictly the (2r+1)×(2r+1) window (clamped to world bounds). // Strictly the (2r+1)×(2r+1) window (clamped to world bounds).
private readonly HashSet<uint> _visible = new(); private readonly HashSet<uint> _visible = new();
@ -43,12 +45,16 @@ public sealed class StreamingRegion
/// </summary> /// </summary>
public IReadOnlyCollection<uint> Resident => _resident; public IReadOnlyCollection<uint> Resident => _resident;
public StreamingRegion(int cx, int cy, int radius) public StreamingRegion(int centerX, int centerY, int nearRadius, int farRadius)
{ {
Radius = radius; NearRadius = nearRadius;
Recenter(cx, cy); FarRadius = farRadius;
Radius = farRadius; // outer ring drives Resident bookkeeping
Recenter(centerX, centerY);
} }
public StreamingRegion(int cx, int cy, int radius) : this(cx, cy, radius, radius) { }
private void Recenter(int cx, int cy) private void Recenter(int cx, int cy)
{ {
CenterX = cx; CenterX = cx;

View file

@ -0,0 +1,18 @@
using AcDream.App.Streaming;
using Xunit;
namespace AcDream.Core.Tests.Streaming;
public class StreamingRegionTwoTierTests
{
[Fact]
public void Constructor_TwoRadii_ExposesNearAndFarRadii()
{
var region = new StreamingRegion(centerX: 100, centerY: 100, nearRadius: 4, farRadius: 12);
Assert.Equal(4, region.NearRadius);
Assert.Equal(12, region.FarRadius);
Assert.Equal(100, region.CenterX);
Assert.Equal(100, region.CenterY);
}
}