From ff0d86e99de2ce0fb61efd82070b758de0bb107f Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 29 Jun 2022 06:34:57 -0500 Subject: [refactor] factored run-perframe out of render (app) --- wheelwork.lisp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wheelwork.lisp b/wheelwork.lisp index 9d7571d..a1208a6 100644 --- a/wheelwork.lisp +++ b/wheelwork.lisp @@ -325,13 +325,18 @@ necessary." (shutdown app)) (cleanup app))))))) -(defgeneric render (thing)) -(defmethod render ((app application)) +(defun run-perframe (app) (let ((table (perframe-table (listener app))) (time (get-universal-time))) (loop for target being the hash-key of table for handlers = (slot-value (listener target) 'perframe) - do (loop for handler in handlers do (funcall handler target time)))) + ;; only fire perframe when target is in scene + when (or (eq app target) (unit-container target)) + do (loop for handler in handlers do (funcall handler target time))))) + +(defgeneric render (thing)) +(defmethod render ((app application)) + (run-perframe app) (gl:clear-color 0.0 0.0 0.0 1.0) (gl:clear :depth-buffer-bit :color-buffer-bit) (dolist (thing (container-units app)) -- cgit v1.2.3