diff options
author | makamys <makamys@outlook.com> | 2022-06-24 09:22:33 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-24 09:32:33 +0200 |
commit | 41c8ac491b8e168f871e8d5eec1a13208e272410 (patch) | |
tree | 21fe2e76cbb71e4c75c43fadb201c83c67738c97 /src/main/java/makamys/neodymium/renderer/NeoRegion.java | |
parent | 2cd1e01bf0f6e80ff1293cacc66616ab79e2a442 (diff) | |
download | Neodymium-41c8ac491b8e168f871e8d5eec1a13208e272410.tar.gz Neodymium-41c8ac491b8e168f871e8d5eec1a13208e272410.tar.bz2 Neodymium-41c8ac491b8e168f871e8d5eec1a13208e272410.zip |
Optimize some stuff in the CPU world
Increases FPS from 550 to 600 when rendering 0 meshes.
(which means, overhead has been reduced)
Diffstat (limited to 'src/main/java/makamys/neodymium/renderer/NeoRegion.java')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/NeoRegion.java | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRegion.java b/src/main/java/makamys/neodymium/renderer/NeoRegion.java index 78bf9e7..40aaf7d 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRegion.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRegion.java @@ -11,13 +11,17 @@ public class NeoRegion { int regionX, regionZ; + public int meshes = 0; + + private int emptyTicks = 0; + public NeoRegion(int regionX, int regionZ) { this.regionX = regionX; this.regionZ = regionZ; for(int i = 0; i < 32; i++) { for(int j = 0; j < 32; j++) { - data[i][j] = new NeoChunk(regionX * 32 + i, regionZ * 32 + j); + data[i][j] = new NeoChunk(regionX * 32 + i, regionZ * 32 + j, this); } } } @@ -134,20 +138,21 @@ public class NeoRegion { return null; } - public boolean tick(Entity player) { - int visibleChunks = 0; + public void tick(Entity player) { for(int i = 0; i < 32; i++) { for(int j = 0; j < 32; j++) { NeoChunk chunk = data[i][j]; if(chunk != null) { chunk.tick(player); - if(chunk.visible) { - visibleChunks++; - } } } } - return visibleChunks > 0; + + if(meshes == 0) { + emptyTicks++; + } else { + emptyTicks = 0; + } } public void destroy(Path saveDir) { @@ -175,16 +180,8 @@ public class NeoRegion { 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; + public boolean shouldDelete() { + return emptyTicks > 100; } } |