mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
calculate section occlusion on demand
In headless mode occlusion does not matter and chunks that are invisible or occluded also don't matter
This commit is contained in:
parent
4f68567199
commit
c4cd6c4856
@ -44,9 +44,8 @@ class ChunkSection(
|
||||
var neighbours: Array<ChunkSection?>? = null
|
||||
|
||||
fun tick(connection: PlayConnection, chunkPosition: Vec2i, sectionHeight: Int, random: Random) {
|
||||
if (blockEntities.isEmpty) {
|
||||
return
|
||||
}
|
||||
if (blockEntities.isEmpty) return
|
||||
|
||||
val offset = Vec3i.of(chunkPosition, sectionHeight)
|
||||
val position = Vec3i()
|
||||
|
||||
|
@ -26,6 +26,7 @@ class SectionOcclusion(
|
||||
private val provider: BlockSectionDataProvider,
|
||||
) {
|
||||
private var occlusion = EMPTY
|
||||
private var calculate = false
|
||||
|
||||
fun clear(notify: Boolean) {
|
||||
update(EMPTY, notify)
|
||||
@ -39,6 +40,8 @@ class SectionOcclusion(
|
||||
}
|
||||
|
||||
fun recalculate(notify: Boolean) {
|
||||
if (!calculate) return
|
||||
|
||||
if (provider.isEmpty) {
|
||||
clear(notify)
|
||||
return
|
||||
@ -180,10 +183,14 @@ class SectionOcclusion(
|
||||
if (`in` == out) {
|
||||
return false
|
||||
}
|
||||
return occlusion[CubeDirections.getIndex(`in`, out)]
|
||||
return isOccluded(CubeDirections.getIndex(`in`, out))
|
||||
}
|
||||
|
||||
fun isOccluded(index: Int): Boolean {
|
||||
if (!calculate) {
|
||||
calculate = true
|
||||
recalculate(false)
|
||||
}
|
||||
return occlusion[index]
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user