mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
mesher: don't lock chunk sections
They should not be locked, because once the data changes the thread is interrupted. The interrupt will come too late otherwise
This commit is contained in:
parent
9487bf6e9c
commit
553c7aeaa2
@ -28,7 +28,6 @@ import de.bixilon.minosoft.data.registries.fluid.DefaultFluids
|
||||
import de.bixilon.minosoft.data.registries.fluid.FlowableFluid
|
||||
import de.bixilon.minosoft.data.registries.fluid.Fluid
|
||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||
import de.bixilon.minosoft.data.world.World
|
||||
import de.bixilon.minosoft.data.world.chunk.Chunk
|
||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
@ -48,21 +47,18 @@ import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh
|
||||
import de.bixilon.minosoft.gui.rendering.world.preparer.FluidSectionPreparer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.KUtil.isTrue
|
||||
import de.bixilon.minosoft.util.chunk.ChunkUtil.acquire
|
||||
import de.bixilon.minosoft.util.chunk.ChunkUtil.release
|
||||
import java.util.*
|
||||
import kotlin.math.atan2
|
||||
|
||||
class FluidCullSectionPreparer(
|
||||
val renderWindow: RenderWindow,
|
||||
) : FluidSectionPreparer {
|
||||
private val world: World = renderWindow.connection.world
|
||||
private val water = renderWindow.connection.registries.fluidRegistry[DefaultFluids.WATER]
|
||||
private val tintManager = renderWindow.tintManager
|
||||
|
||||
|
||||
// ToDo: Should this be combined with the solid renderer (but we'd need to render faces twice, because of cullface)
|
||||
private fun _prepareFluid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbours: Array<ChunkSection?>, neighbourChunks: Array<Chunk>, mesh: WorldMesh) {
|
||||
override fun prepareFluid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbours: Array<ChunkSection?>, neighbourChunks: Array<Chunk>, mesh: WorldMesh) {
|
||||
val blocks = section.blocks
|
||||
|
||||
val random = Random(0L)
|
||||
@ -197,6 +193,7 @@ class FluidCullSectionPreparer(
|
||||
v1 = cornerHeights[0]
|
||||
v2 = cornerHeights[1]
|
||||
}
|
||||
|
||||
1 -> {
|
||||
faceX = 1.0f
|
||||
faceZ = 1.0f
|
||||
@ -204,11 +201,13 @@ class FluidCullSectionPreparer(
|
||||
v1 = cornerHeights[2]
|
||||
v2 = cornerHeights[3]
|
||||
}
|
||||
|
||||
2 -> {
|
||||
faceZ = 1.0f
|
||||
v1 = cornerHeights[3]
|
||||
v2 = cornerHeights[0]
|
||||
}
|
||||
|
||||
3 -> {
|
||||
faceX = 1.0f
|
||||
faceXEnd = 1.0f
|
||||
@ -315,17 +314,6 @@ class FluidCullSectionPreparer(
|
||||
return totalHeight / count
|
||||
}
|
||||
|
||||
override fun prepareFluid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbours: Array<ChunkSection?>, neighbourChunks: Array<Chunk>, mesh: WorldMesh) {
|
||||
section.acquire()
|
||||
neighbours.acquire()
|
||||
try {
|
||||
_prepareFluid(chunkPosition, sectionHeight, chunk, section, neighbours, neighbourChunks, mesh)
|
||||
} finally {
|
||||
section.release()
|
||||
neighbours.release()
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val TEXTURE_CENTER = 1.0f / 2.0f
|
||||
private const val FLUID_TINT_INDEX = 0
|
||||
|
@ -40,8 +40,6 @@ import de.bixilon.minosoft.gui.rendering.world.entities.OnlyMeshedBlockEntityRen
|
||||
import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh
|
||||
import de.bixilon.minosoft.gui.rendering.world.preparer.SolidSectionPreparer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.chunk.ChunkUtil.acquire
|
||||
import de.bixilon.minosoft.util.chunk.ChunkUtil.release
|
||||
import java.util.*
|
||||
|
||||
class SolidCullSectionPreparer(
|
||||
@ -58,7 +56,7 @@ class SolidCullSectionPreparer(
|
||||
profile.performance::fastBedrock.profileWatch(this, true, profile) { this.fastBedrock = it }
|
||||
}
|
||||
|
||||
private fun _prepareSolid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbours: Array<ChunkSection?>, neighbourChunks: Array<Chunk>, mesh: WorldMesh) {
|
||||
override fun prepareSolid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbours: Array<ChunkSection?>, neighbourChunks: Array<Chunk>, mesh: WorldMesh) {
|
||||
val random = Random(0L)
|
||||
|
||||
val randomBlockModels = profile.antiMoirePattern
|
||||
@ -216,17 +214,6 @@ class SolidCullSectionPreparer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun prepareSolid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbours: Array<ChunkSection?>, neighbourChunks: Array<Chunk>, mesh: WorldMesh) {
|
||||
section.acquire()
|
||||
neighbours.acquire()
|
||||
try {
|
||||
_prepareSolid(chunkPosition, sectionHeight, chunk, section, neighbours, neighbourChunks, mesh)
|
||||
} finally {
|
||||
section.release()
|
||||
neighbours.release()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SELF_LIGHT_INDEX = 6 // after all directions
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user