Changeset 3195
- Timestamp:
- 05/27/08 11:34:25 (8 months ago)
- Files:
-
- trunk/projects/bos/web/quad-tree.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/web/quad-tree.lisp
r3180 r3195 256 256 (ensure-node-with-path (ensure-child node (first path)) (rest path)))) 257 257 258 (defun ensure-intersecting-children (node geo-box &optional function) 258 (defun ensure-intersecting-children (node geo-box &optional function (leaf-test #'leaf-node-p)) 259 "Maps FUNCTION over NODE and all children of NODE that intersect 260 with GEO-BOX. Children that dont exist yet are created on the fly. If 261 LEAF-TEST returns true, the children of the current node are not 262 further recursed into." 259 263 (when function 260 264 (funcall function node)) 261 (unless ( leaf-node-pnode)265 (unless (funcall leaf-test node) 262 266 (dolist (index (intersecting-children-indices node geo-box)) 263 267 (ensure-intersecting-children (ensure-child node index) geo-box function)))) … … 279 283 nil)) 280 284 285 (defun collect-nodes (test node &key (prune-test (constantly nil))) 286 (let (nodes) 287 (map-nodes (lambda (node) 288 (when (funcall test node) 289 (push node nodes))) 290 node 291 :prune-test prune-test) 292 (nreverse nodes))) 293 281 294 ;;; *quad-tree* 282 295 (defvar *quad-tree*) … … 287 300 (register-store-transient-init-function 'make-quad-tree) 288 301 289 (def methodnode-path (node)302 (defun node-path (node) 290 303 (let (prev-n path) 291 304 (map-nodes (lambda (n) … … 296 309 (setq prev-n n)) 297 310 *quad-tree* 298 :prune-test (lambda (n) (not (geo-box-intersect-p (geo-box n) (geo-box node))))))) 299 300 301 311 :prune-test (lambda (n) (not (geo-box-intersect-p (geo-box n) 312 (geo-box node))))))) 313
