mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
rendering: make preparing faster
* Around 40% faster
This commit is contained in:
parent
cead36894b
commit
da11f1f0a5
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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]!!,
|
||||
|
Loading…
x
Reference in New Issue
Block a user