diff options
author | makamys <makamys@outlook.com> | 2022-06-22 06:03:03 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-22 06:03:03 +0200 |
commit | d5e4a114ef2e29ea7f00581c34ffcb709ba44064 (patch) | |
tree | 872b1e5e5c49e8bc5aafb8cbd66f287f360390ce /src/main | |
parent | e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e (diff) | |
download | Neodymium-d5e4a114ef2e29ea7f00581c34ffcb709ba44064.tar.gz Neodymium-d5e4a114ef2e29ea7f00581c34ffcb709ba44064.tar.bz2 Neodymium-d5e4a114ef2e29ea7f00581c34ffcb709ba44064.zip |
Unload regions when they are empty, not when they are "far" away
Diffstat (limited to 'src/main')
3 files changed, 28 insertions, 2 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/NeoChunk.java b/src/main/java/makamys/neodymium/renderer/NeoChunk.java index 4dd692e..2adc7ef 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoChunk.java +++ b/src/main/java/makamys/neodymium/renderer/NeoChunk.java @@ -185,4 +185,18 @@ public class NeoChunk { return true; } + public boolean isEmpty() { + for(SimpleChunkMesh scm: simpleMeshes) { + if(scm != null) { + return false; + } + } + for(CullableMeshCollection cm: chunkMeshes) { + if(cm != null) { + return false; + } + } + return true; + } + } diff --git a/src/main/java/makamys/neodymium/renderer/NeoRegion.java b/src/main/java/makamys/neodymium/renderer/NeoRegion.java index 841bf55..78bf9e7 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRegion.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRegion.java @@ -174,5 +174,17 @@ public class NeoRegion { public String toString() { return "LODRegion(" + regionX + ", " + regionZ + ")"; } + + public boolean isEmpty() { + for(int i = 0; i < 32; i++) { + for(int j = 0; j < 32; j++) { + NeoChunk chunk = data[i][j]; + if(chunk != null && !chunk.isEmpty()) { + return false; + } + } + } + return true; + } } diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index d55119f..92efffc 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -103,7 +103,7 @@ public class NeoRenderer { private int renderedMeshes, renderedQuads; private int frameCount; - public int renderRange = 48; + public int renderRange = 48; // unused LOD thing.. private boolean freezeMeshes; @@ -266,7 +266,7 @@ public class NeoRenderer { ChunkCoordIntPair k = it.next(); NeoRegion v = loadedRegionsMap.get(k); - if(v.distanceTaxicab(player) > renderRange * 16 + 16 * 16) { + if(v.isEmpty()) { System.out.println("unloading " + v); v.destroy(getSaveDir()); it.remove(); |