mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 16:36:58 -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
|
var neighbours: Array<ChunkSection?>? = null
|
||||||
|
|
||||||
fun tick(connection: PlayConnection, chunkPosition: Vec2i, sectionHeight: Int, random: Random) {
|
fun tick(connection: PlayConnection, chunkPosition: Vec2i, sectionHeight: Int, random: Random) {
|
||||||
if (blockEntities.isEmpty) {
|
if (blockEntities.isEmpty) return
|
||||||
return
|
|
||||||
}
|
|
||||||
val offset = Vec3i.of(chunkPosition, sectionHeight)
|
val offset = Vec3i.of(chunkPosition, sectionHeight)
|
||||||
val position = Vec3i()
|
val position = Vec3i()
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ class SectionOcclusion(
|
|||||||
private val provider: BlockSectionDataProvider,
|
private val provider: BlockSectionDataProvider,
|
||||||
) {
|
) {
|
||||||
private var occlusion = EMPTY
|
private var occlusion = EMPTY
|
||||||
|
private var calculate = false
|
||||||
|
|
||||||
fun clear(notify: Boolean) {
|
fun clear(notify: Boolean) {
|
||||||
update(EMPTY, notify)
|
update(EMPTY, notify)
|
||||||
@ -39,6 +40,8 @@ class SectionOcclusion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun recalculate(notify: Boolean) {
|
fun recalculate(notify: Boolean) {
|
||||||
|
if (!calculate) return
|
||||||
|
|
||||||
if (provider.isEmpty) {
|
if (provider.isEmpty) {
|
||||||
clear(notify)
|
clear(notify)
|
||||||
return
|
return
|
||||||
@ -180,10 +183,14 @@ class SectionOcclusion(
|
|||||||
if (`in` == out) {
|
if (`in` == out) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return occlusion[CubeDirections.getIndex(`in`, out)]
|
return isOccluded(CubeDirections.getIndex(`in`, out))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isOccluded(index: Int): Boolean {
|
fun isOccluded(index: Int): Boolean {
|
||||||
|
if (!calculate) {
|
||||||
|
calculate = true
|
||||||
|
recalculate(false)
|
||||||
|
}
|
||||||
return occlusion[index]
|
return occlusion[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user