feat: weight vertical distance in chunk-load priority
Adds Configuration.VerticalPriorityWeight (default 4). The priority formula in ChunkStreamer.RecomputeTargetSet now uses dx^2 + dz^2 + dy^2 * VerticalPriorityWeight, so horizontal chunks at the player's Y are dispatched before equally-distant chunks above or below. Fixes janky loading where deep-underground chunks were competing with surface chunks for early dispatch slots.
This commit is contained in:
@@ -351,4 +351,33 @@ public class ChunkStreamerTests
|
||||
streamer.Tick(new Vector3i(0, 0, 0));
|
||||
Assert.Equal(1, generateCalls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tick_VerticalPriorityWeight_PrefersHorizontalAtSameDistance()
|
||||
{
|
||||
var cfg = new Configuration
|
||||
{
|
||||
RenderDistanceHorizontal = 1,
|
||||
RenderDistanceVertical = 1,
|
||||
MaxGenerateJobsInFlight = 100,
|
||||
MaxMeshUploadsPerFrame = 5, // player's chunk + 4 horizontal cardinals
|
||||
VerticalPriorityWeight = 4,
|
||||
};
|
||||
var (streamer, world, _) = CreateStreamer(cfg);
|
||||
|
||||
// Player chunk at Y=2 so vertical neighbors Y=1 and Y=3 are valid.
|
||||
var playerPos = new Vector3i(0, 2, 0);
|
||||
streamer.Tick(playerPos);
|
||||
|
||||
// Drain budget = 5 = priority 0 (player) + 4 priority-1 (horizontal
|
||||
// cardinals). With VerticalPriorityWeight=4, vertical cardinals
|
||||
// (Y=1, Y=3) have priority 4 — they should NOT be among the first 5.
|
||||
Assert.NotNull(world.GetChunk(playerPos));
|
||||
Assert.NotNull(world.GetChunk(new Vector3i( 1, 2, 0)));
|
||||
Assert.NotNull(world.GetChunk(new Vector3i(-1, 2, 0)));
|
||||
Assert.NotNull(world.GetChunk(new Vector3i( 0, 2, 1)));
|
||||
Assert.NotNull(world.GetChunk(new Vector3i( 0, 2, -1)));
|
||||
Assert.Null(world.GetChunk(new Vector3i(0, 3, 0)));
|
||||
Assert.Null(world.GetChunk(new Vector3i(0, 1, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user