diff options
author | makamys <makamys@outlook.com> | 2022-06-21 00:31:13 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-21 02:42:33 +0200 |
commit | c2e64488dadcee9a69335042b9dccec7460af4b9 (patch) | |
tree | 0e32f27277f99a8208682da625d525031032b1f7 /src/main/java | |
parent | 762db36a9a06b58a2e7a6315ac9368b4d456881f (diff) | |
download | Neodymium-c2e64488dadcee9a69335042b9dccec7460af4b9.tar.gz Neodymium-c2e64488dadcee9a69335042b9dccec7460af4b9.tar.bz2 Neodymium-c2e64488dadcee9a69335042b9dccec7460af4b9.zip |
Finish CullableMeshCollection
Diffstat (limited to 'src/main/java')
-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(); |