KStarbound/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt

47 lines
1.5 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ru.dbotthepony.kstarbound.client
import ru.dbotthepony.kstarbound.client.render.renderLayeredList
import ru.dbotthepony.kstarbound.math.encasingChunkPosAABB
import ru.dbotthepony.kstarbound.world.*
import ru.dbotthepony.kvector.util2d.AABB
class ClientWorld(val client: StarboundClient, seed: Long = 0L) : World<ClientWorld, ClientChunk>(seed) {
override fun chunkFactory(pos: ChunkPos): ClientChunk {
return ClientChunk(
world = this,
pos = pos,
)
}
/**
* Отрисовывает этот с обрезкой невидимой геометрии с точки зрения [size] в Starbound Units
*
* Все координаты "местности" сохраняются, поэтому, если отрисовывать слишком далеко от 0, 0
* то геометрия может начать искажаться из-за погрешности плавающей запятой
*
* Обрезает всю заведомо невидимую геометрию на основе аргументов mins и maxs (в пикселях)
*/
fun render(
size: AABB,
) {
val determineRenderers = ArrayList<ClientChunk>()
for (chunk in collectInternal(size.encasingChunkPosAABB())) {
determineRenderers.add(chunk.chunk)
chunk.chunk.bake()
}
renderLayeredList(client.gl.matrixStack, determineRenderers)
for (renderer in determineRenderers) {
renderer.renderDebug()
}
}
override fun thinkInner(delta: Double) {
for (ent in entities) {
ent.think(delta)
}
}
}