chunk meshes
This commit is contained in:
17
Chunk.cs
17
Chunk.cs
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user