mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 00:47:26 -04:00
skin fixes, reload textures command
This commit is contained in:
parent
2735b824b8
commit
f105977d4b
@ -19,6 +19,7 @@ import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||
import de.bixilon.minosoft.gui.rendering.entities.easteregg.EntityEasterEggs.isFlipped
|
||||
import de.bixilon.minosoft.gui.rendering.entities.renderer.EntityRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.entities.renderer.living.LivingEntityRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.instance.SkeletalInstance
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3dUtil.EMPTY
|
||||
@ -64,7 +65,10 @@ open class SkeletalFeature(
|
||||
}
|
||||
|
||||
override fun draw() {
|
||||
val tint = renderer.light.value.mix(renderer.damage.value)
|
||||
var tint = renderer.light.value
|
||||
if (renderer is LivingEntityRenderer<*>) {
|
||||
tint = tint.mix(renderer.damage.value)
|
||||
}
|
||||
instance.draw(tint)
|
||||
}
|
||||
|
||||
|
@ -55,4 +55,8 @@ abstract class TextureManager {
|
||||
staticTextures.use(shader, name)
|
||||
dynamicTextures.use(shader, name)
|
||||
}
|
||||
|
||||
fun reload() {
|
||||
dynamicTextures.reload()
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ abstract class DynamicTextureArray(
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
private fun reload() {
|
||||
fun reload() {
|
||||
unload()
|
||||
upload()
|
||||
this.reload = false
|
||||
|
@ -36,6 +36,7 @@ class OpenGLDynamicTextureArray(
|
||||
initialSize: Int = 32,
|
||||
val resolution: Int,
|
||||
) : DynamicTextureArray(context, initialSize) {
|
||||
private val empty = IntArray(resolution * resolution) { 0x00 }
|
||||
private var handle = -1
|
||||
|
||||
override fun upload(index: Int, texture: DynamicTexture) {
|
||||
@ -49,15 +50,17 @@ class OpenGLDynamicTextureArray(
|
||||
private fun unsafeUpload(index: Int, texture: DynamicTexture) {
|
||||
val data = texture.data ?: throw IllegalArgumentException("No texture data?")
|
||||
for ((level, buffer) in data.collect().withIndex()) {
|
||||
// glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, index, texture.size.x shr level, texture.size.y shr level, 1, GL_RGBA, GL_UNSIGNED_BYTE, mipmap)
|
||||
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, index, resolution shr level, resolution shr level, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer)
|
||||
if (data.size.x != resolution || data.size.y != resolution) {
|
||||
// clear first
|
||||
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, index, resolution shr level, resolution shr level, 1, GL_RGBA, GL_UNSIGNED_BYTE, empty)
|
||||
}
|
||||
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, index, data.size.x shr level, data.size.y shr level, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer)
|
||||
}
|
||||
}
|
||||
|
||||
override fun upload() {
|
||||
if (handle >= 0) throw MemoryLeakException("Texture was not unloaded!")
|
||||
val textureId = OpenGLTextureUtil.createTextureArray()
|
||||
|
||||
for (level in 0 until OpenGLTextureUtil.MAX_MIPMAP_LEVELS) {
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, resolution shr level, resolution shr level, textures.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, null as ByteBuffer?)
|
||||
}
|
||||
@ -67,6 +70,7 @@ class OpenGLDynamicTextureArray(
|
||||
if (texture.data == null) continue
|
||||
unsafeUpload(index, texture)
|
||||
}
|
||||
this.handle = textureId
|
||||
|
||||
for (shader in shaders) {
|
||||
unsafeUse(shader)
|
||||
@ -74,7 +78,6 @@ class OpenGLDynamicTextureArray(
|
||||
|
||||
context.textures.staticTextures.activate() // TODO: why?
|
||||
|
||||
this.handle = textureId
|
||||
}
|
||||
|
||||
override fun activate() {
|
||||
|
@ -18,7 +18,17 @@ import de.bixilon.minosoft.commands.nodes.LiteralNode
|
||||
object ReloadCommand : RenderingCommand {
|
||||
override var node = LiteralNode("reload", setOf("rl"))
|
||||
.addChild(LiteralNode("shaders", executor = {
|
||||
it.connection.rendering?.context?.system?.reloadShaders() ?: throw IllegalStateException("Rendering is not loaded!")
|
||||
it.connection.util.sendDebugMessage("Shaders reloaded!")
|
||||
val context = it.connection.rendering?.context ?: throw IllegalStateException("Rendering is not loaded!")
|
||||
context.queue += {
|
||||
context.system.reloadShaders()
|
||||
it.connection.util.sendDebugMessage("Shaders reloaded!")
|
||||
}
|
||||
}))
|
||||
.addChild(LiteralNode("textures", executor = {
|
||||
val context = it.connection.rendering?.context ?: throw IllegalStateException("Rendering is not loaded!")
|
||||
context.queue += {
|
||||
context.textures.reload()
|
||||
it.connection.util.sendDebugMessage("Textures reloaded!")
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user