mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Easing nodes - Fixed going into a broken state when delay is 0
Numeric easing node - Fixed node not functioning at all Event cycle node - Fixed node not functioning at all
This commit is contained in:
1 parent
6638eae126
commit
cf58acc7d2
4 files changed
+23
-9
No files matched your search
@@ -29,9 +29,10 @@ public class NumericEasingNode : Node
|
||||
public override void Evaluate()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
float inputValue = Input.Value;
|
||||
|
||||
// If the value changed reset progress
|
||||
if (Math.Abs(_targetValue - Input.Value) > 0.001f)
|
||||
if (Math.Abs(_targetValue - inputValue) > 0.001f)
|
||||
{
|
||||
_sourceValue = _currentValue;
|
||||
_targetValue = Input.Value;
|
||||
@@ -55,10 +56,11 @@ public class NumericEasingNode : Node
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float easingTime = EasingTime.Value != 0f ? EasingTime.Value : 1f;
|
||||
TimeSpan delta = DateTime.Now - _lastEvaluate;
|
||||
|
||||
// In case of odd delta's, keep progress between 0f and 1f
|
||||
_progress = Math.Clamp(_progress + (float) delta.TotalMilliseconds / EasingTime.Value, 0f, 1f);
|
||||
_progress = Math.Clamp(_progress + (float) delta.TotalMilliseconds / easingTime, 0f, 1f);
|
||||
|
||||
double eased = _sourceValue + (_targetValue - _sourceValue) * Easings.Interpolate(_progress, EasingFunction.Value);
|
||||
_currentValue = (float) eased;
|
||||
|
||||
@@ -56,10 +56,11 @@ public class SKColorEasingNode : Node
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float easingTime = EasingTime.Value != 0f ? EasingTime.Value : 1f;
|
||||
TimeSpan delta = DateTime.Now - _lastEvaluate;
|
||||
|
||||
// In case of odd delta's, keep progress between 0f and 1f
|
||||
_progress = Math.Clamp(_progress + (float) delta.TotalMilliseconds / EasingTime.Value, 0f, 1f);
|
||||
_progress = Math.Clamp(_progress + (float) delta.TotalMilliseconds / easingTime, 0f, 1f);
|
||||
_currentValue = _sourceValue.Interpolate(_targetValue, (float) Easings.Interpolate(_progress, EasingFunction.Value));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user