diff options
Diffstat (limited to 'src/main/java/makamys/neodymium')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java | 9 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/Mesh.java | 1 |
2 files changed, 9 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) { diff --git a/src/main/java/makamys/neodymium/renderer/Mesh.java b/src/main/java/makamys/neodymium/renderer/Mesh.java index 6d302f5..61d4222 100644 --- a/src/main/java/makamys/neodymium/renderer/Mesh.java +++ b/src/main/java/makamys/neodymium/renderer/Mesh.java @@ -16,6 +16,7 @@ public abstract class Mesh { public int offset = -1; public int pass; int x, y, z; + public QuadNormal normal; public abstract int getStride(); |