test: pin chunk mesher vertex layout with exact float count
This commit is contained in:
@@ -5,7 +5,9 @@ namespace VoxelEngine.Tests;
|
||||
|
||||
public class ChunkMesherTests
|
||||
{
|
||||
private const int FloatsPerFace = 36; // 6 verts * 6 floats
|
||||
private const int FloatsPerVertex = 6; // pos.xyz, uv, shade
|
||||
private const int VerticesPerFace = 6; // quad = 2 triangles
|
||||
private const int FloatsPerFace = FloatsPerVertex * VerticesPerFace; // 36
|
||||
|
||||
private static int FaceCount(float[] mesh) => mesh.Length / FloatsPerFace;
|
||||
|
||||
@@ -43,13 +45,15 @@ public class ChunkMesherTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EveryVertexHasSixFloats()
|
||||
public void SingleBlock_EmitsExactInterleavedFloatCount()
|
||||
{
|
||||
var chunk = new Chunk();
|
||||
chunk[0, 0, 0] = 1;
|
||||
chunk[0, 0, 0] = 1; // corner block: all 6 neighbors are air/out-of-bounds -> 6 faces
|
||||
|
||||
var mesh = new ChunkMesher().Build(chunk, new BlockRegistry());
|
||||
|
||||
Assert.Equal(0, mesh.Length % 6);
|
||||
// Pins the layout: 6 faces * 6 vertices/face * 6 floats/vertex.
|
||||
Assert.Equal(6 * VerticesPerFace * FloatsPerVertex, mesh.Length);
|
||||
Assert.Equal(0, mesh.Length % FloatsPerVertex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user