aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/lodmod/renderer
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-08 15:07:02 +0200
committermakamys <makamys@outlook.com>2022-06-08 15:07:02 +0200
commit6064a0b77be0c15145eb61bd9510f6abaa15677a (patch)
tree409305ec92ee2df4cb9a652bae0e7d77bf6df10a /src/main/java/makamys/lodmod/renderer
parent9860e5f7a81882abe76afaaee9b841890e614e8d (diff)
downloadNeodymium-6064a0b77be0c15145eb61bd9510f6abaa15677a.tar.gz
Neodymium-6064a0b77be0c15145eb61bd9510f6abaa15677a.tar.bz2
Neodymium-6064a0b77be0c15145eb61bd9510f6abaa15677a.zip
Clean up LODChunk section management
Diffstat (limited to 'src/main/java/makamys/lodmod/renderer')
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODChunk.java10
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRenderer.java16
2 files changed, 13 insertions, 13 deletions
diff --git a/src/main/java/makamys/lodmod/renderer/LODChunk.java b/src/main/java/makamys/lodmod/renderer/LODChunk.java
index 5830132..2c5d61c 100644
--- a/src/main/java/makamys/lodmod/renderer/LODChunk.java
+++ b/src/main/java/makamys/lodmod/renderer/LODChunk.java
@@ -21,7 +21,7 @@ public class LODChunk {
SimpleChunkMesh[] simpleMeshes = new SimpleChunkMesh[2];
ChunkMesh[] chunkMeshes = new ChunkMesh[32];
- public boolean[] hidden = new boolean[16];
+ public boolean[] isSectionVisible = new boolean[16];
LODRenderer renderer = LODMod.renderer;
@@ -173,16 +173,12 @@ public class LODChunk {
public boolean isFullyVisible() {
if(!visible) return false;
- for(boolean b : hidden) {
- if(b) {
+ for(boolean b : isSectionVisible) {
+ 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 10f748e..ee6d17a 100644
--- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java
+++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
@@ -459,7 +459,7 @@ public class LODRenderer {
int z = Math.floorDiv(wr.posZ, 16);
LODChunk lodChunk = getLODChunk(x, z);
- lodChunk.hidden[y] = change != WorldRendererChange.VISIBLE;
+ lodChunk.isSectionVisible[y] = change == WorldRendererChange.VISIBLE;
if(change == WorldRendererChange.DELETED) {
removeMesh(lodChunk.chunkMeshes[y]);
}
@@ -469,10 +469,14 @@ public class LODRenderer {
public void onWorldRendererPost(WorldRenderer wr) {
if(LODMod.disableChunkMeshes) return;
- if(Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(Math.floorDiv(wr.posX, 16), Math.floorDiv(wr.posZ, 16)).isChunkLoaded) {
- LODChunk lodChunk = getLODChunk(Math.floorDiv(wr.posX, 16), Math.floorDiv(wr.posZ, 16));
- lodChunk.hidden[Math.floorDiv(wr.posY, 16)] = !((IWorldRenderer)wr).isDrawn();
- lodChunk.putChunkMeshes(Math.floorDiv(wr.posY, 16), ((IWorldRenderer)wr).getChunkMeshes());
+ int x = Math.floorDiv(wr.posX, 16);
+ int y = Math.floorDiv(wr.posY, 16);
+ int z = Math.floorDiv(wr.posZ, 16);
+
+ if(Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(x, z).isChunkLoaded) {
+ LODChunk lodChunk = getLODChunk(x, z);
+ lodChunk.isSectionVisible[y] = ((IWorldRenderer)wr).isDrawn();
+ lodChunk.putChunkMeshes(y, ((IWorldRenderer)wr).getChunkMeshes());
}
}
@@ -555,7 +559,7 @@ public class LODRenderer {
for(int pass = 0; pass < 2; pass++) {
ChunkMesh cm = lodChunk.chunkMeshes[y * 2 + pass];
if(cm != null) {
- if(lodChunk.isSubchunkVisible(y) && newLOD == 2) {
+ if(lodChunk.isSectionVisible[y] && newLOD == 2) {
if(!cm.visible) {
setMeshVisible(cm, true);
}