From ad5f2acfec5a4e1df228352dd290bc8c1c4f2958 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 2 Aug 2016 08:25:57 -0700 Subject: [PATCH] perf improvements. --- desktop/src-common/advent/screens/scene.clj | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 4f57663c..f3139010 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -897,20 +897,17 @@ void main () -(defn get-looped-animation-point [^Animation animation total-time] - (loop [time total-time] - (if (> (- time (animation! animation :get-animation-duration)) 0) - (recur (- time (animation! animation :get-animation-duration))) - time))) +(defn get-looped-animation-point [^Animation animation ^double total-time] + (mod total-time (animation! animation :get-animation-duration))) (defn animate [{:keys [anim anim-loop? anim-merges anim-start] :or {anim-loop? true} :as entity} {:keys [delta-time total-time] :or {delta-time 0} :as screen}] (let [current-frame-index (animation! ^Animation anim :get-key-frame-index (if anim-loop? - (get-looped-animation-point anim (- total-time anim-start)) + (get-looped-animation-point anim ^double (- total-time anim-start)) (- total-time anim-start))) previous-frame-index (animation! ^Animation anim :get-key-frame-index (if anim-loop? - (get-looped-animation-point anim (- total-time anim-start delta-time)) + (get-looped-animation-point anim ^double (- total-time anim-start delta-time)) (- total-time anim-start delta-time)))] (merge entity (animation->texture (update-in screen [:total-time] #(- % anim-start)) anim