home *** CD-ROM | disk | FTP | other *** search
- package Box2D.Collision.Shapes
- {
- import Box2D.Collision.b2AABB;
- import Box2D.Collision.b2BroadPhase;
- import Box2D.Collision.b2Pair;
- import Box2D.Collision.b2Segment;
- import Box2D.Common.Math.b2Vec2;
- import Box2D.Common.Math.b2XForm;
- import Box2D.Dynamics.b2Body;
-
- public class b2Shape
- {
-
- public static const e_polygonShape:int = 1;
-
- private static var s_resetAABB:b2AABB = new b2AABB();
-
- private static var s_syncAABB:b2AABB = new b2AABB();
-
- private static var s_proxyAABB:b2AABB = new b2AABB();
-
- public static const e_unknownShape:int = -1;
-
- public static const e_circleShape:int = 0;
-
- public static const e_shapeTypeCount:int = 2;
-
-
- public var m_next:b2Shape;
-
- public var m_type:int;
-
- public var m_sweepRadius:Number;
-
- public var m_density:Number;
-
- public var m_filter:b2FilterData;
-
- public var m_friction:Number;
-
- public var m_isSensor:Boolean;
-
- public var m_restitution:Number;
-
- public var m_userData:*;
-
- public var m_proxyId:uint;
-
- public var m_body:b2Body;
-
- public function b2Shape(def:b2ShapeDef)
- {
- super();
- m_userData = def.userData;
- m_friction = def.friction;
- m_restitution = def.restitution;
- m_density = def.density;
- m_body = null;
- m_sweepRadius = 0;
- m_next = null;
- m_proxyId = b2Pair.b2_nullProxy;
- m_filter = def.filter.Copy();
- m_isSensor = def.isSensor;
- }
-
- public static function Destroy(shape:b2Shape, allocator:*) : void
- {
- }
-
- public static function Create(def:b2ShapeDef, allocator:*) : b2Shape
- {
- switch(def.type)
- {
- case e_circleShape:
- return new b2CircleShape(def);
- case e_polygonShape:
- return new b2PolygonShape(def);
- default:
- return null;
- }
- }
-
- public function SetUserData(data:*) : void
- {
- m_userData = data;
- }
-
- public function GetSweepRadius() : Number
- {
- return m_sweepRadius;
- }
-
- public function GetNext() : b2Shape
- {
- return m_next;
- }
-
- public function ComputeSweptAABB(aabb:b2AABB, xf1:b2XForm, xf2:b2XForm) : void
- {
- }
-
- public function GetType() : int
- {
- return m_type;
- }
-
- public function GetRestitution() : Number
- {
- return m_restitution;
- }
-
- public function GetFriction() : Number
- {
- return m_friction;
- }
-
- public function GetFilterData() : b2FilterData
- {
- return m_filter.Copy();
- }
-
- public function TestSegment(xf:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number) : Boolean
- {
- return false;
- }
-
- public function RefilterProxy(broadPhase:b2BroadPhase, transform:b2XForm) : void
- {
- if(m_proxyId == b2Pair.b2_nullProxy)
- {
- return;
- }
- broadPhase.DestroyProxy(m_proxyId);
- var aabb:b2AABB = s_resetAABB;
- ComputeAABB(aabb,transform);
- var inRange:Boolean = broadPhase.InRange(aabb);
- if(inRange)
- {
- m_proxyId = broadPhase.CreateProxy(aabb,this);
- }
- else
- {
- m_proxyId = b2Pair.b2_nullProxy;
- }
- }
-
- public function SetFilterData(filter:b2FilterData) : void
- {
- m_filter = filter.Copy();
- }
-
- public function GetUserData() : *
- {
- return m_userData;
- }
-
- public function Synchronize(broadPhase:b2BroadPhase, transform1:b2XForm, transform2:b2XForm) : Boolean
- {
- if(m_proxyId == b2Pair.b2_nullProxy)
- {
- return false;
- }
- var aabb:b2AABB = s_syncAABB;
- ComputeSweptAABB(aabb,transform1,transform2);
- if(broadPhase.InRange(aabb))
- {
- broadPhase.MoveProxy(m_proxyId,aabb);
- return true;
- }
- return false;
- }
-
- public function ComputeMass(massData:b2MassData) : void
- {
- }
-
- public function IsSensor() : Boolean
- {
- return m_isSensor;
- }
-
- public function DestroyProxy(broadPhase:b2BroadPhase) : void
- {
- if(m_proxyId != b2Pair.b2_nullProxy)
- {
- broadPhase.DestroyProxy(m_proxyId);
- m_proxyId = b2Pair.b2_nullProxy;
- }
- }
-
- public function UpdateSweepRadius(center:b2Vec2) : void
- {
- }
-
- public function ComputeAABB(aabb:b2AABB, xf:b2XForm) : void
- {
- }
-
- public function GetBody() : b2Body
- {
- return m_body;
- }
-
- public function CreateProxy(broadPhase:b2BroadPhase, transform:b2XForm) : void
- {
- var aabb:b2AABB = s_proxyAABB;
- ComputeAABB(aabb,transform);
- var inRange:Boolean = broadPhase.InRange(aabb);
- if(inRange)
- {
- m_proxyId = broadPhase.CreateProxy(aabb,this);
- }
- else
- {
- m_proxyId = b2Pair.b2_nullProxy;
- }
- }
-
- public function TestPoint(xf:b2XForm, p:b2Vec2) : Boolean
- {
- return false;
- }
- }
- }
-