From 3647643351c0741364ba08eecc91f7638e62f6b9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 4 Sep 2023 07:56:48 +0700 Subject: [PATCH] Circular aware chunk compilers --- .../kstarbound/client/ClientChunk.kt | 15 +++++++------- .../ru/dbotthepony/kstarbound/world/Chunk.kt | 7 ++++++- .../dbotthepony/kstarbound/world/ChunkPos.kt | 2 +- .../ru/dbotthepony/kstarbound/world/World.kt | 20 +++++++++++++++++-- .../kstarbound/world/api/ITileAccess.kt | 13 ++++++++++++ 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt index 93efbb6d..46f9de2a 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt @@ -18,7 +18,6 @@ import ru.dbotthepony.kstarbound.world.* import ru.dbotthepony.kstarbound.world.api.CHUNK_SIZE import ru.dbotthepony.kstarbound.world.api.CHUNK_SIZEd import ru.dbotthepony.kstarbound.world.api.CHUNK_SIZEf -import ru.dbotthepony.kstarbound.world.api.ITileAccess import ru.dbotthepony.kstarbound.world.api.ITileChunk import ru.dbotthepony.kstarbound.world.entities.Entity import ru.dbotthepony.kvector.arrays.Matrix4fStack @@ -29,7 +28,6 @@ import ru.dbotthepony.kvector.vector.Vector2f import ru.dbotthepony.kvector.vector.Vector3f import java.io.Closeable import java.util.LinkedList -import java.util.function.IntSupplier /** * Псевдо zPos у фоновых тайлов @@ -43,14 +41,13 @@ const val Z_LEVEL_LIQUID = 10000 class ClientChunk(world: ClientWorld, pos: ChunkPos) : Chunk(world, pos), Closeable { val state: GLStateTracker get() = world.client.gl - private inner class TileLayerRenderer(private val view: () -> ITileChunk, private val isBackground: Boolean) : AutoCloseable { + private inner class TileLayerRenderer(private val view: ITileChunk, private val isBackground: Boolean) : AutoCloseable { private val layers = TileLayerList() val bakedMeshes = LinkedList>() var isDirty = true fun bake() { isDirty = false - val view = view() if (state.isSameThread()) { for (mesh in bakedMeshes) { @@ -63,6 +60,8 @@ class ClientChunk(world: ClientWorld, pos: ChunkPos) : Chunk, This : Chunk, This : Chunk { constructor(pos: IStruct2i) : this(pos.component1(), pos.component2()) - val firstBlock get() = Vector2i(tileX, tileY) + val firstTile get() = Vector2i(tileX, tileY) val lastBlock get() = Vector2i(((x + 1) shl CHUNK_SIZE_BITS) - 1, ((y + 1) shl CHUNK_SIZE_BITS) - 1) /** diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt index 4f9cc661..c0fc5be3 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt @@ -41,6 +41,8 @@ abstract class World, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk