improve block preparing performance

This commit is contained in:
Bixilon 2021-07-08 18:23:15 +02:00
parent 831b77dc90
commit b18b9804ef
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -33,7 +33,7 @@ import glm_.vec3.Vec3
class BlockRenderer(data: Map<String, Any>, model: BlockModel) : WorldEntryRenderer {
private val cullFaces: Array<Directions?> = arrayOfNulls(Directions.VALUES.size)
val textures: MutableMap<String, String> = mutableMapOf()
private val elements: MutableSet<ElementRenderer> = mutableSetOf()
private val elements: Array<ElementRenderer>
val textureMapping: MutableMap<String, Texture> = mutableMapOf()
override val faceBorderSizes: Array<Array<FaceSize>?> = arrayOfNulls(Directions.VALUES.size)
override val transparentFaces: BooleanArray = BooleanArray(Directions.VALUES.size)
@ -43,7 +43,7 @@ class BlockRenderer(data: Map<String, Any>, model: BlockModel) : WorldEntryRende
val rotation = data.toVec3().rad
createDirectionMapping(rotation)
val newElements = ElementRenderer.createElements(data, model, rotation, directionMapping)
this.elements.addAll(newElements.reversed()) // reverse drawing order (for e.g. grass block side overlays
this.elements = (newElements.reversed()).toTypedArray() // reverse drawing order (for e.g. grass block side overlays
textures.putAll(model.textures)
}