fix(app): Phase A.1 — separate Visible from Resident in StreamingRegion
Review follow-up from commit 11df793. Three fixes:
1. Visible semantics: StreamingRegion.Visible now strictly describes the
current (2r+1)×(2r+1) window, not window + hysteresis retainees.
Added a parallel Resident property exposing the actual loaded set
(window + hysteresis buffer). This matters because StreamingController
(next task) reads these to decide what to render vs what to unload;
conflating them in one set would have forced awkward post-processing
downstream.
2. Doc/code disagreement: updated the RecenterTo and RegionDiff doc
comments from "radius + 1" to "radius + 2" to match the actual
implementation (which is what the tests require). Also updated the
plan doc so future readers don't hit the same contradiction.
3. Edge-clamping test coverage: added a single-axis edge test
(cx=0, cy=50 → 15 entries) and an ID-encoding test (radius=0 at
0x12,0x34 → 0x1234FFFE) so a swapped-shift bug in EncodeLandblockId
or an asymmetric off-by-one would fail a test instead of passing
silently.
9 tests green, full suite regressions-free.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
11df7930fc
commit
449c2caf8b
3 changed files with 67 additions and 29 deletions
|
|
@ -82,4 +82,27 @@ public class StreamingRegionTests
|
|||
Assert.Equal(25, diff.ToLoad.Count);
|
||||
Assert.Equal(25, diff.ToUnload.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NearXEdgeOnly_ClampsOnlyXAxis()
|
||||
{
|
||||
// cx=0, cy=50, radius=2:
|
||||
// X is clamped to [0..2] (3 entries)
|
||||
// Y is unclamped [48..52] (5 entries)
|
||||
// Total = 3 × 5 = 15 landblocks.
|
||||
var region = new StreamingRegion(cx: 0, cy: 50, radius: 2);
|
||||
|
||||
Assert.Equal(15, region.Visible.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_SmallRadius_IDsMatchEncodingRule()
|
||||
{
|
||||
// Verify EncodeLandblockId is correct (not swapped shifts).
|
||||
// radius=0 at (0x12, 0x34) → exactly one entry, id = 0x1234FFFE.
|
||||
var region = new StreamingRegion(cx: 0x12, cy: 0x34, radius: 0);
|
||||
|
||||
Assert.Single(region.Visible);
|
||||
Assert.Contains(0x1234FFFEu, region.Visible);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue