diff options
author | makamys <makamys@outlook.com> | 2021-05-10 17:56:57 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-10 17:57:26 +0200 |
commit | 143d1a2bd63ed6aa113da73fd097c87ea40c5a8e (patch) | |
tree | ede87bf9f5ffee2383134c22974bc8e47ad073c3 /src | |
parent | 55a677308609250e6514795ce3ef22e2f74a3c13 (diff) | |
download | Neodymium-143d1a2bd63ed6aa113da73fd097c87ea40c5a8e.tar.gz Neodymium-143d1a2bd63ed6aa113da73fd097c87ea40c5a8e.tar.bz2 Neodymium-143d1a2bd63ed6aa113da73fd097c87ea40c5a8e.zip |
Fix yet more visibility issues
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODChunk.java | 20 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODRenderer.java | 39 |
2 files changed, 38 insertions, 21 deletions
diff --git a/src/main/java/makamys/lodmod/renderer/LODChunk.java b/src/main/java/makamys/lodmod/renderer/LODChunk.java index d929306..1e49406 100644 --- a/src/main/java/makamys/lodmod/renderer/LODChunk.java +++ b/src/main/java/makamys/lodmod/renderer/LODChunk.java @@ -19,6 +19,8 @@ public class LODChunk { SimpleChunkMesh[] simpleMeshes = new SimpleChunkMesh[2]; ChunkMesh[] chunkMeshes = new ChunkMesh[32]; + public boolean[] hidden = new boolean[16]; + LODRenderer renderer = LODMod.renderer; public LODChunk(int x, int z) { @@ -56,7 +58,6 @@ public class LODChunk { ChunkMesh newChunkMesh = newChunkMeshes.size() > i ? newChunkMeshes.get(i) : null; if(chunkMeshes[cy * 2 + i] != null) { if(newChunkMesh != null) { - renderer.setMeshVisible(newChunkMesh, chunkMeshes[cy * 2 + i].visible); newChunkMesh.pass = i; } @@ -65,6 +66,7 @@ public class LODChunk { } chunkMeshes[cy * 2 + i] = newChunkMesh; } + LODMod.renderer.lodChunkChanged(this); } // nice copypasta @@ -73,7 +75,6 @@ public class LODChunk { SimpleChunkMesh newSimpleMesh = newSimpleMeshes.size() > i ? newSimpleMeshes.get(i) : null; if(simpleMeshes[i] != null) { if(newSimpleMesh != null) { - renderer.setMeshVisible(newSimpleMesh, simpleMeshes[i].visible); newSimpleMesh.pass = i; } @@ -82,6 +83,7 @@ public class LODChunk { } simpleMeshes[i] = newSimpleMesh; } + LODMod.renderer.lodChunkChanged(this); } public boolean hasChunkMeshes() { @@ -136,4 +138,18 @@ public class LODChunk { putSimpleMeshes(SimpleChunkMesh.generateSimpleMeshes(chunk)); } + public boolean isFullyVisible() { + if(!visible) return false; + for(boolean b : hidden) { + if(b) { + return false; + } + } + return true; + } + + public boolean isSubchunkVisible(int y) { + return !hidden[y]; + } + } diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 3a0ff9d..de294b3 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -431,13 +431,11 @@ public class LODRenderer { LODChunk lodChunk = getLODChunk(x, z); if(visible) { - setMeshVisible(lodChunk.chunkMeshes[y * 2 + 0], false); - setMeshVisible(lodChunk.chunkMeshes[y * 2 + 1], false); - setMeshVisible(lodChunk.simpleMeshes[0], false); - setMeshVisible(lodChunk.simpleMeshes[1], false); + lodChunk.hidden[y] = true; + lodChunkChanged(lodChunk); } else { - setMeshVisible(lodChunk.chunkMeshes[y * 2 + 0], true); - setMeshVisible(lodChunk.chunkMeshes[y * 2 + 1], true); + lodChunk.hidden[y] = false; + lodChunkChanged(lodChunk); } } @@ -518,7 +516,7 @@ public class LODRenderer { int newLOD = (!lodChunk.hasChunkMeshes() && lodChunk.lod == 2) ? 1 : lodChunk.lod; for(SimpleChunkMesh sm : lodChunk.simpleMeshes) { if(sm != null) { - if(lodChunk.visible && newLOD == 1) { + if(lodChunk.isFullyVisible() && newLOD == 1) { if(!sm.visible) { setMeshVisible(sm, true); } @@ -529,18 +527,21 @@ public class LODRenderer { } } } - for(ChunkMesh cm : lodChunk.chunkMeshes) { - if(cm != null) { - if(lodChunk.visible && newLOD == 2) { - if(!cm.visible) { - setMeshVisible(cm, true); - } - } else { - if(cm.visible) { - setMeshVisible(cm, false); - } - } - } + for(int y = 0; y < 16; y++) { + for(int pass = 0; pass < 2; pass++) { + ChunkMesh cm = lodChunk.chunkMeshes[y * 2 + pass]; + if(cm != null) { + if(lodChunk.isSubchunkVisible(y) && newLOD == 2) { + if(!cm.visible) { + setMeshVisible(cm, true); + } + } else { + if(cm.visible) { + setMeshVisible(cm, false); + } + } + } + } } } |