by argv » Fri Jul 27, 2018 10:05 pm
From
Use To Pickup:
Code: Select all
if (HighlightState == FADING_IN || HighlightState == FADING_OUT) {
double time;
if (HighlightState == FADING_IN)
time = ps.Settings.FadeInTime.GetFloat();
else
time = ps.Settings.FadeOutTime.GetFloat();
// Avoid division by zero.
// Division by zero would actually yield correct results (positive infinity), but the engine crashes instead of passing such a value through, so we have to special-case it.
if (time <= 0.)
TweenChange = 1;
else
TweenChange = 1. / (time * TICRATE);
if (HighlightState == FADING_OUT)
TweenChange = -TweenChange;
}
if (TweenChange)
Tween = clamp(Tween + TweenChange, 0., 1.);
It needs to compute how fast an animation is to run, in floating-point change per tic (TweenChange). For user-friendliness, however, the menu options represent the animation speed as total duration in seconds (ps.Settings.Fade{In,Out}Time). To get from the latter to the former, I compute 1/(time*TICRATE).
It's perfectly valid to set the durations to 0, to turn off the animation entirely. This would be represented by TweenChange ≥ 1. ∞ ≥ 1, so an infinite result would result in correct behavior (clamp(Tween + ∞, 0, 1) = 1), and wouldn't require the special case.
From [url=https://github.com/argv-minus-one/gzdoom-use-to-pickup]Use To Pickup[/url]:
[code]
if (HighlightState == FADING_IN || HighlightState == FADING_OUT) {
double time;
if (HighlightState == FADING_IN)
time = ps.Settings.FadeInTime.GetFloat();
else
time = ps.Settings.FadeOutTime.GetFloat();
// Avoid division by zero.
// Division by zero would actually yield correct results (positive infinity), but the engine crashes instead of passing such a value through, so we have to special-case it.
if (time <= 0.)
TweenChange = 1;
else
TweenChange = 1. / (time * TICRATE);
if (HighlightState == FADING_OUT)
TweenChange = -TweenChange;
}
if (TweenChange)
Tween = clamp(Tween + TweenChange, 0., 1.);
[/code]
It needs to compute how fast an animation is to run, in floating-point change per tic (TweenChange). For user-friendliness, however, the menu options represent the animation speed as total duration in seconds (ps.Settings.Fade{In,Out}Time). To get from the latter to the former, I compute 1/(time*TICRATE).
It's perfectly valid to set the durations to 0, to turn off the animation entirely. This would be represented by TweenChange ≥ 1. ∞ ≥ 1, so an infinite result would result in correct behavior (clamp(Tween + ∞, 0, 1) = 1), and wouldn't require the special case.