rendering: fix some hud bugs, change some huds things

This commit is contained in:
Bixilon 2021-03-21 19:09:54 +01:00
parent 8ffce5f563
commit 64d44608b0
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
11 changed files with 40 additions and 39 deletions

View File

@ -23,7 +23,7 @@ import java.util.*
import java.util.concurrent.ConcurrentHashMap
/**
* Collection of chunks
* Collection of chunks and more
*/
class World {
val chunks = ConcurrentHashMap<ChunkPosition, Chunk>()

View File

@ -56,7 +56,7 @@ class Font {
for (provider in providers) {
for (char in provider.chars.values) {
char.calculateUV(provider.width, char.texture.arraySinglePixelSize, char.texture.arraySinglePixelSize) // ToDo: Unicode: With should pe plus 1
char.calculateUV(provider.width, char.texture.arraySinglePixelFactor) // ToDo: Unicode: With should pe plus 1
}
}
loaded = true

View File

@ -33,8 +33,8 @@ data class FontChar(
override val size = Vec2i(endPixel - startPixel, height)
fun calculateUV(letterWidth: Int, atlasWidthSinglePixel: Float, atlasHeightSinglePixel: Float) {
uvStart = Vec2(atlasWidthSinglePixel * (letterWidth * column + startPixel), atlasHeightSinglePixel * (height * row))
uvEnd = Vec2(atlasWidthSinglePixel * (letterWidth * column + endPixel), atlasHeightSinglePixel * (height * (row + 1)))
fun calculateUV(letterWidth: Int, arraySinglePixelFactor: Vec2) {
uvStart = Vec2(letterWidth * column + startPixel, height * row) * arraySinglePixelFactor
uvEnd = Vec2(letterWidth * column + endPixel, height * (row + 1)) * arraySinglePixelFactor
}
}

View File

@ -33,8 +33,8 @@ data class HUDAtlasElement(
fun postInit() {
uvStart = Vec2(binding.start) * texture.arraySinglePixelSize
uvEnd = (Vec2(binding.end) - Vec2(0, 1)) * texture.arraySinglePixelSize
uvStart = Vec2(binding.start) * texture.arraySinglePixelFactor
uvEnd = Vec2(binding.end) * texture.arraySinglePixelFactor
}
companion object {

View File

@ -22,7 +22,7 @@ data class Vec2Binding(
val start: Vec2i,
val end: Vec2i,
) {
val size: Vec2i = glm.abs(Vec2i(start - end)) + 1
val size: Vec2i = glm.abs(start - end)
companion object {

View File

@ -22,6 +22,7 @@ import de.bixilon.minosoft.util.UnitFormatter
class HUDWorldDebugElement(hudRenderer: HUDRenderer) : DebugScreen(hudRenderer) {
private val camera = hudRenderer.renderWindow.camera
private val brandText = text("§cMinosoft 0.1-pre1")
private val fpsText = text("TBA")
private val timingsText = text("TBA")
private val chunksText = text("TBA")

View File

@ -59,15 +59,15 @@ class ImageElement(
val realZ = RenderConstants.HUD_Z_COORDINATE + RenderConstants.HUD_Z_COORDINATE_Z_FACTOR * (this.z + z)
fun addVertex(position: Vec2, textureUV: Vec2) {
cache.addVertex(Vec3(position, realZ), textureUV, textureLike?.texture, tintColor)
fun addVertex(positionX: Float, positionY: Float, textureUV: Vec2) {
cache.addVertex(Vec3(positionX, positionY, realZ), textureUV, textureLike?.texture, tintColor)
}
addVertex(Vec2(modelStart.x, modelStart.y), Vec2(uvStart.x, uvStart.y))
addVertex(Vec2(modelStart.x, modelEnd.y), Vec2(uvStart.x, uvEnd.y))
addVertex(Vec2(modelEnd.x, modelStart.y), Vec2(uvEnd.x, uvStart.y))
addVertex(Vec2(modelStart.x, modelEnd.y), Vec2(uvStart.x, uvEnd.y))
addVertex(Vec2(modelEnd.x, modelEnd.y), Vec2(uvEnd.x, uvEnd.y))
addVertex(Vec2(modelEnd.x, modelStart.y), Vec2(uvEnd.x, uvStart.y))
addVertex(modelStart.x, modelStart.y, Vec2(uvStart.x, uvStart.y))
addVertex(modelStart.x, modelEnd.y, Vec2(uvStart.x, uvEnd.y))
addVertex(modelEnd.x, modelStart.y, Vec2(uvEnd.x, uvStart.y))
addVertex(modelStart.x, modelEnd.y, Vec2(uvStart.x, uvEnd.y))
addVertex(modelEnd.x, modelEnd.y, Vec2(uvEnd.x, uvEnd.y))
addVertex(modelEnd.x, modelStart.y, Vec2(uvEnd.x, uvStart.y))
}
}

View File

@ -50,7 +50,7 @@ class TextElement(
Vec2i(0, Font.CHAR_HEIGHT)
} else {
val textSize = Vec2i(0, 0)
text.prepareRender(Vec2i(0, 1), Vec2i(), font, this, this.z + z + 1, textSize)
text.prepareRender(Vec2i(1, 1), Vec2i(), font, this, this.z + z + 1, textSize)
if (background) {
drawBackground(textSize + 1, z)

View File

@ -39,7 +39,7 @@ class Texture(
lateinit var properties: ImageProperties
var arraySinglePixelSize = 1.0f
var arraySinglePixelFactor = Vec2(1.0f, 1.0f)
var buffer: ByteBuffer? = null
@ -51,7 +51,7 @@ class Texture(
transparency = texture.transparency
uvEnd = texture.uvEnd
properties = ImageProperties()
arraySinglePixelSize = texture.arraySinglePixelSize
arraySinglePixelFactor = texture.arraySinglePixelFactor
isLoaded = true
}

View File

@ -66,7 +66,7 @@ class TextureArray(val allTextures: MutableList<Texture>) {
y = size.y.toFloat() / arrayResolution
)
texture.arraySinglePixelSize = 1.0f / arrayResolution
texture.arraySinglePixelFactor = Vec2(1.0f / arrayResolution, 1.0f / (arrayResolution + 1)) // ToDo: Why +1 ?? Still not working right
texture.arrayLayer = it.size

View File

@ -4,43 +4,43 @@
"versions": {
"567": {
"start": [0, 0],
"end": [181, 21],
"end": [182, 22],
"slots": {
"0": {
"start": [3, 3],
"end": [18, 18]
"end": [19, 19]
},
"1": {
"start": [23, 3],
"end": [38, 18]
"end": [39, 19]
},
"2": {
"start": [43, 3],
"end": [58, 18]
"end": [59, 19]
},
"3": {
"start": [63, 3],
"end": [78, 18]
"end": [79, 19]
},
"4": {
"start": [83, 3],
"end": [98, 18]
"end": [99, 19]
},
"5": {
"start": [103, 3],
"end": [118, 18]
"end": [119, 19]
},
"6": {
"start": [123, 3],
"end": [138, 18]
"end": [139, 19]
},
"7": {
"start": [143, 3],
"end": [158, 18]
"end": [159, 19]
},
"8": {
"start": [163, 3],
"end": [178, 18]
"end": [179, 19]
}
}
}
@ -51,11 +51,11 @@
"versions": {
"567": {
"start": [0, 22],
"end": [23, 45],
"end": [24, 46],
"slots": {
"0": {
"start": [5, 5],
"end": [20, 20]
"end": [21, 21]
}
}
}
@ -66,7 +66,7 @@
"versions": {
"0": {
"start": [0, 0],
"end": [15, 15]
"end": [16, 16]
}
}
},
@ -75,7 +75,7 @@
"versions": {
"0": {
"start": [0, 64],
"end": [181, 68]
"end": [182, 69]
}
}
},
@ -84,7 +84,7 @@
"versions": {
"0": {
"start": [0, 69],
"end": [181, 73]
"end": [182, 74]
}
}
},
@ -93,7 +93,7 @@
"versions": {
"0": {
"start": [16, 0],
"end": [24, 8]
"end": [25, 9]
}
}
},
@ -102,7 +102,7 @@
"versions": {
"0": {
"start": [25, 0],
"end": [33, 8]
"end": [34, 9]
}
}
},
@ -111,7 +111,7 @@
"versions": {
"0": {
"start": [52, 0],
"end": [60, 8]
"end": [61, 9]
}
}
},
@ -120,7 +120,7 @@
"versions": {
"0": {
"start": [61, 0],
"end": [69, 8]
"end": [70, 9]
}
}
}