diff options
author | makamys <makamys@outlook.com> | 2022-06-23 00:38:57 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-23 00:38:57 +0200 |
commit | 3dde44fb2dfc432e9db050956e3598ec403edd16 (patch) | |
tree | 36317fdfea0a49124dbbf87784ffbe1897dfca2b /src/main/java/makamys | |
parent | 36f202c3e3863f19644cbe7044c921c9f541d575 (diff) | |
download | Neodymium-3dde44fb2dfc432e9db050956e3598ec403edd16.tar.gz Neodymium-3dde44fb2dfc432e9db050956e3598ec403edd16.tar.bz2 Neodymium-3dde44fb2dfc432e9db050956e3598ec403edd16.zip |
Remove CullableMeshCollection
Diffstat (limited to 'src/main/java/makamys')
6 files changed, 19 insertions, 91 deletions
diff --git a/src/main/java/makamys/neodymium/ducks/IWorldRenderer.java b/src/main/java/makamys/neodymium/ducks/IWorldRenderer.java index 0652984..3c3d7a8 100644 --- a/src/main/java/makamys/neodymium/ducks/IWorldRenderer.java +++ b/src/main/java/makamys/neodymium/ducks/IWorldRenderer.java @@ -2,9 +2,9 @@ package makamys.neodymium.ducks; import java.util.List; -import makamys.neodymium.renderer.CullableMeshCollection; +import makamys.neodymium.renderer.ChunkMesh; public interface IWorldRenderer { - public List<CullableMeshCollection> getChunkMeshes(); + public List<ChunkMesh> getChunkMeshes(); public boolean isDrawn(); } diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java index 3901a7a..997ac67 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java @@ -15,7 +15,6 @@ import makamys.neodymium.Config; import makamys.neodymium.Neodymium; import makamys.neodymium.ducks.IWorldRenderer; import makamys.neodymium.renderer.ChunkMesh; -import makamys.neodymium.renderer.CullableMeshCollection; import makamys.neodymium.renderer.NeoRenderer; import makamys.neodymium.renderer.lod.FarChunkCache; import makamys.neodymium.renderer.lod.FarWorldRenderer; @@ -51,7 +50,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { boolean savedDrawnStatus; private boolean insideUpdateRenderer; - public List<CullableMeshCollection> chunkMeshes; + public List<ChunkMesh> chunkMeshes; @Redirect(method = "setPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderAABB(Lnet/minecraft/util/AxisAlignedBB;)V")) private void redirectRenderAABB(AxisAlignedBB p1) { @@ -153,7 +152,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { } @Override - public List<CullableMeshCollection> getChunkMeshes() { + public List<ChunkMesh> getChunkMeshes() { return chunkMeshes; } diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java index 8aedc4d..f2482ef 100644 --- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java +++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java @@ -72,7 +72,7 @@ public class ChunkMesh extends Mesh { private static int totalOriginalQuadCount = 0; private static int totalSimplifiedQuadCount = 0; - public static CullableMeshCollection fromTessellator(int pass, WorldRenderer wr, Tessellator t) { + public static ChunkMesh fromTessellator(int pass, WorldRenderer wr, Tessellator t) { if(t.vertexCount % 4 != 0) { System.out.println("Error: Vertex count is not a multiple of 4"); return null; @@ -132,7 +132,7 @@ public class ChunkMesh extends Mesh { //System.out.println("simplified quads " + totalOriginalQuadCount + " -> " + totalSimplifiedQuadCount + " (ratio: " + ((float)totalSimplifiedQuadCount / (float)totalOriginalQuadCount) + ") totalMergeCountByPlane: " + Arrays.toString(totalMergeCountByPlane)); if(quadCount > 0) { - return new CullableMeshCollection( + return new ChunkMesh( (int)(xOffset / 16), (int)(yOffset / 16), (int)(zOffset / 16), new ChunkMesh.Flags(t.hasTexture, t.hasBrightness, t.hasColor, t.hasNormals), quadCount, quads, pass); @@ -296,7 +296,7 @@ public class ChunkMesh extends Mesh { //Tessellator.endSave(); } - static List<CullableMeshCollection> getChunkMesh(int theX, int theY, int theZ) { + static List<ChunkMesh> getChunkMesh(int theX, int theY, int theZ) { WorldRenderer wr = new WorldRenderer(Minecraft.getMinecraft().theWorld, new ArrayList<TileEntity>(), theX * 16, theY * 16, theZ * 16, 100000); wr.isWaitingOnOcclusionQuery = false; diff --git a/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java b/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java deleted file mode 100644 index cdc31a6..0000000 --- a/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java +++ /dev/null @@ -1,53 +0,0 @@ -package makamys.neodymium.renderer; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import makamys.neodymium.Config; -import makamys.neodymium.renderer.ChunkMesh.Flags; - -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) { - if(Config.cullFaces) { - 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; - } - } - } else { - putMeshWithNormal(QuadNormal.NONE, new ChunkMesh(x, y, z, flags, quadCount, quads, pass)); - } - } - - public ChunkMesh getMeshWithNormal(QuadNormal normal) { - return meshes[normal.ordinal()]; - } - - public void putMeshWithNormal(QuadNormal normal, ChunkMesh mesh) { - meshes[normal.ordinal()] = mesh; - } - - public List<ChunkMesh> getMeshes() { - return Arrays.asList(meshes); - } - - public void destroy() { - for(ChunkMesh mesh : meshes) { - if(mesh != null) mesh.destroy(); - } - } - - public boolean isVisible() { - for(ChunkMesh mesh : meshes) { - if(mesh != null && mesh.visible) return true; - } - return false; - } - -} diff --git a/src/main/java/makamys/neodymium/renderer/NeoChunk.java b/src/main/java/makamys/neodymium/renderer/NeoChunk.java index 2adc7ef..72957e0 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoChunk.java +++ b/src/main/java/makamys/neodymium/renderer/NeoChunk.java @@ -18,7 +18,7 @@ public class NeoChunk { boolean discardedMesh; SimpleChunkMesh[] simpleMeshes = new SimpleChunkMesh[2]; - CullableMeshCollection[] chunkMeshes = new CullableMeshCollection[32]; + ChunkMesh[] chunkMeshes = new ChunkMesh[32]; public boolean[] isSectionVisible = new boolean[16]; @@ -56,17 +56,15 @@ public class NeoChunk { return Math.pow(entity.posX - x * 16, 2) + Math.pow(entity.posZ - z * 16, 2); } - public void putChunkMeshes(int cy, List<CullableMeshCollection> newChunkMeshes) { + public void putChunkMeshes(int cy, List<ChunkMesh> newChunkMeshes) { for(int i = 0; i < 2; i++) { - CullableMeshCollection newChunkMesh = newChunkMeshes.size() > i ? newChunkMeshes.get(i) : null; + ChunkMesh newChunkMesh = newChunkMeshes.size() > i ? newChunkMeshes.get(i) : null; if(chunkMeshes[cy * 2 + i] != null) { if(newChunkMesh != null) { // ??? why is this needed? - for(ChunkMesh mesh : newChunkMesh.getMeshes()) { - if(mesh != null) { - mesh.pass = i; - } - } + if(newChunkMesh != null) { + newChunkMesh.pass = i; + } } renderer.removeMesh(chunkMeshes[cy * 2 + i]); @@ -97,7 +95,7 @@ public class NeoChunk { } public boolean hasChunkMeshes() { - for(CullableMeshCollection cm : chunkMeshes) { + for(ChunkMesh cm : chunkMeshes) { if(cm != null) { return true; } @@ -161,7 +159,7 @@ public class NeoChunk { scm.destroy(); } } - for(CullableMeshCollection cm: chunkMeshes) { + for(ChunkMesh cm: chunkMeshes) { if(cm != null) { cm.destroy(); } @@ -191,7 +189,7 @@ public class NeoChunk { return false; } } - for(CullableMeshCollection cm: chunkMeshes) { + for(ChunkMesh cm: chunkMeshes) { if(cm != null) { return false; } diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 3e1abe5..2a18950 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -638,14 +638,14 @@ public class NeoRenderer { } for(int y = 0; y < 16; y++) { for(int pass = 0; pass < 2; pass++) { - CullableMeshCollection cm = lodChunk.chunkMeshes[y * 2 + pass]; + ChunkMesh cm = lodChunk.chunkMeshes[y * 2 + pass]; if(cm != null) { if(lodChunk.isSectionVisible[y] && newLOD == 2) { - if(!cm.isVisible()) { + if(!cm.visible) { setMeshVisible(cm, true); } } else { - if(cm.isVisible()) { + if(cm.visible) { setMeshVisible(cm, false); } } @@ -654,14 +654,6 @@ public class NeoRenderer { } } - protected void setMeshVisible(CullableMeshCollection cm, boolean visible) { - if(cm == null) return; - - for(ChunkMesh mesh : cm.getMeshes()) { - if(mesh != null) setMeshVisible(mesh, visible); - } - } - protected void setMeshVisible(Mesh mesh, boolean visible) { setMeshVisible(mesh, visible, false); } @@ -687,14 +679,6 @@ public class NeoRenderer { setMeshVisible(mesh, false); } - public void removeMesh(CullableMeshCollection cm) { - if(cm == null) return; - - for(Mesh mesh : cm.getMeshes()) { - if(mesh != null) removeMesh(mesh); - } - } - public Chunk getChunkFromChunkCoords(int x, int z) { for(Chunk chunk : myChunks) { if(chunk.xPosition == x && chunk.zPosition == z) { |