dynamic textures: fix cleaning up

This commit is contained in:
Moritz Zwerger 2023-10-28 14:24:47 +02:00
parent 424ef281cb
commit a29155cb96
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 5 additions and 4 deletions

View File

@ -142,7 +142,7 @@ abstract class DynamicTextureArray(
for ((index, reference) in textures.withIndex()) {
if (reference == null) continue
val texture = reference.get()
texture?.state = DynamicTextureState.UNLOADED
if (texture != null) continue // not gced yet, keep it for now
textures[index] = null
}
lock.unlock()

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -17,6 +17,8 @@ enum class DynamicTextureState {
WAITING,
LOADING,
LOADED,
@Deprecated("unrechable", level = DeprecationLevel.ERROR)
UNLOADED,
;
}

View File

@ -51,7 +51,7 @@ class SkinManager(private val textureManager: TextureManager) {
private fun getSkin(uuid: UUID, properties: PlayerProperties?, async: Boolean = true): PlayerSkin? {
val texture = properties?.textures?.skin ?: return default[uuid]
return PlayerSkin(textureManager.dynamicTextures.pushRaw(uuid, async) { texture.read() }, texture.metadata.model)
return PlayerSkin(textureManager.dynamicTextures.pushRaw(texture.getHash(), async) { texture.read() }, texture.metadata.model)
}
fun getSkin(player: PlayerEntity, properties: PlayerProperties? = null, fetch: Boolean = true, async: Boolean = true): PlayerSkin? {

View File

@ -20,7 +20,6 @@ class OpenGLDynamicTexture(identifier: Any, shaderId: Int) : DynamicTexture(iden
override var shaderId: Int = shaderId
get() {
if (state == DynamicTextureState.UNLOADED) throw IllegalStateException("Texture was unloaded!")
if (state == DynamicTextureState.LOADING) throw IllegalStateException("Texture was not loaded yet!")
return field
}