aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-24 10:17:50 +0200
committermakamys <makamys@outlook.com>2022-06-25 07:27:50 +0200
commite5f18be985bac742cc9bbcdf0427187d666a304a (patch)
treebac86f278a1f2cf95c6de4e0a0af5821f38b90d5 /src
parentd5d08eb64a91c1a5b74e401037628260cfd8059c (diff)
downloadNeodymium-e5f18be985bac742cc9bbcdf0427187d666a304a.tar.gz
Neodymium-e5f18be985bac742cc9bbcdf0427187d666a304a.tar.bz2
Neodymium-e5f18be985bac742cc9bbcdf0427187d666a304a.zip
Clean up in ChunkMesh
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/renderer/ChunkMesh.java14
-rw-r--r--src/main/java/makamys/neodymium/renderer/Mesh.java7
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java15
3 files changed, 14 insertions, 22 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
index 47c082e..26429a7 100644
--- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
+++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
@@ -244,15 +244,12 @@ public class ChunkMesh extends Mesh {
}
@Override
- public void writeToIndexBuffer(IntBuffer piFirst, IntBuffer piCount, int[] renderedMeshesReturn,
- int[] renderedQuadsReturn, int cameraXDiv, int cameraYDiv, int cameraZDiv) {
+ public int writeToIndexBuffer(IntBuffer piFirst, IntBuffer piCount, int cameraXDiv, int cameraYDiv, int cameraZDiv) {
if(!Config.cullFaces) {
- super.writeToIndexBuffer(piFirst, piCount, renderedMeshesReturn, renderedQuadsReturn, cameraXDiv, cameraYDiv, cameraZDiv);
- return;
+ return super.writeToIndexBuffer(piFirst, piCount, cameraXDiv, cameraYDiv, cameraZDiv);
}
- renderedMeshesReturn[0] = 0;
- renderedQuadsReturn[0] = 0;
+ int renderedMeshes = 0;
int startIndex = -1;
for(int i = 0; i < NORMAL_ORDER.length + 1; i++) {
@@ -268,12 +265,13 @@ public class ChunkMesh extends Mesh {
piFirst.put(iFirst + (startIndex*4));
piCount.put((endIndex - startIndex)*4);
- renderedMeshesReturn[0]++;
- renderedQuadsReturn[0] += endIndex - startIndex; // TODO remove this, it's redundant
+ renderedMeshes++;
startIndex = -1;
}
}
+
+ return renderedMeshes;
}
private boolean isNormalVisible(QuadNormal normal, int interpXDiv, int interpYDiv, int interpZDiv) {
diff --git a/src/main/java/makamys/neodymium/renderer/Mesh.java b/src/main/java/makamys/neodymium/renderer/Mesh.java
index 6db523d..f73bb51 100644
--- a/src/main/java/makamys/neodymium/renderer/Mesh.java
+++ b/src/main/java/makamys/neodymium/renderer/Mesh.java
@@ -42,11 +42,10 @@ public abstract class Mesh {
UNSENT, SENT, PENDING_DELETE
}
- public void writeToIndexBuffer(IntBuffer piFirst, IntBuffer piCount, int[] renderedMeshesReturn,
- int[] renderedQuadsReturn, int cameraXDiv, int cameraYDiv, int cameraZDiv) {
- renderedMeshesReturn[0] = 1;
- renderedQuadsReturn[0] = quadCount;
+ public int writeToIndexBuffer(IntBuffer piFirst, IntBuffer piCount, int cameraXDiv, int cameraYDiv, int cameraZDiv) {
piFirst.put(iFirst);
piCount.put(iCount);
+
+ return 1;
}
}
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
index 73a3be2..75ce575 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
@@ -18,10 +18,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Queue;
import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -44,7 +41,6 @@ import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
-import net.minecraftforge.event.world.ChunkEvent;
/** The main renderer class. */
public class NeoRenderer {
@@ -170,18 +166,17 @@ public class NeoRenderer {
}
}
- private static int[] renderedMeshesReturn = new int[1];
- private static int[] renderedQuadsReturn = new int[1];
-
private void initIndexBuffers() {
for(int i = 0; i < 2; i++) {
piFirst[i].limit(MAX_MESHES);
piCount[i].limit(MAX_MESHES);
for(Mesh mesh : sentMeshes[i]) {
if(mesh.visible && (Config.maxMeshesPerFrame == -1 || renderedMeshes < Config.maxMeshesPerFrame)) {
- mesh.writeToIndexBuffer(piFirst[i], piCount[i], renderedMeshesReturn, renderedQuadsReturn, interpXDiv, interpYDiv, interpZDiv);
- renderedMeshes += renderedMeshesReturn[0];
- renderedQuads += renderedQuadsReturn[0];
+ int meshes = mesh.writeToIndexBuffer(piFirst[i], piCount[i], interpXDiv, interpYDiv, interpZDiv);
+ renderedMeshes += meshes;
+ for(int j = piCount[i].position() - meshes; j < piCount[i].position(); j++) {
+ renderedQuads += piCount[i].get(j) / 4;
+ }
}
}
piFirst[i].flip();