diff options
author | makamys <makamys@outlook.com> | 2022-06-22 05:57:01 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-22 05:57:15 +0200 |
commit | e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e (patch) | |
tree | bfce4c849f450213496887e5f0d6a54dd7bcd36b /src/main/java/makamys | |
parent | bef6742c00977461daf36a56023432472e79bab5 (diff) | |
download | Neodymium-e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e.tar.gz Neodymium-e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e.tar.bz2 Neodymium-e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e.zip |
Fix memory leak
Meshes wouldn't get unloaded properly if they were never sent to the GPU, or
if they are transparent.
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r-- | src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java | 5 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/NeoRenderer.java | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java index fb73362..3901a7a 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java @@ -49,6 +49,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { public boolean needsUpdate; boolean savedDrawnStatus; + private boolean insideUpdateRenderer; public List<CullableMeshCollection> chunkMeshes; @@ -71,6 +72,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Inject(method = "updateRenderer", at = @At(value = "HEAD")) private void preUpdateRenderer(CallbackInfo ci) { saveDrawnStatus(); + insideUpdateRenderer = true; if(Neodymium.isActive()) { if(needsUpdate) { @@ -88,6 +90,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Inject(method = "updateRenderer", at = @At(value = "RETURN")) private void postUpdateRenderer(CallbackInfo ci) { notifyIfDrawnStatusChanged(); + insideUpdateRenderer = false; if(Neodymium.isActive()) { if(chunkMeshes != null) { @@ -99,7 +102,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Inject(method = "postRenderBlocks", at = @At(value = "HEAD")) private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) { - if(Neodymium.isActive() && !Config.disableChunkMeshes) { + if(insideUpdateRenderer && Neodymium.isActive() && !Config.disableChunkMeshes) { if(chunkMeshes != null) { chunkMeshes.add(ChunkMesh.fromTessellator(pass, WorldRenderer.class.cast(this), Tessellator.instance)); } diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 7bc582c..d55119f 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -537,6 +537,10 @@ public class NeoRenderer { lodChunk.isSectionVisible[y] = change == WorldRendererChange.VISIBLE; if(change == WorldRendererChange.DELETED) { removeMesh(lodChunk.chunkMeshes[y]); + if(lodChunk.chunkMeshes[y] != null) { + lodChunk.chunkMeshes[y].destroy(); + lodChunk.chunkMeshes[y] = null; + } } lodChunkChanged(lodChunk); } |