From: terencehill Date: Wed, 31 Dec 2014 17:00:25 +0000 (+0100) Subject: Further optimize ModalController_draw code X-Git-Tag: xonotic-v0.8.1~138^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2c2c64c5e525fc1ecbee6c508e750955f841ecb0;p=xonotic%2Fxonotic-data.pk3dir.git Further optimize ModalController_draw code --- diff --git a/qcsrc/menu/item/modalcontroller.c b/qcsrc/menu/item/modalcontroller.c index cfa3af852..5f6799902 100644 --- a/qcsrc/menu/item/modalcontroller.c +++ b/qcsrc/menu/item/modalcontroller.c @@ -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;