mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
heightmap: use section height
index is prune to errors and not very natural
This commit is contained in:
parent
dc43b0c266
commit
d2d45008b0
@ -43,17 +43,11 @@ abstract class ChunkHeightmap(protected val chunk: Chunk) : Heightmap {
|
||||
}
|
||||
|
||||
private fun trace(position: InChunkPosition, notify: Boolean) {
|
||||
val sections = chunk.sections
|
||||
|
||||
var y = Int.MIN_VALUE
|
||||
val index = position.xz
|
||||
|
||||
sectionLoop@ for (sectionIndex in (position.y.sectionHeight - chunk.minSection) downTo 0) {
|
||||
if (sectionIndex >= sections.size) {
|
||||
// starting from above world
|
||||
continue
|
||||
}
|
||||
val section = sections[sectionIndex] ?: continue
|
||||
sectionLoop@ for (sectionHeight in position.y.sectionHeight downTo chunk.minSection) {
|
||||
val section = chunk[sectionHeight] ?: continue
|
||||
if (section.blocks.isEmpty) continue
|
||||
|
||||
val min = section.blocks.minPosition
|
||||
@ -63,11 +57,11 @@ abstract class ChunkHeightmap(protected val chunk: Chunk) : Heightmap {
|
||||
|
||||
|
||||
for (sectionY in max.y downTo min.y) {
|
||||
val state = section.blocks[InSectionPosition((sectionY shl 8) or index)] ?: continue
|
||||
val state = section.blocks[InSectionPosition(index).with(y = sectionY)] ?: continue
|
||||
val pass = passes(state)
|
||||
if (pass == HeightmapPass.PASSES) continue
|
||||
|
||||
y = (sectionIndex + chunk.minSection) * ProtocolDefinition.SECTION_HEIGHT_Y + sectionY
|
||||
y = sectionHeight * ProtocolDefinition.SECTION_HEIGHT_Y + sectionY
|
||||
if (pass == HeightmapPass.ABOVE) y++
|
||||
|
||||
break@sectionLoop
|
||||
|
Loading…
x
Reference in New Issue
Block a user