summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2020-12-16 08:24:54 -0500
committerDavid Thompson <dthompson@vistahigherlearning.com>2020-12-16 08:24:54 -0500
commit1f33135b58fc12f0e4f7e661e0c5a64498e17815 (patch)
tree75dfe791fb803c2f1c7a61211b5e5563ba5c30e3
parenta8fe1ee0159172c556af7ccf841fba8a3859b597 (diff)
node-2d: Improve position interpolation logic.
-rw-r--r--starling/node-2d.scm8
1 files changed, 3 insertions, 5 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index f6dc7c1..6fd80ba 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -285,9 +285,8 @@
(define-method (teleport (node <node-2d>) x y)
(move-to node x y)
- (let ((lp (last-position node)))
- (set-vec2-x! lp x)
- (set-vec2-y! lp y)))
+ (set-vec2! (last-position node) x y)
+ (set-vec2! (render-position node) x y))
(define-method (rotate-to (node <node-2d>) theta)
(set! (rotation node) theta)
@@ -372,8 +371,7 @@
(lp (last-position node))
(rp (render-position node))
(beta (- 1.0 alpha)))
- (unless (and (= (vec2-x lp) (vec2-x rp))
- (= (vec2-y lp) (vec2-y rp)))
+ (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)))
(set! (dirty-matrix? node) #t)))