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

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Lowest value on menu sliders is not 0 at first with arrows

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

by Blue Shadow » Fri Nov 04, 2016 4:36 am

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

by Graf Zahl » Fri Nov 04, 2016 4:18 am

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

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

by dpJudas » Sun Oct 16, 2016 8:33 am

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;
}

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

by Rachael » Sun Oct 16, 2016 6:36 am

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

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

by unknownna » Sun Oct 16, 2016 3:46 am

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

by Graf Zahl » Sun Oct 16, 2016 3:35 am

Welcome to the joy that's called floating point math.

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

by unknownna » Sun Oct 16, 2016 3:24 am

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.

Top