mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
worldgen estimation change; common worldgen variables moved to Worldgen.kt
This commit is contained in:
@@ -300,10 +300,12 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
App.fontGame.draw(batch, Lang["CONTEXT_GENERATOR_SEED"], drawX - 4, drawY + sizeSelY + inputLineY2)
|
||||
|
||||
val (wx, wy) = TerrarumIngame.NEW_WORLD_SIZE[sizeSelector.selection]
|
||||
val etaMin = Worldgen.getEstimationSec(wx, wy).div(60f).roundToInt().coerceAtLeast(1)
|
||||
val etaSec = Worldgen.getEstimationSec(wx, wy)
|
||||
val etaMin = etaSec.div(60f).roundToInt().coerceAtLeast(1)
|
||||
val etaText = Lang.getAndUseTemplate("CONTEXT_ESTIMATED_MINUTES_PLURAL", true, etaMin)
|
||||
val etaTextPrint = etaText + (if (App.IS_DEVELOPMENT_BUILD) " ($etaSec s)" else "")
|
||||
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, etaText, width, drawX, drawY + sizeSelY + inputLineY3)
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, etaTextPrint, width, drawX, drawY + sizeSelY + inputLineY3)
|
||||
}
|
||||
else if (mode == 1) {
|
||||
// code input labels
|
||||
|
||||
@@ -195,10 +195,12 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
|
||||
App.fontGame.draw(batch, Lang["CONTEXT_PLACE_COORDINATE"], drawX - 4, drawY + sizeSelY + inputLineY2)
|
||||
|
||||
val (wx, wy) = TerrarumIngame.NEW_WORLD_SIZE[sizeSelector.selection]
|
||||
val etaMin = Worldgen.getEstimationSec(wx, wy).div(60f).roundToInt().coerceAtLeast(1)
|
||||
val etaSec = Worldgen.getEstimationSec(wx, wy)
|
||||
val etaMin = etaSec.div(60f).roundToInt().coerceAtLeast(1)
|
||||
val etaText = Lang.getAndUseTemplate("CONTEXT_ESTIMATED_MINUTES_PLURAL", true, etaMin)
|
||||
val etaTextPrint = etaText + (if (App.IS_DEVELOPMENT_BUILD) " ($etaSec s)" else "")
|
||||
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, etaText, width, drawX, drawY + sizeSelY + inputLineY3)
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, etaTextPrint, width, drawX, drawY + sizeSelY + inputLineY3)
|
||||
|
||||
// memory gauge
|
||||
val chunksUsed = full.chunksUsed
|
||||
|
||||
@@ -19,19 +19,15 @@ import kotlin.math.sin
|
||||
*/
|
||||
class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, params) {
|
||||
|
||||
private val threadExecutor = TerrarumIngame.worldgenThreadExecutor
|
||||
|
||||
private val genSlices = max(threadExecutor.threadCount, world.width / 9)
|
||||
|
||||
private val YHEIGHT_MAGIC = 2800.0 / 3.0
|
||||
private val YHEIGHT_DIVISOR = 2.0 / 7.0
|
||||
|
||||
override fun getDone(loadscreen: LoadScreenBase) {
|
||||
// loadscreen.progress.set((loadscreen.progress.get() + 0x1_000000_000000L) and 0x7FFF_000000_000000L)
|
||||
|
||||
threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(genSlices).map { xs ->
|
||||
threadExecutor.submit {
|
||||
Worldgen.threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(Worldgen.genSlices).map { xs ->
|
||||
Worldgen.threadExecutor.submit {
|
||||
val localJoise = getGenerator(seed, params as BiomegenParams)
|
||||
for (x in xs) {
|
||||
for (y in 0 until world.height) {
|
||||
@@ -49,7 +45,7 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
}
|
||||
}
|
||||
|
||||
threadExecutor.join()
|
||||
Worldgen.threadExecutor.join()
|
||||
|
||||
App.printdbg(this, "Waking up Worldgen")
|
||||
}
|
||||
|
||||
@@ -18,17 +18,13 @@ import kotlin.math.sqrt
|
||||
* Created by minjaesong on 2023-10-25.
|
||||
*/
|
||||
class Oregen(world: GameWorld, private val caveAttenuateBiasScaled: ModuleScaleDomain, seed: Long, private val ores: List<OregenParams>) : Gen(world, seed) {
|
||||
|
||||
private val threadExecutor = TerrarumIngame.worldgenThreadExecutor
|
||||
private val genSlices = max(threadExecutor.threadCount, world.width / 9)
|
||||
|
||||
override fun getDone(loadscreen: LoadScreenBase) {
|
||||
loadscreen.stageValue += 1
|
||||
loadscreen.progress.set(0L)
|
||||
|
||||
threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(genSlices).mapIndexed { i, xs ->
|
||||
threadExecutor.submit {
|
||||
Worldgen.threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(Worldgen.genSlices).mapIndexed { i, xs ->
|
||||
Worldgen.threadExecutor.submit {
|
||||
val localJoise = getGenerator(seed)
|
||||
for (x in xs) {
|
||||
val sampleTheta = (x.toDouble() / world.width) * TWO_PI
|
||||
@@ -39,7 +35,7 @@ class Oregen(world: GameWorld, private val caveAttenuateBiasScaled: ModuleScaleD
|
||||
}
|
||||
}
|
||||
|
||||
threadExecutor.join()
|
||||
Worldgen.threadExecutor.join()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,20 +20,17 @@ import kotlin.math.max
|
||||
*/
|
||||
class OregenAutotiling(world: GameWorld, seed: Long, val tilingModes: HashMap<ItemID, String>) : Gen(world, seed) {
|
||||
|
||||
private val threadExecutor = TerrarumIngame.worldgenThreadExecutor
|
||||
private val genSlices = max(threadExecutor.threadCount, world.width / 9)
|
||||
|
||||
override fun getDone(loadscreen: LoadScreenBase) {
|
||||
threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(genSlices).mapIndexed { i, xs ->
|
||||
threadExecutor.submit {
|
||||
Worldgen.threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(Worldgen.genSlices).mapIndexed { i, xs ->
|
||||
Worldgen.threadExecutor.submit {
|
||||
for (x in xs) {
|
||||
draw(x)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
threadExecutor.join()
|
||||
Worldgen.threadExecutor.join()
|
||||
}
|
||||
|
||||
private fun getHashCoord(x: Int, y: Int, mod: Int) =
|
||||
|
||||
@@ -24,11 +24,6 @@ class Terragen(world: GameWorld, val highlandLowlandSelectCache: ModuleCache, se
|
||||
const val YHEIGHT_DIVISOR = 2.0 / 7.0
|
||||
}
|
||||
|
||||
private val threadExecutor = TerrarumIngame.worldgenThreadExecutor
|
||||
|
||||
private val genSlices = max(threadExecutor.threadCount, world.width / 9)
|
||||
|
||||
|
||||
private val dirtStoneDitherSize = 3 // actual dither size will be double of this value
|
||||
private val stoneSlateDitherSize = 4
|
||||
|
||||
@@ -36,9 +31,9 @@ class Terragen(world: GameWorld, val highlandLowlandSelectCache: ModuleCache, se
|
||||
loadscreen.stageValue += 1
|
||||
loadscreen.progress.set(0L)
|
||||
|
||||
threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(genSlices).mapIndexed { i, xs ->
|
||||
threadExecutor.submit {
|
||||
Worldgen.threadExecutor.renew()
|
||||
(0 until world.width).sliceEvenly(Worldgen.genSlices).mapIndexed { i, xs ->
|
||||
Worldgen.threadExecutor.submit {
|
||||
val localJoise = getGenerator(seed, params as TerragenParams)
|
||||
for (x in xs) {
|
||||
val sampleTheta = (x.toDouble() / world.width) * TWO_PI
|
||||
@@ -49,7 +44,7 @@ class Terragen(world: GameWorld, val highlandLowlandSelectCache: ModuleCache, se
|
||||
}
|
||||
}
|
||||
|
||||
threadExecutor.join()
|
||||
Worldgen.threadExecutor.join()
|
||||
|
||||
printdbg(this, "Waking up Worldgen")
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.LoadScreenBase
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import kotlin.math.max
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
/**
|
||||
@@ -21,6 +23,9 @@ object Worldgen {
|
||||
lateinit var params: WorldgenParams
|
||||
private set
|
||||
|
||||
val threadExecutor = TerrarumIngame.worldgenThreadExecutor
|
||||
var genSlices = -1
|
||||
|
||||
private val threadLock = java.lang.Object()
|
||||
|
||||
fun attachMap(world: GameWorld, genParams: WorldgenParams) {
|
||||
@@ -62,6 +67,8 @@ object Worldgen {
|
||||
fun generateMap(loadscreen: LoadScreenBase) {
|
||||
highlandLowlandSelectCache = getHighlandLowlandSelectCache(params.terragenParams, params.seed)
|
||||
caveAttenuateBiasScaled = getCaveAttenuateBiasScaled(highlandLowlandSelectCache, params.terragenParams)
|
||||
genSlices = max(threadExecutor.threadCount, world.width / 9)
|
||||
|
||||
|
||||
val jobs = getJobs()
|
||||
|
||||
@@ -99,7 +106,7 @@ object Worldgen {
|
||||
data class Work(val loadingScreenName: String, val theWork: Gen, val tags: List<String>)
|
||||
|
||||
fun getEstimationSec(width: Int, height: Int): Long {
|
||||
return (23.15 * 1.25 * (48600000.0 / bogoflops) * ((width * height) / 40095000.0) * (32.0 / THREAD_COUNT)).roundToLong()
|
||||
return (23.15 * 1.25 * (48600000.0 / bogoflops) * ((width * height) / 20095000.0) * (32.0 / THREAD_COUNT)).roundToLong()
|
||||
}
|
||||
|
||||
private fun getHighlandLowlandSelectCache(params: TerragenParams, seed: Long): ModuleCache {
|
||||
|
||||
Reference in New Issue
Block a user