From ef723f7a82894794da6a2bf1c4cec68b2df430a9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 16 May 2023 19:03:28 -0400 Subject: node-2d: Only calculate beta value when interpolation is needed. This avoids allocating a float every frame for static nodes. --- catbird/node-2d.scm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/catbird/node-2d.scm b/catbird/node-2d.scm index 12014f1..868604a 100644 --- a/catbird/node-2d.scm +++ b/catbird/node-2d.scm @@ -654,12 +654,12 @@ (when (visible? node) (let ((p (position node)) (lp (last-position node)) - (rp (render-position node)) - (beta (- 1.0 alpha))) + (rp (render-position node))) (unless (and (vec2= rp p) (vec2= lp p)) - (set-vec2-x! rp (+ (* (vec2-x p) alpha) (* (vec2-x lp) beta))) - (set-vec2-y! rp (+ (* (vec2-y p) alpha) (* (vec2-y lp) beta))) - (expire-local-matrix node))) + (let ((beta (- 1.0 alpha))) + (set-vec2-x! rp (+ (* (vec2-x p) alpha) (* (vec2-x lp) beta))) + (set-vec2-y! rp (+ (* (vec2-y p) alpha) (* (vec2-y lp) beta))) + (expire-local-matrix node)))) (next-method))) -- cgit v1.2.3