diff options
Diffstat (limited to 'src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java b/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java index 034c3bb..9c039b4 100644 --- a/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java +++ b/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java @@ -2,6 +2,7 @@ package makamys.neodymium.renderer; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; import makamys.neodymium.renderer.ChunkMesh.Flags; @@ -10,7 +11,13 @@ public class CullableMeshCollection { private ChunkMesh[] meshes = new ChunkMesh[QuadNormal.values().length]; public CullableMeshCollection(int x, int y, int z, Flags flags, int quadCount, List<MeshQuad> quads, int pass) { - putMeshWithNormal(QuadNormal.NONE, new ChunkMesh(x, y, z, flags, quadCount, quads, pass)); + for(QuadNormal normal : QuadNormal.values()) { + List<MeshQuad> normalQuads = quads.stream().filter(q -> MeshQuad.isValid(q) && q.normal == normal).collect(Collectors.toList()); + if(!normalQuads.isEmpty()) { + putMeshWithNormal(normal, new ChunkMesh(x, y, z, flags, normalQuads.size(), normalQuads, pass)); + getMeshWithNormal(normal).normal = normal; + } + } } public ChunkMesh getMeshWithNormal(QuadNormal normal) { |