diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt index 2208c3ae0..f86730401 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt @@ -72,13 +72,12 @@ class Cavegen(world: GameWorld, isFinal: Boolean, val highlandLowlandSelectCache it.setBias(params.caveAttenuateBias) // (0.5+) adjust the "concentration" of the cave gen. Lower = larger voids })} - val caveAttenuateBias = caveAttenuateBias0.let { - ModuleScaleOffset().also { - it.setSource(caveAttenuateBias0) - it.setScale(params.caveAttenuateScale) - } + val caveAttenuateBias = ModuleScaleOffset().also { + it.setSource(caveAttenuateBias0) + it.setScale(params.caveAttenuateScale) } + val caveShapeAttenuate = ModuleCombiner().also { it.setType(ModuleCombiner.CombinerType.MULT) it.setSource(0, caveShape) diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt index af2efd7d8..2eb621872 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt @@ -250,6 +250,7 @@ interface TerragenParams { val caveShapeFreq: Double //adjust the "density" of the caves val caveAttenuateScale: Double // used with the caveAttenuateBias, controls the "concentration" of the cave gen val caveAttenuateBias: Double // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) + val caveAttenuateScale1: Double // used with the caveAttenuateBias, controls the "concentration" of the cave gen val caveAttenuateBias1: Double // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) val caveSelectThre: Double // also adjust this if you've touched the bias value. Number can be greater than 1.0 val caveBlockageFractalFreq: Double @@ -269,6 +270,7 @@ data class TerragenParamsAlpha1( override val caveShapeFreq: Double = 4.0, //adjust the "density" of the caves override val caveAttenuateScale: Double = 1.0, // used with the caveAttenuateBias, controls the "concentration" of the cave gen override val caveAttenuateBias: Double = 0.90, // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) + override val caveAttenuateScale1: Double = 1.0, // used with the caveAttenuateBias, controls the "concentration" of the cave gen override val caveAttenuateBias1: Double = 0.90, // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) override val caveSelectThre: Double = 0.918, // also adjust this if you've touched the bias value. Number can be greater than 1.0 override val caveBlockageFractalFreq: Double = 8.88, @@ -291,6 +293,7 @@ data class TerragenParamsAlpha2( override val caveShapeFreq: Double = 4.0, //adjust the "density" of the caves override val caveAttenuateScale: Double = 0.94, // used with the caveAttenuateBias, controls the "concentration" of the cave gen override val caveAttenuateBias: Double = 0.95, // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) + override val caveAttenuateScale1: Double = 0.90, // used with the caveAttenuateBias, controls the "concentration" of the cave gen override val caveAttenuateBias1: Double = 0.90, // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) override val caveSelectThre: Double = 0.915, // also adjust this if you've touched the bias value. Number can be greater than 1.0 override val caveBlockageFractalFreq: Double = 8.88, diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt index d81983f0d..908dfaf8a 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt @@ -431,11 +431,9 @@ object Worldgen { it.setBias(params.caveAttenuateBias1) // (0.5+) adjust the "concentration" of the cave gen. Lower = larger voids })} - val caveAttenuateBiasForOres = caveAttenuateBias1.let { - ModuleScaleOffset().also { - it.setSource(caveAttenuateBias1) - it.setScale(params.caveAttenuateScale) - } + val caveAttenuateBiasForOres = ModuleScaleOffset().also { + it.setSource(caveAttenuateBias1) + it.setScale(params.caveAttenuateScale1) } val scale = ModuleScaleDomain().also { diff --git a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt index 93e1faa4b..bf8127016 100644 --- a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt +++ b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt @@ -83,7 +83,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() { private var generationTime = 0f private var today = "" - private val NM_TERR = TerragenTest to TerragenParamsAlpha2() + private val NM_TERR = TerragenTest(TerragenParamsAlpha2()) private val NM_BIOME = BiomeMaker to BiomegenParams() private val NOISEMAKER = NM_TERR @@ -120,9 +120,11 @@ class WorldgenNoiseSandbox : ApplicationAdapter() { font.draw(batch, "Seed: $seed", 8f, 8f + 1*20) - font.draw(batch, "caveAttenuateScale=${NM_TERR.second.caveAttenuateScale}", 8f, 8f + 2*20) - font.draw(batch, "caveAttenuateBias=${NM_TERR.second.caveAttenuateBias}", 8f, 8f + 3*20) - font.draw(batch, "caveSelectThre=${NM_TERR.second.caveSelectThre}", 8f, 8f + 4*20) + font.draw(batch, "caveAttenuateScale=${NM_TERR.params.caveAttenuateScale}", 8f, 8f + 2*20) + font.draw(batch, "caveAttenuateScale1=${NM_TERR.params.caveAttenuateScale1}", 8f, 8f + 3*20) + font.draw(batch, "caveAttenuateBias=${NM_TERR.params.caveAttenuateBias}", 8f, 8f + 4*20) + font.draw(batch, "caveAttenuateBias1=${NM_TERR.params.caveAttenuateBias1}", 8f, 8f +5*20) + font.draw(batch, "caveSelectThre=${NM_TERR.params.caveSelectThre}", 8f, 8f + 6*20) } } @@ -189,7 +191,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() { private fun getSY(y: Int): Double = y - (getClampedHeight() - YHEIGHT_MAGIC) * YHEIGHT_DIVISOR // Q&D offsetting to make ratio of sky:ground to be constant - private fun renderNoise(noiseMaker: Pair, callback: () -> Unit = {}) { + private fun renderNoise(noiseMaker: NoiseMaker, callback: () -> Unit = {}) { generationStartTime = System.nanoTime() // erase first @@ -204,7 +206,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() { Thread { val runnables: List = (0 until testTex.width).sliceEvenly(genSlices).map { range -> { - val localJoise = noiseMaker.first.getGenerator(seed, noiseMaker.second) + val localJoise = noiseMaker.getGenerator(seed, 0) for (x in range) { for (y in 0 until NOISEBOX_HEIGHT) { val sampleTheta = (x.toDouble() / NOISEBOX_WIDTH) * TWO_PI @@ -212,9 +214,9 @@ class WorldgenNoiseSandbox : ApplicationAdapter() { sin(sampleTheta) * sampleOffset + sampleOffset // plus sampleOffset to make only val sampleZ = cos(sampleTheta) * sampleOffset + sampleOffset // positive points are to be sampled - val sampleY = getSY(y) + val sampleY = getSY(y) //+ 10000 - noiseMaker.first.draw(x, y, localJoise.mapIndexed { index, it -> + noiseMaker.draw(x, y, localJoise.mapIndexed { index, it -> it.get(sampleX, sampleY, sampleZ) }, testTex) } @@ -335,7 +337,7 @@ internal object BiomeMaker : NoiseMaker { } // http://accidentalnoise.sourceforge.net/minecraftworlds.html -internal object TerragenTest : NoiseMaker { +internal class TerragenTest(val params: TerragenParams) : NoiseMaker { private infix fun Color.mul(other: Color) = this.mul(other) @@ -387,7 +389,7 @@ internal object TerragenTest : NoiseMaker { ) private val terragenYscaling = (NOISEBOX_HEIGHT / 2400.0).pow(0.75) - private val terragenTiers = listOf(.0, .5, 1.5, 4.0).map { it * terragenYscaling } // pow 1.0 for 1-to-1 scaling; 0.75 is used to make deep-rock layers actually deep for huge world size + private val terragenTiers = (params.terragenTiers).map { it * terragenYscaling } // pow 1.0 for 1-to-1 scaling; 0.75 is used to make deep-rock layers actually deep for huge world size override fun draw(x: Int, y: Int, noiseValue: List, outTex: Pixmap) { val terr = noiseValue[0].tiered(terragenTiers) @@ -432,8 +434,7 @@ internal object TerragenTest : NoiseMaker { } - override fun getGenerator(seed: Long, params: Any): List { - val params = params as TerragenParams + override fun getGenerator(seed: Long, wtf: Any): List { val lowlandMagic: Long = 0x41A21A114DBE56 // Maria Lindberg val highlandMagic: Long = 0x0114E091 // Olive Oyl val mountainMagic: Long = 0x115AA4DE2504 // Lisa Anderson @@ -611,20 +612,18 @@ internal object TerragenTest : NoiseMaker { it.setBias(params.caveAttenuateBias1) // (0.5+) adjust the "concentration" of the cave gen. Lower = larger voids })} - val caveAttenuateBiasForTerr = caveAttenuateBias0.let { - ModuleScaleOffset().also { - it.setSource(caveAttenuateBias0) - it.setScale(params.caveAttenuateScale) - } + val caveAttenuateBiasForTerr = ModuleScaleOffset().also { + it.setSource(caveAttenuateBias0) + it.setScale(params.caveAttenuateScale) } - val caveAttenuateBiasForOres = caveAttenuateBias0.let { - ModuleScaleOffset().also { - it.setSource(caveAttenuateBias1) - it.setScale(params.caveAttenuateScale) - } + + val caveAttenuateBiasForOres = ModuleScaleOffset().also { + it.setSource(caveAttenuateBias1) + it.setScale(params.caveAttenuateScale1) } + val caveShapeAttenuate = ModuleCombiner().also { it.setType(ModuleCombiner.CombinerType.MULT) it.setSource(0, caveShape)