Use hash table for chunk map
This commit is contained in:
parent
64b777c11a
commit
8a03d326f4
@ -117,9 +117,17 @@ class ChunkPos(val x: Int, val y: Int) : Comparable<ChunkPos> {
|
||||
return ChunkPos(x, y)
|
||||
}
|
||||
|
||||
fun toLong(): Long {
|
||||
return toLong(x, y)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ZERO = ChunkPos(0, 0)
|
||||
|
||||
fun toLong(x: Int, y: Int): Long {
|
||||
return x.toLong() or (y.toLong() shl 32)
|
||||
}
|
||||
|
||||
fun fromTilePosition(input: IStruct2i): ChunkPos {
|
||||
val (x, y) = input
|
||||
return ChunkPos(tileToChunkComponent(x), tileToChunkComponent(y))
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList
|
||||
import it.unimi.dsi.fastutil.objects.Object2DoubleAVLTreeMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
||||
import ru.dbotthepony.kbox2d.api.ContactImpulse
|
||||
import ru.dbotthepony.kbox2d.api.IContactFilter
|
||||
import ru.dbotthepony.kbox2d.api.IContactListener
|
||||
@ -129,11 +130,7 @@ abstract class World<This : World<This, ChunkType>, ChunkType : Chunk<This, Chun
|
||||
val seed: Long,
|
||||
val widthInChunks: Int
|
||||
) {
|
||||
protected val chunkMap = Object2ObjectAVLTreeMap<ChunkPos, ChunkType> cmp@{ a, b ->
|
||||
return@cmp a.compareTo(b)
|
||||
}
|
||||
|
||||
//protected val chunkMap = HashMap<ChunkPos, ChunkType>()
|
||||
protected val chunkMap = Object2ObjectOpenHashMap<ChunkPos, ChunkType>()
|
||||
|
||||
/**
|
||||
* Является ли мир "сферическим"
|
||||
|
Loading…
Reference in New Issue
Block a user