Table Of Contents

Previous topic

18.3. The RigidBody Object

Next topic

18.6. The CollisionUtils Object

This Page

18.4. The Broadphase Object

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.

18.4.1. Constructor

Two Broadphase implementation exists in the Turbulenz SDK at present, these can be constructed with Physics2DDevice.createSweepAndPruneBroadphase() and Physics2DDevice.createBoxTreeBroadphase().

18.4.2. Methods

18.4.2.1. insert

Summary

Insert data value into broadphase, with given bounds and static type.

Syntax

var handle = broadphase.insert(data, bounds, isStatic);
data

The data value to be inserted.

This value may be of any type, and inserted multiple times if needed.

bounds

The bounds of the data in the broadphase.

The definition of the bounds is up to the broadphase. For the 2D broadphases used by Physics2DDevice these bounds should be an axis-aligned rectangle defined like
[minX, minY, maxX, maxY]
isStatic
Whether this data is a static, or dynamic data value.

18.4.2.2. update

Summary

Update handle bounds and static type.

Syntax

broadphase.update(handle, bounds, isStatic);
handle
The handle to be updated as returned by broadphase.insert.
bounds
The new bounds for the handle.
isStatic (Optional)
The new static type for the handle. If unspecified the handles type will remain unchanged.

18.4.2.3. remove

Summary

Remove handle from broadphase.

Syntax

broadphase.remove(handle);
handle
The handle to be removed as returned by broadphase.insert.

Broadphase implementations are free to re-use object handles, so references to handles that have been removed should be deleted.

18.4.2.4. clear

Summary

Remove all handles from broadphase, executing given callback (if supplied) for each handle.

Syntax

broadphase.clear(callback, thisObject);
callback (Optional)

An optional callback which will be called for all handles.

It should take a single argument as the handle from the broadphase.

thisObject (Optional)
An optional object to use for the this object when calling the callback.

18.4.2.5. perform

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);
callback

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.

thisObject (Optional)
An optional object to use for the this object when calling the callback.

18.4.2.6. sample

Summary

Query all handles overlapping given bounds.

Syntax

broadphase.sample(bounds, callback, thisObject);
bounds
The bounds (as defined by broadphase) to sample handles from.
callback

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.

thisObject (Optional)
An optional object to use for the this object when calling the callback.

18.5. The Broadphase Handle Object

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.

18.5.1. Properties

18.5.1.1. data

The data associated with handle.

18.5.1.2. isStatic

The static type of handle.

Note

Read Only