InteractionFilter

nape.dynamics.InteractionFilter (final class)

InteractionFilter provides bit flags for low-level filtering of interactions.

For a given interaction type, two Shapes will be permitted to interact only if (shape1.group & shape2.mask) != 0 && (shape2.group & shape1.mask) != 0

There are 32 real groups corresponding to a set bit in the group/mask fields. For instance a group value of 0x120 corresponds to the 'real' groups 5 and 8 as 0x120 = (1<<5) | (1<<8)

Nape provides group/mask for each interaction type. The actual precedence of interactions is further defined simply as: Sensor > Fluid > Collision.
Two static bodies can never interact, and with the exception of sensor interaction, at least one of the two bodies must be dynamic.
Sensor interactions have the highest precedence, followed by fluid and then collisions. Sensor interaction is permitted only if one of the shapes is sensorEnabled, whilst fluid is permitted only if one of the shapes is fluidEnabled.

if ((shapeA.sensorEnabled || shapeB.sensorEnabled) && shapeA.filter.shouldSense(shapeB.filter)) {
SENSOR INTERACTION!!
}
else if (bodyA.isDynamic() || bodyB.isDynamic()) {
if ((shapeA.fluidEnabled || shapeB.fluidEnabled) && shapeA.filter.shouldFlow(shapeB.filter)) {
FLUID INTERACTION!!
}
else if (shapeA.filter.shouldCollide(shapeB.filter)) {
COLLISION INTERACTION!!
}
}

Instance Members

@private


nape
userData: Dynamic

Dynamic object for user to store additional data.

This object cannot be set, only its dynamically created properties may be set. In AS3 the type of this property is &#42

This object will be lazily constructed so that until accessed for the first time, will be null internally.

@default {}


Set of all active shapes using this object.

Activeness of a shape in the sense that the Shape's Body is inside of a Space.

This list is immutable.


nape
collisionGroup: Int

Group bitfield for Collision type interactions. @default 1


nape
collisionMask: Int

Mask bitfield for Collision type interactions. @default -1 (all bits set)


nape
sensorGroup: Int

Group bitfield for Sensor type interactions. @default 1


nape
sensorMask: Int

Mask bitfield for Sensor type interactions. @default -1 (all bits set)


nape
fluidGroup: Int

Group bitfield for Fluid type interactions. @default 1


nape
fluidMask: Int

Mask bitfield for Fluid type interactions. @default -1 (all bits set)


nape
shouldCollide(filter: InteractionFilter): Bool

Determine if objects are permitted to collide based on InteractionFilters

A collision type interaction can occur only if this returns True.

Name Type Description
filter InteractionFilter The filter to evaluate possibility of collision with.
Returns Description
Bool True, if based on interaction filters only the two objects would be able to collide.

nape
shouldSense(filter: InteractionFilter): Bool

Determine if objects are permitted to sense based on InteractionFilters

A sensor type interaction can occur only if this returns True.

Name Type Description
filter InteractionFilter The filter to evaluate possibility of sensor with.
Returns Description
Bool True, if based on interaction filters only the two objects would be able to sense.

nape
shouldFlow(filter: InteractionFilter): Bool

Determine if objects are permitted to interact as fluids based on InteractionFilters

A fluid type interaction can occur only if this returns True.

Name Type Description
filter InteractionFilter The filter to evaluate possibility of fluid with.
Returns Description
Bool True, if based on interaction filters only the two objects would be able to interact as fluids.

nape
copy(): InteractionFilter

Produce a copy of this InteractionFilter

Returns Description
InteractionFilter The copy of this filter.

nape
toString(): String

@private

Returns
String

nape
new(?collisionGroup: Int = 1, ?collisionMask: Int = -1, ?sensorGroup: Int = 1, ?sensorMask: Int = -1, ?fluidGroup: Int = 1, ?fluidMask: Int = -1): Void

Construct a new InteractionFilter.

Name Type Default Description
collisionGroup Int 1 The Group bitfield for Collision interactions. (default 1)
collisionMask Int -1 The Mask bitfield for Collision interactions. (default -1)
sensorGroup Int 1 The Group bitfield for Sensor interactions. (default 1)
sensorMask Int -1 The Mask bitfield for Sensor interactions. (default -1)
fluidGroup Int 1 The Group bitfield for Fluid interactions. (default 1)
fluidMask Int -1 The Mask bitfield for Fluid interactions. (default -1)

Private Members

Metadata

Name Parameters
:final -