summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-05-16 19:03:28 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-05-16 19:03:28 -0400
commitef723f7a82894794da6a2bf1c4cec68b2df430a9 (patch)
tree80bf6b28e26152ef3e02173f39fa68e71fcfe4d1
parent6dbc6492a97aaf59c8390e4951c0440214db96f1 (diff)
node-2d: Only calculate beta value when interpolation is needed.
This avoids allocating a float every frame for static nodes.
-rw-r--r--catbird/node-2d.scm10
1 files 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)))