]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use the formula with exp, as it's more mathematically correct
authorterencehill <piuntn@gmail.com>
Tue, 11 Aug 2015 18:31:34 +0000 (20:31 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 11 Aug 2015 18:31:34 +0000 (20:31 +0200)
qcsrc/menu/item/listbox.qc

index 1940e324f27b0fa3174bbaf1db2652cf13292c25..83a811a4e623e2abd915a44e62e55b06742aef40 100644 (file)
@@ -418,13 +418,12 @@ void ListBox_draw(entity me)
        }
        if(me.scrollPos != me.scrollPosTarget)
        {
-               float PI = 3.1415926535897932384626433832795028841971693993751058209749445923;
-               float exp_factor = 0.65;
+               float exp_factor = 0.16;
                if(me.pressed == 1)
-                       exp_factor = 0.45; // scroll faster while dragging the scrollbar
+                       exp_factor = 0.06; // scroll faster while dragging the scrollbar
                // this formula works with whatever framerate
-               float f = sin(PI / 2 * pow(frametime, exp_factor));
-               me.scrollPos = me.scrollPos * (1 - f) + me.scrollPosTarget * f;
+               float f = exp(-frametime / exp_factor);
+               me.scrollPos = me.scrollPos * f + me.scrollPosTarget * (1 - f);
                if(fabs(me.scrollPos - me.scrollPosTarget) < 0.001)
                        me.scrollPos = me.scrollPosTarget;
        }