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 @Synchronized
fun clearEmpty(): Int { fun clearEmpty(): Int {
var meshes = 0 var meshes = 0
opaqueMesh?.let {
if (it.data.isEmpty) { fun processMesh(mesh: SingleWorldMesh?): Boolean {
it.data.unload() if (mesh == null) {
opaqueMesh = null return false
} else {
meshes++
} }
} if (mesh.data.isEmpty) {
translucentMesh?.let { mesh.data.unload()
if (it.data.isEmpty) { return true
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++
} }
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 { blockEntities?.let {
if (it.isEmpty()) { if (it.isEmpty()) {
blockEntities = null blockEntities = null