diff options
author | colin <colin@cicadas.surf> | 2024-12-14 12:29:29 -0800 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-12-14 12:29:29 -0800 |
commit | 543704f0f54cbb1de78754ad8a323c482ab6829c (patch) | |
tree | 7528c0105516a2a2800e432de9f4f1a6c3fe506e /src/core | |
parent | 3a2217263d581be9a7f629b10d75aa8e3d581890 (diff) |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/unit.lisp | 34 |
1 files changed, 18 insertions, 16 deletions
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." |