Fix attack/decay interpolation (#114)
This commit is contained in:
@@ -95,27 +95,19 @@ class Envelope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (phase == EnvelopePhase.Attack) {
|
if (phase == EnvelopePhase.Attack) {
|
||||||
current = if (attack == 0.0) {
|
val denom = if (attack == 0.0) 1.0 else attack
|
||||||
targetValue
|
|
||||||
} else {
|
|
||||||
val t = clamp(cycleTime / attack, 0.0, 1.0)
|
|
||||||
|
|
||||||
mix(restValue, targetValue, exponentialEasing(t, easingFactor))
|
val t = clamp(cycleTime / denom, 0.0, 1.0)
|
||||||
}
|
|
||||||
|
current = mix(restValue, targetValue, exponentialEasing(t, easingFactor))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phase == EnvelopePhase.Decay) {
|
if (phase == EnvelopePhase.Decay) {
|
||||||
current = if (decay == 0.0) {
|
val denom = if (decay == 0.0) 1.0 else decay
|
||||||
initialRestValue
|
|
||||||
} else {
|
|
||||||
val t = clamp((cycleTime - attack) / decay, 0.0, 1.0)
|
|
||||||
|
|
||||||
mix(targetValue, initialRestValue, exponentialEasing(t, easingFactor))
|
val t = clamp((cycleTime - attack) / denom, 0.0, 1.0)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current.isNaN()) {
|
current = mix(targetValue, initialRestValue, exponentialEasing(t, easingFactor))
|
||||||
println("current is NaN, $phase")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user