The Broadphase objects keep a common interface that may be used outside of any 2d physics simulation, nor are Broadphases limited just to two dimensions.
Insert data value into broadphase, with given bounds and static type.
var handle = broadphase.insert(data, bounds, isStatic);
The data value to be inserted.
This value may be of any type, and inserted multiple times if needed.
The bounds of the data in the broadphase.
Update handle bounds and static type.
broadphase.update(handle, bounds, isStatic);
Remove handle from broadphase.
Broadphase implementations are free to re-use object handles, so references to handles that have been removed should be deleted.
Remove all handles from broadphase, executing given callback (if supplied) for each handle.
An optional callback which will be called for all handles.
It should take a single argument as the handle from the broadphase.
Query all pairs of handles overlapping in the broadphase.
Pairs will not be reported for two handles marked as static.
A callback which will be called for all handle pairs.
It should take two arguments as the handles from the broadphase that form each pair.
Query all handles overlapping given bounds.
broadphase.sample(bounds, callback, thisObject);
A callback which will be called for all overlapping handles.
It should take two arguments as the handle that was overlapped, and the input bounds to the sample function.
Full specification of the handle object is left to the Broadphase implementation.
Broadphase implementations are free to re-use object handles, so references to them should not be kept.