3d spaces

1.0.0

A library implementing spatial query structures

Table of Contents

About 3D-Spaces

This library implements a number of spatial query data structures; structures that can answer spatial range queries for optimised lookup, particularly suited for games. Often this is used to implement a "broad phase search".

How To

The library defines a core protocol which every structure (called a container) must implement. Every container may also expose additional operations or properties, but it is not required to do so. The library does not provide any object implementations. Instead it is expected that you implement bounding-box and bounding-sphere or location, bsize, and radius for your objects to describe their bounding volumes, which the containers will then make use of.

The following shows a very basic use:

(defclass box ()
  ((location :initarg :location :initform (vec 0 0 0) :accessor space:location)
   (bsize :initarg :bsize :initform (vec 0 0 0) :accessor space:bsize)))

(defun box (&optional (location (vec 0 0 0)) (bsize (vec 0 0 0)))
  (make-instance 'box :location location :bsize bsize))

(defvar *bvh2* (org.shirakumo.fraf.trial.space.bvh2:make-bvh))

(space:enter (box (vec 10 10 10) (vec 1 2 3)) *bvh2*)

(space:do-all (object *bvh2*)
  (print object))

(space:do-overlapping (object *bvh2* (space:region 0 0 0 11 11 11))
  (print object))

(space:do-contained (object *bvh2* (space:region 0 0 0 11 11 11))
  (print object))

(describe *bvh2*)

(space:clear *bvh2*)

Every container also implements For's iteration protocol, allowing you to iterate over the containers in an opaque way.

Supported Structures

The library supports the following structure types at this point:

Please see their respective packages for additional supported operations.

New Structures

In order to add a new structure, you must:

  1. Create a new package to hold your structure functions

  2. Create a subtype of container

  3. Implement enter, leave, clear, and call-with-overlapping

And ideally you should also:

System Information

1.0.0
Yukari Hafner
zlib

Definition Index