perf improvements.

This commit is contained in:
Bryce Covert
2016-08-02 08:25:57 -07:00
parent 8e34dc708c
commit ad5f2acfec

View File

@@ -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