rendering: make preparing faster

* Around 40% faster
This commit is contained in:
Bixilon 2021-03-25 17:06:38 +01:00
parent cead36894b
commit da11f1f0a5
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 18 additions and 15 deletions

View File

@ -77,7 +77,7 @@ data class BlockPosition(val x: Int, val y: Int, val z: Int) {
return "($x $y $z)"
}
infix fun add(input: Vec3): Vec3 {
infix operator fun plus(input: Vec3): Vec3 {
return Vec3(input.x + x, input.y + y, input.z + z)
}
}

View File

@ -93,7 +93,6 @@ class BlockRenderer : BlockRenderInterface {
override fun render(blockState: BlockState, lightAccessor: LightAccessor, tintColor: RGBColor?, position: BlockPosition, meshCollection: ChunkMeshCollection, neighbourBlocks: Array<BlockState?>, world: World) {
for (direction in Directions.DIRECTIONS) {
for (element in elements) {
val cullFace = cullFaces[direction.ordinal] != null
var neighbourBlockFullFace = false
@ -103,12 +102,16 @@ class BlockRenderer : BlockRenderInterface {
if (model.fullFaceDirections[testDirection.ordinal] != null && model.transparentFaces[testDirection.ordinal] == null) {
neighbourBlockFullFace = true
break
}
}
}
if (neighbourBlockFullFace && cullFace) {
continue
}
for (element in elements) {
element.render(tintColor, position, lightAccessor, textureMapping, direction, meshCollection)
}
}

View File

@ -79,7 +79,7 @@ class ElementRenderer(parent: BlockModelElement, val rotation: Vec3, uvLock: Boo
fun createQuad(drawPositions: Array<Vec3>, texturePositions: Array<Vec2?>) {
for (vertex in DRAW_ODER) {
val input = drawPositions[vertex.first]
val output = position add input
val output = position + input
mesh.addVertex(
position = output,
textureCoordinates = texturePositions[vertex.second]!!,