feat(A.5 T13): StreamingController two-tier Tick
Replaces the single-radius Tick with a two-tier model that consumes StreamingRegion's TwoTierDiff (5-list) and routes to the appropriate JobKind: - ToLoadFar -> _enqueueLoad(id, LoadFar) - ToLoadNear -> _enqueueLoad(id, LoadNear) - ToPromote -> _enqueueLoad(id, PromoteToNear) - ToDemote -> _state.RemoveEntitiesFromLandblock(id) on render thread - ToUnload -> _enqueueUnload(id) Drain switch handles Loaded (terrain + entity layer), Promoted (entity layer only -- terrain already loaded), Unloaded, Failed, WorkerCrashed. Constructor signature: nearRadius/farRadius separate ints. Old single- radius ctor removed; existing single-radius tests updated to pass nearRadius=farRadius for backward-compat coverage. GameWindow's enqueueLoad lambda updated from (id =>...) to (id, kind) => to match new Action<uint, LandblockStreamJobKind> signature; radius: arg renamed to nearRadius:/farRadius: (both set to _streamingRadius until T16 wires the full two-tier env-var parsing). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
aff35d2a76
commit
b8d80fe282
4 changed files with 79 additions and 29 deletions
|
|
@ -14,7 +14,7 @@ public class StreamingControllerTests
|
|||
public List<uint> Unloads { get; } = new();
|
||||
public Queue<LandblockStreamResult> Pending { get; } = new();
|
||||
|
||||
public void EnqueueLoad(uint id) => Loads.Add(id);
|
||||
public void EnqueueLoad(uint id, LandblockStreamJobKind _) => Loads.Add(id);
|
||||
public void EnqueueUnload(uint id) => Unloads.Add(id);
|
||||
public IReadOnlyList<LandblockStreamResult> DrainCompletions(int max)
|
||||
{
|
||||
|
|
@ -36,12 +36,13 @@ public class StreamingControllerTests
|
|||
drainCompletions: fake.DrainCompletions,
|
||||
applyTerrain: (_, _) => { },
|
||||
state: state,
|
||||
radius: 2);
|
||||
nearRadius: 2,
|
||||
farRadius: 2);
|
||||
|
||||
// Center at (50, 50); no landblocks loaded yet.
|
||||
controller.Tick(observerCx: 50, observerCy: 50);
|
||||
|
||||
// 5×5 window = 25 loads enqueued, 0 unloads.
|
||||
// 5×5 window = 25 loads enqueued (nearRadius==farRadius so all go to ToLoadNear), 0 unloads.
|
||||
Assert.Equal(25, fake.Loads.Count);
|
||||
Assert.Empty(fake.Unloads);
|
||||
}
|
||||
|
|
@ -53,7 +54,7 @@ public class StreamingControllerTests
|
|||
var fake = new FakeStreamer();
|
||||
var controller = new StreamingController(
|
||||
fake.EnqueueLoad, fake.EnqueueUnload, fake.DrainCompletions,
|
||||
(_, _) => { }, state, radius: 2);
|
||||
(_, _) => { }, state, nearRadius: 2, farRadius: 2);
|
||||
|
||||
controller.Tick(50, 50);
|
||||
fake.Loads.Clear();
|
||||
|
|
@ -72,7 +73,7 @@ public class StreamingControllerTests
|
|||
var applied = new List<LoadedLandblock>();
|
||||
var controller = new StreamingController(
|
||||
fake.EnqueueLoad, fake.EnqueueUnload, fake.DrainCompletions,
|
||||
(lb, _) => applied.Add(lb), state, radius: 2);
|
||||
(lb, _) => applied.Add(lb), state, nearRadius: 2, farRadius: 2);
|
||||
|
||||
// Note: LoadedLandblock's actual fields are LandblockId, Heightmap,
|
||||
// Entities (positional record). Adjust if the first positional arg
|
||||
|
|
@ -99,7 +100,7 @@ public class StreamingControllerTests
|
|||
var fake = new FakeStreamer();
|
||||
var controller = new StreamingController(
|
||||
fake.EnqueueLoad, fake.EnqueueUnload, fake.DrainCompletions,
|
||||
(_, _) => { }, state, radius: 2);
|
||||
(_, _) => { }, state, nearRadius: 2, farRadius: 2);
|
||||
|
||||
var lb = new LoadedLandblock(0x32320FFEu, new LandBlock(), System.Array.Empty<WorldEntity>());
|
||||
state.AddLandblock(lb);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue