PackageBox2D.Collision.Shapes
Classpublic class b2Shape
Subclassesb2CircleShape, b2PolygonShape

A shape is used for collision detection. Shapes are created in b2World. You can use shape for collision detection before they are attached to the world.



Public Methods
 MethodDefined by
  
b2Shape
  
ComputeAABB(aabb:b2AABB, xf:b2XForm):void
Given a transform, compute the associated axis aligned bounding box for this shape.
b2Shape
  
ComputeMass(massData:b2MassData):void
Compute the mass properties of this shape using its dimensions and density.
b2Shape
  
ComputeSweptAABB(aabb:b2AABB, xf1:b2XForm, xf2:b2XForm):void
Given two transforms, compute the associated swept axis aligned bounding box for this shape.
b2Shape
  
Create(def:b2ShapeDef, allocator:*):b2Shape
[static]
b2Shape
  
CreateProxy(broadPhase:b2BroadPhase, transform:b2XForm):void
b2Shape
  
Destroy(shape:b2Shape, allocator:*):void
[static]
b2Shape
  
DestroyProxy(broadPhase:b2BroadPhase):void
b2Shape
  
Get the parent body of this shape.
b2Shape
  
Get the contact filtering data.
b2Shape
  
GetFriction():Number
Get the coefficient of friction.
b2Shape
  
Get the next shape in the parent body's shape list.
b2Shape
  
GetRestitution():Number
Get the coefficient of restitution.
b2Shape
  
GetSweepRadius():Number
Get the maximum radius about the parent body's center of mass.
b2Shape
  
GetType():int
Get the type of this shape.
b2Shape
  
Get the user data that was assigned in the shape definition.
b2Shape
  
IsSensor():Boolean
Is this shape a sensor (non-solid)?
b2Shape
  
RefilterProxy(broadPhase:b2BroadPhase, transform:b2XForm):void
b2Shape
  
Set the contact filtering data.
b2Shape
  
SetUserData(data:*):void
Set the user data.
b2Shape
  
Synchronize(broadPhase:b2BroadPhase, transform1:b2XForm, transform2:b2XForm):Boolean
b2Shape
  
TestPoint(xf:b2XForm, p:b2Vec2):Boolean
Test a point for containment in this shape.
b2Shape
  
TestSegment(xf:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):Boolean
Perform a ray cast against this shape.
b2Shape
  
b2Shape
Public Constants
 ConstantDefined by
  e_circleShape : int = 0
[static]
b2Shape
  e_polygonShape : int = 1
[static]
b2Shape
  e_shapeTypeCount : int = 2
[static]
b2Shape
  e_unknownShape : int = -1
[static]
b2Shape
Property detail
m_bodyproperty
b2internal var m_body:b2Body
m_densityproperty 
b2internal var m_density:Number
m_frictionproperty 
b2internal var m_friction:Number
m_nextproperty 
b2internal var m_next:b2Shape
m_restitutionproperty 
b2internal var m_restitution:Number
m_sweepRadiusproperty 
b2internal var m_sweepRadius:Number
m_typeproperty 
b2internal var m_type:int
Constructor detail
b2Shape()constructor
public function b2Shape(def:b2ShapeDef)Parameters
def:b2ShapeDef
Method detail
ComputeAABB()method
public function ComputeAABB(aabb:b2AABB, xf:b2XForm):void

Given a transform, compute the associated axis aligned bounding box for this shape.

Parameters
aabb:b2AABB — returns the axis aligned box.
 
xf:b2XForm — the world transform of the shape.
ComputeMass()method 
public function ComputeMass(massData:b2MassData):void

Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.

Parameters
massData:b2MassData — returns the mass data for this shape.
ComputeSweptAABB()method 
public function ComputeSweptAABB(aabb:b2AABB, xf1:b2XForm, xf2:b2XForm):void

Given two transforms, compute the associated swept axis aligned bounding box for this shape.

Parameters
aabb:b2AABB — returns the axis aligned box.
 
xf1:b2XForm — the starting shape world transform.
 
