diff options
author | David Thompson <dthompson2@worcester.edu> | 2018-08-28 09:00:16 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2018-08-28 09:06:21 -0400 |
commit | b345d228b38cf6d3b5206327d63fe969adc42811 (patch) | |
tree | 1f9ce176383ef75e0e1de04431a7c4866d0d0d18 /starling/node-2d.scm | |
parent | 1ad377e3cde4011b9c2934c152335293261c3f1d (diff) |
node: Add visible? flag.
Diffstat (limited to 'starling/node-2d.scm')
-rw-r--r-- | starling/node-2d.scm | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm index a0b2746..368e8a2 100644 --- a/starling/node-2d.scm +++ b/starling/node-2d.scm @@ -314,26 +314,27 @@ (next-method)) (define-method (render* (node <node-2d>) alpha) - ;; Compute the linearly interpolated rendering position, in the case - ;; that node has moved since the last update. - (let ((p (position node)) - (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))) - (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))) - ;; Recompute dirty matrices. - (when (dirty-matrix? node) - (compute-matrices! node) - (set! (dirty-matrix? node) #f) - ;; If the parent is dirty, all the children need to be marked as - ;; dirty, too. - (for-each (lambda (node) - (set! (dirty-matrix? node) #t)) - (children node))) + (when (visible? node) + ;; Compute the linearly interpolated rendering position, in the case + ;; that node has moved since the last update. + (let ((p (position node)) + (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))) + (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))) + ;; Recompute dirty matrices. + (when (dirty-matrix? node) + (compute-matrices! node) + (set! (dirty-matrix? node) #f) + ;; If the parent is dirty, all the children need to be marked as + ;; dirty, too. + (for-each (lambda (node) + (set! (dirty-matrix? node) #t)) + (children node)))) (next-method)) (define-method (activate (node <node-2d>)) |