Skip to content

Commit

Permalink
improve fluid rendering performance, fix some fluid rendering bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bixilon committed Feb 29, 2024
1 parent 5802589 commit 51993e1
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2Util.EMPTY
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.rotate
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.EMPTY
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.chunkPosition
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.inChunkPosition
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
Expand All @@ -65,8 +66,7 @@ class FluidSectionMesher(
fun mesh(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbourChunks: Array<Chunk>, neighbours: Array<ChunkSection?>, mesh: ChunkMeshes) {
val blocks = section.blocks

var position: Vec3i
var rendered = false
var position = Vec3i.EMPTY
var tint: Int

val cameraOffset = context.camera.offset.offset
Expand Down Expand Up @@ -108,9 +108,10 @@ class FluidSectionMesher(

if (skip.isTrue) continue

position = Vec3i(offsetX + x, offsetY + y, offsetZ + z)
tint = tints.getFluidTint(chunk, fluid, height, position.x, position.y, position.z) ?: Colors.WHITE_RGB
var rendered = false
position.x = offsetX + x; position.y = offsetY + y; position.z = offsetZ + z

tint = tints.getFluidTint(chunk, fluid, height, position.x, position.y, position.z) ?: Colors.WHITE_RGB
val cornerHeights = floatArrayOf(
getCornerHeight(chunk, chunkPosition, position, fluid),
getCornerHeight(chunk, chunkPosition, position + Directions.EAST, fluid),
Expand All @@ -120,7 +121,7 @@ class FluidSectionMesher(

val offsetPosition = Vec3(position - cameraOffset)

if (cornerHeights[0] < 1.0f && !skip[Directions.O_UP]) {
if (cornerHeights[0] <= 1.0f && !skip[Directions.O_UP]) {
val velocity = fluid.getVelocity(state, position, chunk)
val still = velocity.x == 0.0 && velocity.z == 0.0
val texture: Texture
Expand Down

0 comments on commit 51993e1

Please sign in to comment.