mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 01:48:04 -04:00
move debug texture to render constants
This commit is contained in:
parent
afd4a89406
commit
59fe64020a
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering
|
||||
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
|
||||
object RenderConstants {
|
||||
@ -57,4 +58,8 @@ object RenderConstants {
|
||||
const val RENDER_HUD = true
|
||||
|
||||
const val FORCE_DEBUG_TEXTURE = false
|
||||
|
||||
|
||||
val DEBUG_TEXTURE_RESOURCE_LOCATION = ResourceLocation("minosoft:textures/debug.png")
|
||||
const val DEBUG_TEXTURE_ID = 0 // always add the debug texture to the texture array first to ensure the id is 0
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ class RenderWindow(
|
||||
glEnable(GL_CULL_FACE)
|
||||
|
||||
|
||||
textures.allTextures.add(Texture(TextureArray.DEBUG_TEXTURE))
|
||||
textures.allTextures.add(Texture(RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION))
|
||||
|
||||
font.load(connection.assetsManager)
|
||||
|
||||
|
@ -36,7 +36,7 @@ class SectionArrayMesh : Mesh(initialCacheSize = 100000) {
|
||||
val lightColor = RGBColor((color.red * lightFactor).toInt(), (color.green * lightFactor).toInt(), (color.blue * lightFactor).toInt())
|
||||
|
||||
val textureLayer = if (RenderConstants.FORCE_DEBUG_TEXTURE) {
|
||||
0
|
||||
RenderConstants.DEBUG_TEXTURE_ID
|
||||
} else {
|
||||
(texture.arrayId shl 24) or texture.arrayLayer
|
||||
}
|
||||
|
@ -33,7 +33,13 @@ import de.bixilon.minosoft.gui.rendering.util.VecUtil.rotate
|
||||
import glm_.vec3.Vec3
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
class ElementRenderer(parent: BlockModelElement, val rotation: Vec3, uvLock: Boolean, rescale: Boolean, private val directionMapping: HashBiMap<Directions, Directions>) {
|
||||
class ElementRenderer(
|
||||
parent: BlockModelElement,
|
||||
val rotation: Vec3,
|
||||
uvLock: Boolean,
|
||||
rescale: Boolean,
|
||||
private val directionMapping: HashBiMap<Directions, Directions>,
|
||||
) {
|
||||
val faceBorderSize: Array<FaceSize?> = arrayOfNulls(Directions.DIRECTIONS.size)
|
||||
private val faces: MutableMap<Directions, BlockModelFace> = mutableMapOf()
|
||||
private var transformedPositions: Array<Vec3> = parent.transformedPositions.clone()
|
||||
@ -68,7 +74,7 @@ class ElementRenderer(parent: BlockModelElement, val rotation: Vec3, uvLock: Boo
|
||||
val face = faces[realDirection] ?: return // Not our face
|
||||
val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[realDirection.ordinal]
|
||||
|
||||
val texture = textureMapping[face.textureName] ?: TODO("Unknown texture used ${face.textureName}")
|
||||
val texture = textureMapping[face.textureName] ?: TODO("Unknown texture used ${face.textureName}") // ToDo: can be replaced with RenderConstants.DEBUG_TEXTURE_ID?
|
||||
|
||||
val lightLevel = lightAccessor.getLightLevel(blockPosition + face.cullFace?.let { directionMapping[it] }) // ToDo: rotate cullface
|
||||
|
||||
|
@ -18,8 +18,8 @@ import com.google.gson.JsonObject
|
||||
import de.bixilon.minosoft.data.assets.AssetsManager
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
import de.bixilon.minosoft.gui.rendering.textures.Texture
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureArray
|
||||
import java.io.InputStream
|
||||
|
||||
object FontLoader {
|
||||
@ -97,7 +97,7 @@ object FontLoader {
|
||||
if (i % 256 == 0) {
|
||||
currentAtlasTexture = if (MISSING_UNICODE_PAGES.contains(i / UNICODE_CHARS_PER_PAGE)) {
|
||||
// ToDo: Why is this texture missing in minecraft?
|
||||
Texture(TextureArray.DEBUG_TEXTURE)
|
||||
Texture(RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION)
|
||||
} else {
|
||||
// new page (texture)
|
||||
Texture(Texture.getResourceTextureIdentifier(template.namespace, template.path.format("%02x".format(i / 256))))
|
||||
|
@ -145,8 +145,6 @@ class TextureArray(val allTextures: MutableList<Texture>) {
|
||||
val TEXTURE_RESOLUTION_ID_MAP = arrayOf(16, 32, 64, 128, 256, 512, 1024) // A 12x12 texture will be saved in texture id 0 (in 0 are only 16x16 textures). Animated textures get split
|
||||
const val TEXTURE_MAX_RESOLUTION = 1024
|
||||
|
||||
val DEBUG_TEXTURE = ResourceLocation("minosoft:textures/debug.png")
|
||||
|
||||
private const val INTS_PER_ANIMATED_TEXTURE = 4
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user