chunk meshes

This commit is contained in:
maxwes08
2025-09-03 15:08:21 +02:00
parent 94ebc4ace4
commit 3678eaa5f8
8 changed files with 69 additions and 41 deletions

View File

@@ -4,16 +4,16 @@
{
public static int Size = 16;
public static int Height = 256;
public readonly int PositionX;
public readonly int PositionY;
public readonly int X;
public readonly int Y;
private Dictionary<ushort, BlockData> _blockData;
private Blocks[] _blocks;
public Chunk(int positionX, int positionY)
public Chunk(int x, int y)
{
PositionX = positionX;
PositionY = positionY;
X = x;
Y = y;
_blockData = new Dictionary<ushort, BlockData>();
_blocks = new Blocks[Size * Size * Height];
@@ -84,7 +84,8 @@
public ChunkMesh GetChunkMesh()
{
ChunkMesh chunkMesh = new ChunkMesh(Size * Size * Height / 2);
ChunkMesh chunkMesh = new ChunkMesh(X, Y);
List<FaceData> faces = new List<FaceData>(Size * Size * Height / 2);
// offsets table
@@ -121,12 +122,14 @@
faceData.Y = (byte)y;
faceData.Z = (byte)z;
chunkMesh.Faces.Add(faceData);
faces.Add(faceData);
}
}
}
}
chunkMesh.SetFaces(faces);
return chunkMesh;
}
}