Skip to content

Commit dc53209

Browse files
committed
camera shaking: fine tune more
1 parent 17c48d9 commit dc53209

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/main/java/de/bixilon/minosoft/gui/rendering/camera/shaking/CameraShaking.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CameraShaking(
2828
private val profile: ShakingC,
2929
) {
3030
private var rotation = 0.0f
31-
private val speed = FloatAverage(10 * ProtocolDefinition.TICK_TIME * 1_000_000L, 0.0f)
31+
private val speed = FloatAverage(5 * ProtocolDefinition.TICK_TIME * 1_000_000L, 0.0f)
3232
private val physics = camera.context.connection.camera.entity.physics
3333

3434
val isEmpty: Boolean get() = rotation == 0.0f
@@ -57,15 +57,14 @@ class CameraShaking(
5757
}
5858
val time = millis()
5959
this.speed += this.physics.velocity.xz.length2().toFloat() // velocity affects how quick it goes
60-
val speed = this.speed.avg
60+
val speed = minOf(this.speed.avg, 0.25f)
6161
return bobbing(time, speed, FREQUENCY * profile.speed, STRENGTH * profile.intensity)
6262
}
6363

6464
private fun bobbing(time: Long, speed: Float, frequency: Float, intensity: Float): Float {
6565
val seconds = time / 1000.0
6666

6767
val sin = sin(seconds * frequency).toFloat()
68-
val speed = minOf(this.speed.avg, 0.25f)
6968
return (sin * speed * intensity) / MINIMUM_SPEED
7069
}
7170

@@ -81,11 +80,12 @@ class CameraShaking(
8180
fun transform(): Mat4? {
8281
if (this.rotation == 0.0f) return null
8382
return Mat4()
84-
.rotateAssign(this.rotation, Vec3(0, 0, 1))
83+
.rotateAssign(this.rotation, ROTATION)
8584
}
8685

8786
companion object {
88-
private const val STRENGTH = 0.001f
87+
private val ROTATION = Vec3(0, 0, 1)
88+
private const val STRENGTH = 0.002f
8989
private const val FREQUENCY = 10.0f
9090
private const val MINIMUM_SPEED = 0.1f
9191
}

0 commit comments

Comments
 (0)