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.
Two Broadphase implementation exists in the Turbulenz SDK at present, these can be constructed with Physics2DDevice.createSweepAndPruneBroadphase() and Physics2DDevice.createBoxTreeBroadphase().
Summary
Insert data value into broadphase, with given bounds and static type.
Syntax
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.
Summary
Update handle bounds and static type.
Syntax
broadphase.update(handle, bounds, isStatic);
Summary
Remove handle from broadphase.
Syntax
broadphase.remove(handle);
Broadphase implementations are free to re-use object handles, so references to handles that have been removed should be deleted.
Summary
Remove all handles from broadphase, executing given callback (if supplied) for each handle.
Syntax
broadphase.clear(callback, thisObject);
An optional callback which will be called for all handles.
It should take a single argument as the handle from the broadphase.
Summary
Query all pairs of handles overlapping in the broadphase.
Pairs will not be reported for two handles marked as static.
Syntax
broadphase.perform(callback, thisObject);
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.
Summary
Query all handles overlapping given bounds.
Syntax
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.