mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-24 04:57:50 -04:00
improve memory usage and performance a bit
This commit is contained in:
parent
877f212cee
commit
eccca7d29b
@ -25,7 +25,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTex
|
||||
|
||||
class CharData(
|
||||
private val renderWindow: RenderWindow,
|
||||
val char: Int,
|
||||
val texture: AbstractTexture?,
|
||||
val width: Int,
|
||||
val scaledWidth: Int,
|
||||
|
@ -99,7 +99,6 @@ class BitmapFontProvider(
|
||||
|
||||
val charData = CharData(
|
||||
renderWindow = renderWindow,
|
||||
char = char,
|
||||
texture = texture,
|
||||
width = width,
|
||||
scaledWidth = scaledWidth,
|
||||
|
@ -24,7 +24,7 @@ import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class LegacyUnicodeFontProvider(
|
||||
private val renderWindow: RenderWindow,
|
||||
renderWindow: RenderWindow,
|
||||
data: Map<String, Any>,
|
||||
) : FontProvider {
|
||||
private val chars: Array<CharData?> = arrayOfNulls(1 shl Char.SIZE_BITS)
|
||||
@ -68,7 +68,6 @@ class LegacyUnicodeFontProvider(
|
||||
|
||||
val charData = CharData(
|
||||
renderWindow = renderWindow,
|
||||
char = char,
|
||||
texture = texture,
|
||||
width = width,
|
||||
scaledWidth = scaledWidth,
|
||||
|
@ -34,10 +34,9 @@ class SpaceFontProvider(
|
||||
data["advances"]?.toJsonObject()?.let {
|
||||
for ((charData, spacing) in it) {
|
||||
val char = charData.codePoints().iterator().nextInt()
|
||||
chars[char] = CharData(renderWindow, char, null, spacing.toInt(), spacing.toInt(), Vec2.EMPTY, Vec2.EMPTY)
|
||||
chars[char] = CharData(renderWindow, null, spacing.toInt(), spacing.toInt(), Vec2.EMPTY, Vec2.EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) = Unit
|
||||
|
@ -27,7 +27,7 @@ import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh
|
||||
class BakedFace(
|
||||
override val sizeStart: Vec2,
|
||||
override val sizeEnd: Vec2,
|
||||
val positions: Array<Vec3>,
|
||||
val positions: FloatArray,
|
||||
val uv: Array<Vec2>,
|
||||
val shade: Float,
|
||||
val tintIndex: Int,
|
||||
@ -48,8 +48,8 @@ class BakedFace(
|
||||
color.b *= (tint and 0xFF) / RGBColor.COLOR_FLOAT_DIVIDER
|
||||
}
|
||||
for ((index, textureIndex) in meshToUse.order) {
|
||||
val indexPosition = positions[index].array
|
||||
meshToUse.addVertex(floatArrayOf(indexPosition[0] + position[0], indexPosition[1] + position[1], indexPosition[2] + position[2]), uv[textureIndex], texture, color.rgb, light)
|
||||
val indexOffset = index * 3
|
||||
meshToUse.addVertex(floatArrayOf(positions[indexOffset + 0] + position[0], positions[indexOffset + 1] + position[1], positions[indexOffset + 2] + position[2]), uv[textureIndex], texture, color.rgb, light)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,10 +133,17 @@ class UnbakedBlockStateModel(
|
||||
Directions.WEST, Directions.EAST -> 0.6f
|
||||
}
|
||||
}
|
||||
val floatPositions = FloatArray(4 * 3) // positions.size * 3
|
||||
for ((index, position) in positions.withIndex()) {
|
||||
floatPositions[index * 3 + 0] = position.x
|
||||
floatPositions[index * 3 + 1] = position.y
|
||||
floatPositions[index * 3 + 2] = position.z
|
||||
}
|
||||
|
||||
val bakedFace = BakedFace(
|
||||
sizeStart = sizeStart,
|
||||
sizeEnd = sizeEnd,
|
||||
positions = positions,
|
||||
positions = floatPositions,
|
||||
uv = texturePositions,
|
||||
shade = shade,
|
||||
tintIndex = face.tintIndex,
|
||||
|
Loading…
x
Reference in New Issue
Block a user