xf2:b2XForm — the ending shape world transform.
Create()method 
public static function Create(def:b2ShapeDef, allocator:*):b2ShapeParameters
def:b2ShapeDef
 
allocator:*

Returns
b2Shape
CreateProxy()method 
public function CreateProxy(broadPhase:b2BroadPhase, transform:b2XForm):voidParameters
broadPhase:b2BroadPhase
 
transform:b2XForm
Destroy()method 
public static function Destroy(shape:b2Shape, allocator:*):voidParameters
shape:b2Shape
 
allocator:*
DestroyProxy()method 
public function DestroyProxy(broadPhase:b2BroadPhase):voidParameters
broadPhase:b2BroadPhase
GetBody()method 
public function GetBody():b2Body

Get the parent body of this shape. This is NULL if the shape is not attached.

Returns
b2Body — the parent body.
GetFilterData()method 
public function GetFilterData():b2FilterData

Get the contact filtering data.

Returns
b2FilterData
GetFriction()method 
public function GetFriction():Number

Get the coefficient of friction.

Returns
Number
GetNext()method 
public function GetNext():b2Shape

Get the next shape in the parent body's shape list.

Returns
b2Shape — the next shape.
GetRestitution()method 
public function GetRestitution():Number

Get the coefficient of restitution.

Returns
Number
GetSweepRadius()method 
public function GetSweepRadius():Number

Get the maximum radius about the parent body's center of mass.

Returns
Number
GetType()method 
public function GetType():int

Get the type of this shape. You can use this to down cast to the concrete shape.

Returns
int — the shape type.
GetUserData()method 
public function GetUserData():*

Get the user data that was assigned in the shape definition. Use this to store your application specific data.

Returns
*
IsSensor()method 
public function IsSensor():Boolean

Is this shape a sensor (non-solid)?

Returns
Boolean — the true if the shape is a sensor.
RefilterProxy()method 
public function RefilterProxy(broadPhase:b2BroadPhase, transform:b2XForm):voidParameters
broadPhase:b2BroadPhase
 
transform:b2XForm
SetFilterData()method 
public function SetFilterData(filter:b2FilterData):void

Set the contact filtering data. You must call b2World::Refilter to correct existing contacts/non-contacts.

Parameters
filter:b2FilterData
SetUserData()method 
public function SetUserData(data:*):void

Set the user data. Use this to store your application specific data.

Parameters
data:*
Synchronize()method 
public function Synchronize(broadPhase:b2BroadPhase, transform1:b2XForm, transform2:b2XForm):BooleanParameters
broadPhase:b2BroadPhase
 
transform1:b2XForm
 
transform2:b2XForm

Returns
Boolean
TestPoint()method 
public function TestPoint(xf:b2XForm, p:b2Vec2):Boolean

Test a point for containment in this shape. This only works for convex shapes.

Parameters
xf:b2XForm — the shape world transform.
 
p:b2Vec2 — a point in world coordinates.

Returns
Boolean
TestSegment()method 
public function TestSegment(xf:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):Boolean

Perform a ray cast against this shape.

Parameters
xf:b2XForm — the shape world transform.
 
lambda:Array — returns the hit fraction. You can use this to compute the contact point p = (1 - lambda) segment.p1 + lambda segment.p2.
 
normal:b2Vec2 — returns the normal at the contact point. If there is no intersection, the normal is not set.
 
segment:b2Segment — defines the begin and end point of the ray cast.
 
maxLambda:Number — a number typically in the range [0,1].

Returns
Boolean — true if there was an intersection.
UpdateSweepRadius()method 
public function UpdateSweepRadius(center:b2Vec2):voidParameters
center:b2Vec2
Constant detail
e_circleShapeconstant
public static const e_circleShape:int = 0
e_polygonShapeconstant 
public static const e_polygonShape:int = 1
e_shapeTypeCountconstant 
public static const e_shapeTypeCount:int = 2
e_unknownShapeconstant 
public static const e_unknownShape:int = -1