mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
fluid renderer: use unsafe get to calculate corners height
Improves the performance
This commit is contained in:
parent
f313efe214
commit
410b06432e
@ -73,6 +73,8 @@ class Chunk(
|
|||||||
|
|
||||||
operator fun get(position: Vec3i): BlockState? = get(position.x, position.y, position.z)
|
operator fun get(position: Vec3i): BlockState? = get(position.x, position.y, position.z)
|
||||||
|
|
||||||
|
fun unsafeGet(position: Vec3i): BlockState? = unsafeGet(position.x, position.y, position.z)
|
||||||
|
|
||||||
fun set(x: Int, y: Int, z: Int, blockState: BlockState?, blockEntity: BlockEntity? = null) {
|
fun set(x: Int, y: Int, z: Int, blockState: BlockState?, blockEntity: BlockEntity? = null) {
|
||||||
val section = getOrPut(y.sectionHeight) ?: return
|
val section = getOrPut(y.sectionHeight) ?: return
|
||||||
section.blocks[x, y.inSectionHeight, z] = blockState
|
section.blocks[x, y.inSectionHeight, z] = blockState
|
||||||
|
@ -61,11 +61,7 @@ class FluidCullSectionPreparer(
|
|||||||
|
|
||||||
// ToDo: Should this be combined with the solid renderer (but we'd need to render faces twice, because of cullface)
|
// ToDo: Should this be combined with the solid renderer (but we'd need to render faces twice, because of cullface)
|
||||||
override 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 isLowestSection = sectionHeight == chunk.lowestSection
|
|
||||||
val isHighestSection = sectionHeight == chunk.highestSection
|
|
||||||
val blocks = section.blocks
|
val blocks = section.blocks
|
||||||
val sectionLight = section.light
|
|
||||||
section.acquire()
|
section.acquire()
|
||||||
neighbours.acquire()
|
neighbours.acquire()
|
||||||
|
|
||||||
@ -284,11 +280,11 @@ class FluidCullSectionPreparer(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val inChunkPosition = blockPosition.inChunkPosition
|
val inChunkPosition = blockPosition.inChunkPosition
|
||||||
if (fluid.matches(lastChunk[inChunkPosition + Directions.UP])) {
|
if (fluid.matches(lastChunk.unsafeGet(inChunkPosition + Directions.UP))) {
|
||||||
return 1.0f
|
return 1.0f
|
||||||
}
|
}
|
||||||
|
|
||||||
val blockState = lastChunk[inChunkPosition]
|
val blockState = lastChunk.unsafeGet(inChunkPosition)
|
||||||
if (blockState == null) {
|
if (blockState == null) {
|
||||||
count++
|
count++
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user