From 543704f0f54cbb1de78754ad8a323c482ab6829c Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 14 Dec 2024 12:29:29 -0800 Subject: Loop style nits --- src/core/unit.lisp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/unit.lisp b/src/core/unit.lisp index 308b715..ded1e41 100644 --- a/src/core/unit.lisp +++ b/src/core/unit.lisp @@ -110,23 +110,25 @@ (defmethod get-rect ((unit unit)) (or (cached-rectangle unit) - (setf (cached-rectangle unit) - (with-accessors ((x x) (y y) (w width) (h height) (r rotation)) unit - (let ((m - (mat:meye 4)) - (tr - (vec:vec (+ x (* 0.5 w)) (+ y (* 0.5 h)) 0.0))) - (mat:nmtranslate m tr) - (mat:nmrotate m vec:+vz+ r) - (mat:nmtranslate m (vec:v* -1.0 tr)) + (setf + (cached-rectangle unit) + (with-accessors ((x x) (y y) (w width) (h height) (r rotation)) unit + (let ((m + (mat:meye 4)) + (tr + (vec:vec (+ x (* 0.5 w)) (+ y (* 0.5 h)) 0.0))) + + (mat:nmtranslate m tr) + (mat:nmrotate m vec:+vz+ r) + (mat:nmtranslate m (vec:v* -1.0 tr)) - (loop for vec in (list (mat:m* m (vec:vec x y 0.0 1.0)) - (mat:m* m (vec:vec x (+ y h) 0.0 1.0)) - (mat:m* m (vec:vec (+ x w) (+ y h) 0.0 1.0)) - (mat:m* m (vec:vec (+ x w) y 0.0 1.0)) - (mat:m* m (vec:vec x y 0.0 1.0))) - collect (list (vec:vx vec) - (vec:vy vec)))))))) + (loop :for vec :in (list (mat:m* m (vec:vec x y 0.0 1.0)) + (mat:m* m (vec:vec x (+ y h) 0.0 1.0)) + (mat:m* m (vec:vec (+ x w) (+ y h) 0.0 1.0)) + (mat:m* m (vec:vec (+ x w) y 0.0 1.0)) + (mat:m* m (vec:vec x y 0.0 1.0))) + :collect (list (vec:vx vec) + (vec:vy vec)))))))) (defun units-intersect-p (au1 au2) "Returns T if the two units AU1 an AU2 intersect. Both must implement GET-RECT." -- cgit v1.2.3