update
This commit is contained in:
25
ChunkMesh.cs
25
ChunkMesh.cs
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user