Lowest value on menu sliders is not 0 at first with arrows

Bugs that have been investigated and resolved somehow.

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.
Post Reply
unknownna
Posts: 215
Joined: Sat Oct 06, 2007 4:45 pm

Lowest value on menu sliders is not 0 at first with arrows

Post by unknownna »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
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

Post by Graf Zahl »

Welcome to the joy that's called floating point math.
unknownna
Posts: 215
Joined: Sat Oct 06, 2007 4:45 pm

Re: Lowest value on menu sliders is not 0 at first with arro

Post by unknownna »

This also affects GZDoom's vid_brightness "Brightness" slider when setting it back to 0 in the middle of the slider.
User avatar
Rachael
Posts: 13968
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Lowest value on menu sliders is not 0 at first with arro

Post by Rachael »

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. :P
dpJudas
 
 
Posts: 3177
Joined: Sat May 28, 2016 1:01 pm

Re: Lowest value on menu sliders is not 0 at first with arro

Post by dpJudas »

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;
}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
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

Post by Graf Zahl »

I chose the brute force approach of simply forcing small numbers to zero, it seems the only place where it actually causes problems.
Post Reply

Return to “Closed Bugs [GZDoom]”