mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 21:44:05 +09:00
torch should flicker less erratic now
This commit is contained in:
@@ -90,6 +90,9 @@ internal object WeatherMixer : RNGConsumer {
|
||||
private var astrumOffY = 0f
|
||||
|
||||
private val clouds = SortedArrayList<WeatherObjectCloud>()
|
||||
|
||||
// val weatherbox: Weatherbox
|
||||
|
||||
var cloudsSpawned = 0; private set
|
||||
private var windVector = Vector3(-1f, 0f, 0.1f) // this is a direction vector
|
||||
val cloudSpawnMax: Int
|
||||
|
||||
47
src/net/torvald/terrarum/weather/Weatherbox.kt
Normal file
47
src/net/torvald/terrarum/weather/Weatherbox.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
package net.torvald.terrarum.weather
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import java.util.*
|
||||
|
||||
class Weatherbox {
|
||||
|
||||
val RNG: HQRNG
|
||||
get() = WeatherMixer.RNG
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
data class WeatherStateBox(var x: Double, var p0: Double, var p1: Double, var p2: Double, var p3: Double) {
|
||||
|
||||
fun get() = interpolateCatmullRom(x, p0, p1, p2, p3)
|
||||
|
||||
fun getAndUpdate(xdelta: Double, RNG: Random): Double {
|
||||
synchronized(RNG) {
|
||||
val y = get()
|
||||
x += xdelta
|
||||
while (x >= 1.0) {
|
||||
x -= 1.0
|
||||
p0 = p1
|
||||
p1 = p2
|
||||
p2 = p3
|
||||
p3 = RNG.nextDouble()
|
||||
}
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
// fixed with T=0.5
|
||||
fun interpolateCatmullRom(u: Double, p0: Double, p1: Double, p2: Double, p3: Double): Double {
|
||||
val c1: Double = p1
|
||||
val c2: Double = -0.5 * p0 + 0.5 * p2
|
||||
val c3: Double = p0 - 2.5 * p1 + 2.0 * p2 - 0.5 * p3
|
||||
val c4: Double = -0.5 * p0 + 1.5 * p1 - 1.5 * p2 + 0.5 * p3
|
||||
return (((c4 * u + c3) * u + c2) * u + c1)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user