fix(streaming): load water-surface chunks over submerged columns
This commit is contained in:
@@ -175,8 +175,9 @@ public sealed class ChunkStreamer : IDisposable
|
||||
// Fills `into` with the chunk positions to load for a viewer at chunk
|
||||
// `center`, over a square horizontal region of Chebyshev radius `radiusH`.
|
||||
// Per column the full vertical stack from bedrock (cy 0) up to the
|
||||
// surface-top chunk is loaded, plus any section above the surface holding
|
||||
// player edits (e.g. a built tower).
|
||||
// surface-top chunk (clamped up to the sea-level chunk so submerged columns
|
||||
// load their opaque-water surface) is loaded, plus any section above that
|
||||
// holding player edits (e.g. a built tower).
|
||||
private void CollectTargets(Vector3i center, int radiusH, HashSet<Vector3i> into)
|
||||
{
|
||||
for (int dx = -radiusH; dx <= radiusH; dx++)
|
||||
@@ -185,7 +186,13 @@ public sealed class ChunkStreamer : IDisposable
|
||||
int cx = center.X + dx;
|
||||
int cz = center.Z + dz;
|
||||
|
||||
int surfaceTop = ChunkMath.FloorDiv(this.SurfaceTopHeight(cx, cz), VoxelChunk.Size);
|
||||
// Clamp the column top up to at least the sea-level chunk: where the
|
||||
// terrain surface is below sea level, WorldGenerator fills opaque water
|
||||
// from the surface up to SeaLevel, so the column must load through the
|
||||
// waterline or the submerged water surface renders as see-through holes.
|
||||
int surfaceTop = Math.Max(
|
||||
ChunkMath.FloorDiv(this.SurfaceTopHeight(cx, cz), VoxelChunk.Size),
|
||||
ChunkMath.FloorDiv(WorldConstants.SeaLevel, VoxelChunk.Size));
|
||||
ChunkStreamer.AddColumn(into, cx, cz, 0, surfaceTop);
|
||||
|
||||
int clampedTop = Math.Min(WorldConstants.WorldHeightChunks - 1, surfaceTop);
|
||||
|
||||
Reference in New Issue
Block a user