diff options
author | makamys <makamys@outlook.com> | 2021-05-10 13:06:34 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-10 13:06:34 +0200 |
commit | 53667f60256297c98ea0e58ec164ef922c702361 (patch) | |
tree | e14cbdc7f054736d99a272e9689c23c1848c4681 /src/main/java/makamys | |
parent | b083ec25e114fd7616c14a90253a1fae835e0735 (diff) | |
download | Neodymium-53667f60256297c98ea0e58ec164ef922c702361.tar.gz Neodymium-53667f60256297c98ea0e58ec164ef922c702361.tar.bz2 Neodymium-53667f60256297c98ea0e58ec164ef922c702361.zip |
Maintain mesh visibility when replacing a mesh
Partial fix for invisible chunks on the edge of the loaded world when
using OptiFine
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODChunk.java | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/main/java/makamys/lodmod/renderer/LODChunk.java b/src/main/java/makamys/lodmod/renderer/LODChunk.java index 46467e5..d929306 100644 --- a/src/main/java/makamys/lodmod/renderer/LODChunk.java +++ b/src/main/java/makamys/lodmod/renderer/LODChunk.java @@ -53,29 +53,35 @@ public class LODChunk { public void putChunkMeshes(int cy, List<ChunkMesh> newChunkMeshes) { for(int i = 0; i < 2; i++) { - if(chunkMeshes[cy * 2 + i] != null) { + 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; + } + renderer.setMeshVisible(chunkMeshes[cy * 2 + i], false); chunkMeshes[cy * 2 + i].destroy(); - chunkMeshes[cy * 2 + i] = null; - } - } - - for(int i = 0; i < newChunkMeshes.size(); i++) { - chunkMeshes[cy * 2 + i] = newChunkMeshes.get(i); - if(newChunkMeshes.get(i) != null) { - chunkMeshes[cy * 2 + i].pass = i; } + chunkMeshes[cy * 2 + i] = newChunkMesh; } } - public void putSimpleMeshes(List<SimpleChunkMesh> meshes) { - for(SimpleChunkMesh sm : simpleMeshes) { - if(sm!= null) { - renderer.setMeshVisible(sm, false); - } - } - - simpleMeshes = meshes.toArray(new SimpleChunkMesh[0]); + // nice copypasta + public void putSimpleMeshes(List<SimpleChunkMesh> newSimpleMeshes) { + for(int i = 0; i < 2; i++) { + 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; + } + + renderer.setMeshVisible(simpleMeshes[i], false); + simpleMeshes[i].destroy(); + } + simpleMeshes[i] = newSimpleMesh; + } } public boolean hasChunkMeshes() { |