]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Further optimize ModalController_draw code
authorterencehill <piuntn@gmail.com>
Wed, 31 Dec 2014 17:00:25 +0000 (18:00 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 31 Dec 2014 17:00:25 +0000 (18:00 +0100)
qcsrc/menu/item/modalcontroller.c

index cfa3af85279490a73c6825fff6c5dd1a33af042c..5f67999029fdb8d7a781fe69a6cd87e059152fc5 100644 (file)
@@ -160,22 +160,6 @@ void ModalController_draw(entity me)
 
        for(e = me.firstChild; e; e = e.nextSibling)
        {
-               f = (e.ModalController_factor = min(1, e.ModalController_factor + df));
-               if(e.ModalController_state)
-                       if(f < 1)
-                               animating = 1;
-
-               if(f < 1)
-               {
-                       prevFactor   = (1 - f) / (1 - f + df);
-                       targetFactor =     df  / (1 - f + df);
-               }
-               else
-               {
-                       prevFactor = 0;
-                       targetFactor = 1;
-               }
-
                if(e.ModalController_state == 2)
                {
                        // fading out partially
@@ -193,25 +177,30 @@ void ModalController_draw(entity me)
                else
                {
                        // fading out
-                       if(f < 1)
-                               animating = 1;
                        targetOrigin = e.Container_origin; // stay as is
                        targetSize = e.Container_size; // stay as is
                        targetAlpha = 0;
                }
 
+               f = (e.ModalController_factor = min(1, e.ModalController_factor + df));
                if(f == 1)
                {
+                       prevFactor = 0;
+                       targetFactor = 1;
                        e.Container_origin = targetOrigin;
                        e.Container_size = targetSize;
                        me.setAlphaOf(me, e, targetAlpha);
                }
                else
                {
+                       prevFactor = (1 - f) / (1 - f + df);
                        if(!e.ModalController_state) // optimize code and avoid precision errors
                                me.setAlphaOf(me, e, e.Container_alpha  * prevFactor);
                        else
                        {
+                               animating = 1;
+                               targetFactor = df / (1 - f + df);
+
                                if(e.ModalController_state == 1)
                                {
                                        e.Container_origin = e.Container_origin * prevFactor + targetOrigin * targetFactor;