45 lines
945 B
C#
45 lines
945 B
C#
using OpenTK.Graphics.OpenGL4;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Voxel
|
|
{
|
|
public class ChunkMesh
|
|
{
|
|
public int X;
|
|
public int Y;
|
|
private byte[] _packedData;
|
|
public bool NeedsUpdate = false;
|
|
public int Size = 0;
|
|
private List<FaceData> _faces;
|
|
|
|
public ChunkMesh(int x, int y)
|
|
{
|
|
_packedData = new byte[0];
|
|
X = x;
|
|
Y = y;
|
|
}
|
|
|
|
public void SetFaces(List<FaceData> faces)
|
|
{
|
|
Size = faces.Count;
|
|
_faces = faces;
|
|
NeedsUpdate = true;
|
|
}
|
|
|
|
public byte[] GetPackedData()
|
|
{
|
|
if (NeedsUpdate)
|
|
{
|
|
_packedData = _faces.SelectMany(f => f.Pack()).ToArray();
|
|
}
|
|
|
|
return _packedData;
|
|
}
|
|
}
|
|
}
|