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.
This commit is contained in:
Moritz Zwerger committed 2026-01-17 14:29:36 +01:00
1 parent c6a6876bee
commit 9bc8a14c7d
1 file changed
+5 -4
@@ -50,15 +50,16 @@ abstract class SimpleOverlay(
}
private fun updateMesh() {
if (this.mesh == null || invalid) {
mesh?.unload()
}
this.mesh?.unload()
this.mesh = createMesh()
this.mesh?.load()
this.invalid = false
}
override fun draw() {
updateMesh()
if (invalid) {
updateMesh()
}
val mesh = this.mesh ?: return
shader.use()