mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -04:00
rendering: fix water
This commit is contained in:
parent
935467305e
commit
fa6990b0b2
@ -112,6 +112,12 @@ class BlockModelFace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun scale(scaleFactor: Double) {
|
||||||
|
for ((i, position) in positions.withIndex()) {
|
||||||
|
positions[i] = position * scaleFactor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private fun uvToFloat(uv: Float): Float {
|
private fun uvToFloat(uv: Float): Float {
|
||||||
return (uv) / BlockModelElement.BLOCK_RESOLUTION
|
return (uv) / BlockModelElement.BLOCK_RESOLUTION
|
||||||
|
@ -28,7 +28,8 @@ class FluidRenderer(private val stillTextureName: String, private val flowingTex
|
|||||||
val modelMatrix = Mat4().translate(position.toVec3())
|
val modelMatrix = Mat4().translate(position.toVec3())
|
||||||
val lightLevel = lightAccessor.getLightLevel(position)
|
val lightLevel = lightAccessor.getLightLevel(position)
|
||||||
val heights = calculateHeights(neighbourBlocks, blockState, world, position)
|
val heights = calculateHeights(neighbourBlocks, blockState, world, position)
|
||||||
val (texture, angle) = if (isLiquidFlowing(heights)) {
|
val isFlowing = isLiquidFlowing(heights)
|
||||||
|
val (texture, angle) = if (isFlowing) {
|
||||||
Pair(flowing, getRotationAngle(heights))
|
Pair(flowing, getRotationAngle(heights))
|
||||||
} else {
|
} else {
|
||||||
Pair(still, 0f)
|
Pair(still, 0f)
|
||||||
@ -39,6 +40,9 @@ class FluidRenderer(private val stillTextureName: String, private val flowingTex
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val face = BlockModelFace(VecUtil.EMPTY_VECTOR, Vec3(VecUtil.BLOCK_SIZE_VECTOR.x, positions[7].y * 8, VecUtil.BLOCK_SIZE_VECTOR.z), direction)
|
val face = BlockModelFace(VecUtil.EMPTY_VECTOR, Vec3(VecUtil.BLOCK_SIZE_VECTOR.x, positions[7].y * 8, VecUtil.BLOCK_SIZE_VECTOR.z), direction)
|
||||||
|
if (isFlowing) {
|
||||||
|
face.scale(0.5)
|
||||||
|
}
|
||||||
face.rotate(angle)
|
face.rotate(angle)
|
||||||
val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[direction.ordinal]
|
val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[direction.ordinal]
|
||||||
val drawPositions = arrayOf(positions[positionTemplate[0]], positions[positionTemplate[1]], positions[positionTemplate[2]], positions[positionTemplate[3]])
|
val drawPositions = arrayOf(positions[positionTemplate[0]], positions[positionTemplate[1]], positions[positionTemplate[2]], positions[positionTemplate[3]])
|
||||||
@ -68,7 +72,7 @@ class FluidRenderer(private val stillTextureName: String, private val flowingTex
|
|||||||
for (direction in directions!!) {
|
for (direction in directions!!) {
|
||||||
angle += getRotationAngle(direction)
|
angle += getRotationAngle(direction)
|
||||||
}
|
}
|
||||||
return angle / directions.size
|
return if (position == 1) { angle / directions.size } else { angle / directions.size + glm.PI.toFloat() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRotationAngle(direction: Directions): Float {
|
private fun getRotationAngle(direction: Directions): Float {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user