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)
|
return ChunkPos(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun toLong(): Long {
|
||||||
|
return toLong(x, y)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ZERO = ChunkPos(0, 0)
|
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 {
|
fun fromTilePosition(input: IStruct2i): ChunkPos {
|
||||||
val (x, y) = input
|
val (x, y) = input
|
||||||
return ChunkPos(tileToChunkComponent(x), tileToChunkComponent(y))
|
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.Object2DoubleAVLTreeMap
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
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.ContactImpulse
|
||||||
import ru.dbotthepony.kbox2d.api.IContactFilter
|
import ru.dbotthepony.kbox2d.api.IContactFilter
|
||||||
import ru.dbotthepony.kbox2d.api.IContactListener
|
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 seed: Long,
|
||||||
val widthInChunks: Int
|
val widthInChunks: Int
|
||||||
) {
|
) {
|
||||||
protected val chunkMap = Object2ObjectAVLTreeMap<ChunkPos, ChunkType> cmp@{ a, b ->
|
protected val chunkMap = Object2ObjectOpenHashMap<ChunkPos, ChunkType>()
|
||||||
return@cmp a.compareTo(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
//protected val chunkMap = HashMap<ChunkPos, ChunkType>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Является ли мир "сферическим"
|
* Является ли мир "сферическим"
|
||||||
|
Loading…
Reference in New Issue
Block a user