This commit is contained in:
maxwes08
2025-09-09 10:57:28 +02:00
parent 3678eaa5f8
commit b6655d71d9
6 changed files with 148 additions and 81 deletions

View File

@@ -1,4 +1,5 @@
using System;
using OpenTK.Graphics.OpenGL4;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,22 +11,36 @@ namespace Voxel
{
public int X;
public int Y;
public byte[] PackedData;
public bool NeedsUpdate = true;
private byte[] _packedData;
public bool NeedsUpdate = false;
public int Length = 0;
private List<FaceData> _faces;
public int SSBO;
public ChunkMesh(int x, int y)
{
PackedData = new byte[0];
_packedData = new byte[0];
X = x;
Y = y;
SSBO = GL.GenBuffer();
}
public void SetFaces(List<FaceData> faces)
{
Length = faces.Count;
PackedData = faces.SelectMany(f => f.Pack()).ToArray();
_faces = faces;
NeedsUpdate = true;
}
public byte[] GetPackedData()
{
if (NeedsUpdate)
{
_packedData = _faces.SelectMany(f => f.Pack()).ToArray();
NeedsUpdate = false;
}
return _packedData;
}
}
}