aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/renderer/NeoChunk.java
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-24 09:22:33 +0200
committermakamys <makamys@outlook.com>2022-06-24 09:32:33 +0200
commit41c8ac491b8e168f871e8d5eec1a13208e272410 (patch)
tree21fe2e76cbb71e4c75c43fadb201c83c67738c97 /src/main/java/makamys/neodymium/renderer/NeoChunk.java
parent2cd1e01bf0f6e80ff1293cacc66616ab79e2a442 (diff)
downloadNeodymium-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/NeoChunk.java')
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoChunk.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/NeoChunk.java b/src/main/java/makamys/neodymium/renderer/NeoChunk.java
index 72957e0..e7c3cab 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoChunk.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoChunk.java
@@ -16,6 +16,7 @@ public class NeoChunk {
boolean visible;
boolean dirty;
boolean discardedMesh;
+ NeoRegion region;
SimpleChunkMesh[] simpleMeshes = new SimpleChunkMesh[2];
ChunkMesh[] chunkMeshes = new ChunkMesh[32];
@@ -24,9 +25,10 @@ public class NeoChunk {
NeoRenderer renderer = Neodymium.renderer;
- public NeoChunk(int x, int z) {
+ public NeoChunk(int x, int z, NeoRegion region) {
this.x = x;
this.z = z;
+ this.region = region;
}
/*
public LODChunk(NBTTagCompound nbt, List<String> spriteList) {
@@ -69,6 +71,8 @@ public class NeoChunk {
renderer.removeMesh(chunkMeshes[cy * 2 + i]);
chunkMeshes[cy * 2 + i].destroy();
+ } else {
+ region.meshes++;
}
chunkMeshes[cy * 2 + i] = newChunkMesh;
}
@@ -104,14 +108,18 @@ public class NeoChunk {
}
public void tick(Entity player) {
- double distSq = distSq(player);
- if(Config.disableSimpleMeshes || distSq < Math.pow((Neodymium.renderer.renderRange / 2) * 16, 2)) {
- setLOD(2);
- } else if(distSq < Math.pow((Neodymium.renderer.renderRange) * 16, 2)) {
- setLOD(1);
- } else {
- setLOD(0);
- }
+ if(Config.disableSimpleMeshes) {
+ setLOD(2);
+ } else {
+ double distSq = distSq(player);
+ if(Config.disableSimpleMeshes || distSq < Math.pow((Neodymium.renderer.renderRange / 2) * 16, 2)) {
+ setLOD(2);
+ } else if(distSq < Math.pow((Neodymium.renderer.renderRange) * 16, 2)) {
+ setLOD(1);
+ } else {
+ setLOD(0);
+ }
+ }
}
public void setLOD(int lod) {
@@ -125,6 +133,7 @@ public class NeoChunk {
if(chunkMeshes[i] != null) {
chunkMeshes[i].destroy();
chunkMeshes[i] = null;
+ region.meshes--;
discardedMesh = true;
}
}
@@ -157,11 +166,13 @@ public class NeoChunk {
for(SimpleChunkMesh scm: simpleMeshes) {
if(scm != null) {
scm.destroy();
+ region.meshes--;
}
}
for(ChunkMesh cm: chunkMeshes) {
if(cm != null) {
cm.destroy();
+ region.meshes--;
}
}
Neodymium.renderer.setVisible(this, false);