Skip to content

Commit 9bc8a14

Browse files
committed
overlays: fix crash when recreating mesh
I refactored this, somehow broke it and did not notice. Thanks to polarite for reporting. Mesh invalidation happens when you go e.g. into water and the the mesh gets recrated, but never loaded. An assertion is hit (mesh not loaded yet) when attempting to draw it.
1 parent c6a6876 commit 9bc8a14

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • src/main/java/de/bixilon/minosoft/gui/rendering/framebuffer/world/overlay/overlays/simple

src/main/java/de/bixilon/minosoft/gui/rendering/framebuffer/world/overlay/overlays/simple/SimpleOverlay.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ abstract class SimpleOverlay(
5050
}
5151

5252
private fun updateMesh() {
53-
if (this.mesh == null || invalid) {
54-
mesh?.unload()
55-
}
53+
this.mesh?.unload()
5654
this.mesh = createMesh()
55+
this.mesh?.load()
5756
this.invalid = false
5857
}
5958

6059
override fun draw() {
61-
updateMesh()
60+
if (invalid) {
61+
updateMesh()
62+
}
6263
val mesh = this.mesh ?: return
6364

6465
shader.use()

0 commit comments

Comments
 (0)