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)"
|
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)
|
return Vec3(input.x + x, input.y + y, input.z + z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,22 +93,25 @@ class BlockRenderer : BlockRenderInterface {
|
|||||||
|
|
||||||
override fun render(blockState: BlockState, lightAccessor: LightAccessor, tintColor: RGBColor?, position: BlockPosition, meshCollection: ChunkMeshCollection, neighbourBlocks: Array<BlockState?>, world: World) {
|
override fun render(blockState: BlockState, lightAccessor: LightAccessor, tintColor: RGBColor?, position: BlockPosition, meshCollection: ChunkMeshCollection, neighbourBlocks: Array<BlockState?>, world: World) {
|
||||||
for (direction in Directions.DIRECTIONS) {
|
for (direction in Directions.DIRECTIONS) {
|
||||||
for (element in elements) {
|
val cullFace = cullFaces[direction.ordinal] != null
|
||||||
val cullFace = cullFaces[direction.ordinal] != null
|
|
||||||
|
var neighbourBlockFullFace = false
|
||||||
|
neighbourBlocks[direction.ordinal]?.renders?.let { // ToDo: Improve this
|
||||||
|
val testDirection = direction.inverse
|
||||||
|
for (model in it) {
|
||||||
|
if (model.fullFaceDirections[testDirection.ordinal] != null && model.transparentFaces[testDirection.ordinal] == null) {
|
||||||
|
neighbourBlockFullFace = true
|
||||||
|
break
|
||||||
|
|
||||||
var neighbourBlockFullFace = false
|
|
||||||
neighbourBlocks[direction.ordinal]?.renders?.let { // ToDo: Improve this
|
|
||||||
val testDirection = direction.inverse
|
|
||||||
for (model in it) {
|
|
||||||
if (model.fullFaceDirections[testDirection.ordinal] != null && model.transparentFaces[testDirection.ordinal] == null) {
|
|
||||||
neighbourBlockFullFace = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (neighbourBlockFullFace && cullFace) {
|
}
|
||||||
continue
|
|
||||||
}
|
if (neighbourBlockFullFace && cullFace) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for (element in elements) {
|
||||||
element.render(tintColor, position, lightAccessor, textureMapping, direction, meshCollection)
|
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?>) {
|
fun createQuad(drawPositions: Array<Vec3>, texturePositions: Array<Vec2?>) {
|
||||||
for (vertex in DRAW_ODER) {
|
for (vertex in DRAW_ODER) {
|
||||||
val input = drawPositions[vertex.first]
|
val input = drawPositions[vertex.first]
|
||||||
val output = position add input
|
val output = position + input
|
||||||
mesh.addVertex(
|
mesh.addVertex(
|
||||||
position = output,
|
position = output,
|
||||||
textureCoordinates = texturePositions[vertex.second]!!,
|
textureCoordinates = texturePositions[vertex.second]!!,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user