Files
VoxelEngine/World/Chunk/Chunk.cs
MDietermann 49d35cab5b feat: add multi-chunk world with cross-chunk face culling
Add a World that stores chunks in a Dictionary keyed by chunk
coordinate, with floor-division world<->chunk coordinate mapping
(correct for negative coords). The mesher takes an optional neighbor
sampler so faces at chunk borders are culled against adjacent chunks
instead of always meshing the shell. Render one ChunkRenderer per
chunk, placed via the model matrix. Reorganize the World layer into
Blocks/ and Chunk/ sub-namespaces.
2026-05-28 15:32:45 +02:00

20 lines
593 B
C#

namespace VoxelEngine.World.Chunk;
public sealed class Chunk
{
public const int Size = 16;
private readonly ushort[] _ids = new ushort[Chunk.Size * Chunk.Size * Chunk.Size];
public ushort this[int x, int y, int z]
{
get => this._ids[Chunk.Index(x, y, z)];
set => this._ids[Chunk.Index(x, y, z)] = value;
}
public static bool InBounds(int x, int y, int z) =>
x is >= 0 and < Chunk.Size && y is >= 0 and < Chunk.Size && z is >= 0 and < Chunk.Size;
private static int Index(int x, int y, int z) => (x * Chunk.Size + y) * Chunk.Size + z;
}