mirror of
https://github.com/Bixilon/Minosoft.git
synced 2026-12-05 15:58:25 +00:00
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:
1 file changed
+5
-4
+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()
|
||||
|
||||
Reference in new issue
Block a user