aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-07-06 23:34:56 +0200
committerLinnea Gräf <nea@nea.moe>2025-07-06 23:36:31 +0200
commitb09648d71258f8d4012c9b50d679f7c3db9201b2 (patch)
tree76d59ee0ef5cf098e62de287ef263b37f73d20ad /src
parentb40ae8a455d0f338d6fdb709ec830beae66eb8b2 (diff)
downloadFirmament-b09648d71258f8d4012c9b50d679f7c3db9201b2.tar.gz
Firmament-b09648d71258f8d4012c9b50d679f7c3db9201b2.tar.bz2
Firmament-b09648d71258f8d4012c9b50d679f7c3db9201b2.zip
fix: incorrect macro wheel for two items because of angle lerp near π / 2 defaulting the wrong way
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/util/render/LerpUtils.kt6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/kotlin/util/render/LerpUtils.kt b/src/main/kotlin/util/render/LerpUtils.kt
index 63a13ec..e7f226c 100644
--- a/src/main/kotlin/util/render/LerpUtils.kt
+++ b/src/main/kotlin/util/render/LerpUtils.kt
@@ -1,11 +1,15 @@
package moe.nea.firmament.util.render
import me.shedaniel.math.Color
+import kotlin.math.absoluteValue
val π = Math.PI
val τ = Math.PI * 2
-fun lerpAngle(a: Float, b: Float, progress: Float): Float {
+fun lerpAngle(a: Float, b: Float, progress: Float): Float {
// TODO: there is at least 10 mods to many in here lol
+ if (((b - a).absoluteValue - π).absoluteValue < 0.0001) {
+ return lerp(a, b, progress)
+ }
val shortestAngle = ((((b.mod(τ) - a.mod(τ)).mod(τ)) + τ + π).mod(τ)) - π
return ((a + (shortestAngle) * progress).mod(τ)).toFloat()
}