aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2021-05-09 07:44:58 +0200
committermakamys <makamys@outlook.com>2021-05-09 07:44:58 +0200
commitecec76b081029e706390b74f06198250da43905d (patch)
treeb04356df29b9848b909f95f1d51874fb895ac3b3 /src/main/java
parentfcd6b68d60f4a3fa50991e75d101497aeca3aa4f (diff)
downloadNeodymium-ecec76b081029e706390b74f06198250da43905d.tar.gz
Neodymium-ecec76b081029e706390b74f06198250da43905d.tar.bz2
Neodymium-ecec76b081029e706390b74f06198250da43905d.zip
Improve memory tracking
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODChunk.java14
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRegion.java2
-rw-r--r--src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java5
3 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/makamys/lodmod/renderer/LODChunk.java b/src/main/java/makamys/lodmod/renderer/LODChunk.java
index 5ee5f35..c9bdd5e 100644
--- a/src/main/java/makamys/lodmod/renderer/LODChunk.java
+++ b/src/main/java/makamys/lodmod/renderer/LODChunk.java
@@ -113,4 +113,18 @@ public class LODChunk {
return nbt;
}
+ public void destroy() {
+ for(SimpleChunkMesh scm: simpleMeshes) {
+ if(scm != null) {
+ scm.destroy();
+ }
+ }
+ for(ChunkMesh cm: chunkMeshes) {
+ if(cm != null) {
+ cm.destroy();
+ }
+ }
+ LODMod.renderer.setVisible(this, false);
+ }
+
}
diff --git a/src/main/java/makamys/lodmod/renderer/LODRegion.java b/src/main/java/makamys/lodmod/renderer/LODRegion.java
index a99c24a..df79ede 100644
--- a/src/main/java/makamys/lodmod/renderer/LODRegion.java
+++ b/src/main/java/makamys/lodmod/renderer/LODRegion.java
@@ -144,7 +144,7 @@ public class LODRegion {
for(int j = 0; j < 32; j++) {
LODChunk chunk = data[i][j];
if(chunk != null) {
- LODMod.renderer.setVisible(chunk, false);
+ chunk.destroy();
}
}
}
diff --git a/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java b/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java
index 01291d5..581ee4a 100644
--- a/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java
+++ b/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java
@@ -180,4 +180,9 @@ public class SimpleChunkMesh extends Mesh {
return (3 * 4 + 8 + 4 + 4);
}
+ public void destroy() {
+ usedRAM -= buffer.limit();
+ instances--;
+ }
+
}