diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-27 12:07:10 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-27 12:07:10 -0500 |
commit | 11f8d6dad0078464ccbc29cab57908a0923ca447 (patch) | |
tree | ff56d4daf1c2d7cb657587a9fcacdeedfef36307 /src/wheelwork.lisp | |
parent | 0b743b90752bacf31923171af9af0e5ff1f08095 (diff) |
[refactor] represent scene as a vector; [refactor] shared text shader
Diffstat (limited to 'src/wheelwork.lisp')
-rw-r--r-- | src/wheelwork.lisp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/wheelwork.lisp b/src/wheelwork.lisp index 8a534ed..ab432d5 100644 --- a/src/wheelwork.lisp +++ b/src/wheelwork.lisp @@ -10,7 +10,7 @@ (defmethod add-unit ((unit unit)) "Adds a unit to the display." (assert *application*) - (push unit (application-scene *application*)) + (vector-push-extend unit (application-scene *application*) (1+ (length (application-scene *application*)))) (setf (unit-in-scene-p unit) t)) (defgeneric drop-unit (unit)) @@ -109,15 +109,21 @@ position. The list always contains the app itself as the last element." (defun unit-under (app x y) "Finds the visible unit that contains the point x y, returns it as a single elemtn list, or nil if none found" - (loop for u in (application-scene app) - when (unit-visibly-contains-p u x y) - return (list u))) + (with-slots (scene) app + (loop + for idx from (1- (length scene)) downto 0 + for u = (elt scene idx) + when (unit-visibly-contains-p u x y) + return (list u)))) (defun all-units-under (app x y) "Finds all units under the point x y" - (loop for u in (application-scene app) - when (unit-visibly-contains-p u x y) - collect u)) + (with-slots (scene) app + (loop + for idx from (1- (length scene)) downto 0 + for u = (elt scene idx) + when (unit-visibly-contains-p u x y) + collect u))) (defvar *event-still-bubbling-p* nil "Controls whether an event is bubbling") |