mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
camera: calculate targets and visibility graph parallel
This commit is contained in:
parent
63154beeee
commit
ced8e710ce
@ -309,7 +309,7 @@ class World(
|
||||
val offset = Vec3i.EMPTY + { random.nextInt(-radius, radius) }
|
||||
val blockPosition = origin + offset
|
||||
|
||||
val blockState = chunk.getWorld(offset, origin, blockPosition) ?: return
|
||||
val blockState = chunk.traceBlock(offset, origin, blockPosition) ?: return
|
||||
|
||||
blockState.block.randomTick(connection, blockState, blockPosition, random)
|
||||
}
|
||||
|
@ -377,16 +377,16 @@ class Chunk(
|
||||
}
|
||||
}
|
||||
|
||||
fun getWorld(offset: Vec3i, origin: Vec3i, blockPosition: Vec3i = origin + offset): BlockState? {
|
||||
fun traceBlock(offset: Vec3i, origin: Vec3i, blockPosition: Vec3i = origin + offset): BlockState? {
|
||||
val originChunkPosition = origin.chunkPosition
|
||||
val targetChunkPosition = blockPosition.chunkPosition
|
||||
|
||||
val deltaChunkPosition = targetChunkPosition - originChunkPosition
|
||||
|
||||
return getWorld(blockPosition.inChunkPosition, deltaChunkPosition)
|
||||
return traceBlock(blockPosition.inChunkPosition, deltaChunkPosition)
|
||||
}
|
||||
|
||||
private fun getWorld(inChunkSectionPosition: Vec3i, chunkOffset: Vec2i): BlockState? {
|
||||
private fun traceBlock(inChunkSectionPosition: Vec3i, chunkOffset: Vec2i): BlockState? {
|
||||
if (chunkOffset.x == 0 && chunkOffset.y == 0) {
|
||||
return this[inChunkSectionPosition]
|
||||
}
|
||||
@ -394,19 +394,19 @@ class Chunk(
|
||||
|
||||
if (chunkOffset.x > 0) {
|
||||
chunkOffset.x--
|
||||
return neighbours[6].getWorld(inChunkSectionPosition, chunkOffset)
|
||||
return neighbours[6].traceBlock(inChunkSectionPosition, chunkOffset)
|
||||
}
|
||||
if (chunkOffset.x < 0) {
|
||||
chunkOffset.x++
|
||||
return neighbours[1].getWorld(inChunkSectionPosition, chunkOffset)
|
||||
return neighbours[1].traceBlock(inChunkSectionPosition, chunkOffset)
|
||||
}
|
||||
if (chunkOffset.y > 0) {
|
||||
chunkOffset.y--
|
||||
return neighbours[4].getWorld(inChunkSectionPosition, chunkOffset)
|
||||
return neighbours[4].traceBlock(inChunkSectionPosition, chunkOffset)
|
||||
}
|
||||
if (chunkOffset.y < 0) {
|
||||
chunkOffset.y++
|
||||
return neighbours[3].getWorld(inChunkSectionPosition, chunkOffset)
|
||||
return neighbours[3].traceBlock(inChunkSectionPosition, chunkOffset)
|
||||
}
|
||||
|
||||
Broken("Can not get chunk from offset: $chunkOffset")
|
||||
|
@ -13,6 +13,10 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.camera
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.time.TimeUtil
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
@ -68,8 +72,10 @@ class Camera(
|
||||
entity._draw(TimeUtil.millis)
|
||||
}
|
||||
matrixHandler.draw()
|
||||
visibilityGraph.draw()
|
||||
targetHandler.raycast()
|
||||
val latch = CountUpAndDownLatch(2)
|
||||
DefaultThreadPool += ThreadPoolRunnable(ThreadPool.Priorities.HIGHER) { visibilityGraph.draw();latch.dec() }
|
||||
DefaultThreadPool += ThreadPoolRunnable(ThreadPool.Priorities.HIGHER) { targetHandler.raycast();latch.dec() }
|
||||
fogManager.draw()
|
||||
latch.await()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user