Lowest value on menu sliders is not 0 at first with arrows
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Lowest value on menu sliders is not 0 at first with arrows
When using the left arrow key to move a slider to its lowest value, it first sets the value to some different number like 7.45058e-10, then sets it properly to 0 when you use left arrow key again, so you have to use left arrow key one extra time when it's at 0 to really set it to 0. I noticed this while using the "crosshairscale" slider in a Git build, wondering why the crosshair didn't appear at first when I turned the scaling down to 0.00.
- Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Lowest value on menu sliders is not 0 at first with arro
Welcome to the joy that's called floating point math.
Re: Lowest value on menu sliders is not 0 at first with arro
This also affects GZDoom's vid_brightness "Brightness" slider when setting it back to 0 in the middle of the slider.
Re: Lowest value on menu sliders is not 0 at first with arro
Not sure if there's any real way to fix this outside of clipping the display values to 4-5 decimal places.
You can rest assured though that anything e-10 is a really small number.
You can rest assured though that anything e-10 is a really small number.
Re: Lowest value on menu sliders is not 0 at first with arro
The only way I can think of is something like this:
Code: Select all
float AdjustSliderValue(float value, float minValue, float maxValue, int numSteps)
{
int maxStep = numSteps - 1;
float sliderLength = (maxValue - minValue);
int sliderStepValue = std::round((value - minValue) * maxStep / sliderLength);
float t = sliderStepValue / (float)maxStep;
return minValue * (1.0f - t) + maxValue * t;
}
- Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Lowest value on menu sliders is not 0 at first with arro
I chose the brute force approach of simply forcing small numbers to zero, it seems the only place where it actually causes problems.
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: Lowest value on menu sliders is not 0 at first with arro
This can be closed, then.
http://forum.zdoom.org/viewtopic.php?f=2&t=53088
http://forum.zdoom.org/viewtopic.php?f=2&t=53088