mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -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)
|
||||
|
||||
lateinit var inverse: Directions
|
||||
lateinit var inversed: Directions
|
||||
private set
|
||||
|
||||
private fun inverse(): Directions {
|
||||
@ -113,7 +113,7 @@ enum class Directions(val directionVector: Vec3i) {
|
||||
|
||||
init {
|
||||
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()
|
||||
override val faceBorderSizes: Array<Array<FaceSize>?> = arrayOfNulls(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) {
|
||||
val rotation = Java.glm.radians(data.toVec3())
|
||||
@ -117,16 +117,22 @@ class BlockRenderer : BlockRenderInterface {
|
||||
return
|
||||
}
|
||||
for (direction in Directions.DIRECTIONS) {
|
||||
val invertedDirection = direction.inverse
|
||||
val rotatedDirection = directionMapping[direction]!!
|
||||
val invertedDirection = direction.inversed
|
||||
var isNeighbourTransparent = false
|
||||
var neighbourFaceSize: Array<FaceSize>? = null
|
||||
val neighbourBlock = neighbourBlocks[direction.ordinal]
|
||||
// ToDo: We need to rotate the direction first and then rotate it
|
||||
neighbourBlock?.getBlockRenderer(blockPosition + directionMapping[direction])?.let {
|
||||
if (it.transparentFaces[invertedDirection.ordinal]) {
|
||||
neighbourBlock?.getBlockRenderer(blockPosition + direction)?.let {
|
||||
val itDirection = if (it is BlockRenderer) {
|
||||
it.directionMapping[invertedDirection]!!
|
||||
} else {
|
||||
invertedDirection
|
||||
}
|
||||
|
||||
if (it.transparentFaces[itDirection.ordinal]) {
|
||||
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.
|
||||
@ -140,7 +146,7 @@ class BlockRenderer : BlockRenderInterface {
|
||||
return@let
|
||||
}
|
||||
|
||||
val elementFaceBorderSize = element.faceBorderSize[direction.ordinal] ?: return@let
|
||||
val elementFaceBorderSize = element.faceBorderSize[rotatedDirection.ordinal] ?: return@let
|
||||
for (size in it) {
|
||||
if (elementFaceBorderSize.start.x < size.start.x || elementFaceBorderSize.start.y < size.start.y) {
|
||||
return@let
|
||||
|
@ -44,14 +44,14 @@ class FluidRenderer(
|
||||
if (isFlowing || Directions.SIDES.contains(direction)) {
|
||||
face.scale(0.5)
|
||||
texture = flowingTexture
|
||||
if (! Directions.SIDES.contains(direction)) {
|
||||
if (!Directions.SIDES.contains(direction)) {
|
||||
val angle = getRotationAngle(heights)
|
||||
face.rotate(angle)
|
||||
}
|
||||
} else {
|
||||
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
|
||||
}
|
||||
val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[direction.ordinal]
|
||||
|
Loading…
x
Reference in New Issue
Block a user