Use double precision for exponential step sizes
Otherwise you will get issues with rounding errors if someone ever tries to have smoothing times over a second or so.
This commit is contained in:
parent
6a40cc9916
commit
e8764e7327
1 changed files with 2 additions and 2 deletions
|
@ -171,13 +171,13 @@ impl<T: Smoothable> Smoother<T> {
|
||||||
// We need to solve `current * (step_size ^ steps_left) = target` for
|
// We need to solve `current * (step_size ^ steps_left) = target` for
|
||||||
// `step_size`
|
// `step_size`
|
||||||
nih_debug_assert_ne!(current, 0.0);
|
nih_debug_assert_ne!(current, 0.0);
|
||||||
(self.target.to_f32() / current).powf((steps_left as f32).recip())
|
((self.target.to_f32() / current) as f64).powf((steps_left as f64).recip()) as f32
|
||||||
}
|
}
|
||||||
// In this case the step size value is the coefficient the current value will be
|
// In this case the step size value is the coefficient the current value will be
|
||||||
// multiplied by, while the target value is multipled by one minus the coefficient. This
|
// multiplied by, while the target value is multipled by one minus the coefficient. This
|
||||||
// reaches 99.99% of the target value after `steps_left`. The smoother will snap to the
|
// reaches 99.99% of the target value after `steps_left`. The smoother will snap to the
|
||||||
// target value after that point.
|
// target value after that point.
|
||||||
SmoothingStyle::Exponential(_) => 0.0001f32.powf(1.0 / steps_left as f32),
|
SmoothingStyle::Exponential(_) => 0.0001f64.powf(1.0 / steps_left as f64) as f32,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue