WorldMesh.kt: remove some duplicated code

This commit is contained in:
Bixilon 2022-08-22 19:57:07 +02:00
parent a102302810
commit 612d02e253
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -54,38 +54,25 @@ class WorldMesh(
@Synchronized
fun clearEmpty(): Int {
var meshes = 0
opaqueMesh?.let {
if (it.data.isEmpty) {
it.data.unload()
opaqueMesh = null
} else {
meshes++
fun processMesh(mesh: SingleWorldMesh?): Boolean {
if (mesh == null) {
return false
}
}
translucentMesh?.let {
if (it.data.isEmpty) {
it.data.unload()
translucentMesh = null
} else {
meshes++
}
}
transparentMesh?.let {
if (it.data.isEmpty) {
it.data.unload()
transparentMesh = null
} else {
meshes++
}
}
textMesh?.let {
if (it.data.isEmpty) {
it.data.unload()
textMesh = null
} else {
meshes++
if (mesh.data.isEmpty) {
mesh.data.unload()
return true
}
meshes++
return false
}
if (processMesh(opaqueMesh)) opaqueMesh = null
if (processMesh(translucentMesh)) translucentMesh = null
if (processMesh(transparentMesh)) transparentMesh = null
if (processMesh(textMesh)) textMesh = null
blockEntities?.let {
if (it.isEmpty()) {
blockEntities = null