mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 02:45:13 -04:00
rendering: fix some bugs in new block mesher
This commit is contained in:
parent
55d990954f
commit
ef990159e7
@ -28,7 +28,7 @@ enum class Directions(val directionVector: Vec3i) {
|
|||||||
|
|
||||||
val floatDirectionVector = Vec3(directionVector)
|
val floatDirectionVector = Vec3(directionVector)
|
||||||
|
|
||||||
lateinit var inverse: Directions
|
lateinit var inversed: Directions
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private fun inverse(): Directions {
|
private fun inverse(): Directions {
|
||||||
@ -113,7 +113,7 @@ enum class Directions(val directionVector: Vec3i) {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
for (direction in DIRECTIONS) {
|
for (direction in DIRECTIONS) {
|
||||||
direction.inverse = direction.inverse()
|
direction.inversed = direction.inverse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class BlockRenderer : BlockRenderInterface {
|
|||||||
private val textureMapping: MutableMap<String, Texture> = mutableMapOf()
|
private val textureMapping: MutableMap<String, Texture> = mutableMapOf()
|
||||||
override val faceBorderSizes: Array<Array<FaceSize>?> = arrayOfNulls(Directions.DIRECTIONS.size)
|
override val faceBorderSizes: Array<Array<FaceSize>?> = arrayOfNulls(Directions.DIRECTIONS.size)
|
||||||
override val transparentFaces: BooleanArray = BooleanArray(Directions.DIRECTIONS.size)
|
override val transparentFaces: BooleanArray = BooleanArray(Directions.DIRECTIONS.size)
|
||||||
private val directionMapping: HashBiMap<Directions, Directions> = HashBiMap.create()
|
val directionMapping: HashBiMap<Directions, Directions> = HashBiMap.create()
|
||||||
|
|
||||||
constructor(data: JsonObject, parent: BlockModel) {
|
constructor(data: JsonObject, parent: BlockModel) {
|
||||||
val rotation = Java.glm.radians(data.toVec3())
|
val rotation = Java.glm.radians(data.toVec3())
|
||||||
@ -117,16 +117,22 @@ class BlockRenderer : BlockRenderInterface {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (direction in Directions.DIRECTIONS) {
|
for (direction in Directions.DIRECTIONS) {
|
||||||
val invertedDirection = direction.inverse
|
val rotatedDirection = directionMapping[direction]!!
|
||||||
|
val invertedDirection = direction.inversed
|
||||||
var isNeighbourTransparent = false
|
var isNeighbourTransparent = false
|
||||||
var neighbourFaceSize: Array<FaceSize>? = null
|
var neighbourFaceSize: Array<FaceSize>? = null
|
||||||
val neighbourBlock = neighbourBlocks[direction.ordinal]
|
val neighbourBlock = neighbourBlocks[direction.ordinal]
|
||||||
// ToDo: We need to rotate the direction first and then rotate it
|
neighbourBlock?.getBlockRenderer(blockPosition + direction)?.let {
|
||||||
neighbourBlock?.getBlockRenderer(blockPosition + directionMapping[direction])?.let {
|
val itDirection = if (it is BlockRenderer) {
|
||||||
if (it.transparentFaces[invertedDirection.ordinal]) {
|
it.directionMapping[invertedDirection]!!
|
||||||
|
} else {
|
||||||
|
invertedDirection
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it.transparentFaces[itDirection.ordinal]) {
|
||||||
isNeighbourTransparent = true
|
isNeighbourTransparent = true
|
||||||
}
|
}
|
||||||
neighbourFaceSize = it.faceBorderSizes[invertedDirection.ordinal]
|
neighbourFaceSize = it.faceBorderSizes[itDirection.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo: Should we preserve the cullface attribute? It seems to has no point here.
|
// ToDo: Should we preserve the cullface attribute? It seems to has no point here.
|
||||||
@ -140,7 +146,7 @@ class BlockRenderer : BlockRenderInterface {
|
|||||||
return@let
|
return@let
|
||||||
}
|
}
|
||||||
|
|
||||||
val elementFaceBorderSize = element.faceBorderSize[direction.ordinal] ?: return@let
|
val elementFaceBorderSize = element.faceBorderSize[rotatedDirection.ordinal] ?: return@let
|
||||||
for (size in it) {
|
for (size in it) {
|
||||||
if (elementFaceBorderSize.start.x < size.start.x || elementFaceBorderSize.start.y < size.start.y) {
|
if (elementFaceBorderSize.start.x < size.start.x || elementFaceBorderSize.start.y < size.start.y) {
|
||||||
return@let
|
return@let
|
||||||
|
@ -51,7 +51,7 @@ class FluidRenderer(
|
|||||||
} else {
|
} else {
|
||||||
texture = stillTexture
|
texture = stillTexture
|
||||||
}
|
}
|
||||||
if (isBlockSameFluid(neighbourBlocks[direction.ordinal]) || neighbourBlocks[direction.ordinal]?.getBlockRenderer(blockPosition + direction)?.faceBorderSizes?.let { it[direction.inverse.ordinal] != null } == true && direction != Directions.UP) {
|
if (isBlockSameFluid(neighbourBlocks[direction.ordinal]) || neighbourBlocks[direction.ordinal]?.getBlockRenderer(blockPosition + direction)?.faceBorderSizes?.let { it[direction.inversed.ordinal] != null } == true && direction != Directions.UP) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[direction.ordinal]
|
val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[direction.ordinal]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user