calculate cloud speed from time

Now their speed is not frame rate specific anymore
This commit is contained in:
Bixilon 2022-12-06 12:55:02 +01:00
parent 251c257bed
commit e2f90cb625
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 13 additions and 2 deletions

View File

@ -126,7 +126,7 @@ class CloudLayer(
}
private fun getCloudSpeed(): Float {
return randomSpeed + 0.05f
return randomSpeed + 0.1f
}
private fun updateOffset() {
@ -134,7 +134,7 @@ class CloudLayer(
return
}
var offset = this.offset
offset += getCloudSpeed()
offset += getCloudSpeed() * clouds.delta * 10
if (offset > MAX_OFFSET) {
offset -= MAX_OFFSET
}

View File

@ -18,6 +18,7 @@ import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.kotlinglm.vec4.Vec4
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.kutil.observer.DataObserver.Companion.observe
import de.bixilon.kutil.time.TimeUtil.millis
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.world.time.DayPhases
import de.bixilon.minosoft.data.world.time.MoonPhases
@ -59,6 +60,10 @@ class CloudRenderer(
private set
private var toUnload: MutableSet<CloudLayer> = mutableSetOf()
private var time = millis()
var delta = 0.0f
private set
override val skipOpaque: Boolean
get() = !sky.effects.clouds || !sky.profile.clouds.enabled || connection.profiles.block.viewDistance < 3 || layers.isEmpty()
@ -113,6 +118,12 @@ class CloudRenderer(
if (layers.size != nextLayers) {
updateLayers(nextLayers)
}
val time = millis()
val delta = time - this.time
this.delta = delta / 1000.0f
this.time = time
for (layer in layers) {
layer.prepareAsync()
}