Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef B2_POLYGON_SHAPE_H
00020 #define B2_POLYGON_SHAPE_H
00021
00022 #include <Box2D/Collision/Shapes/b2Shape.h>
00023
00028 class b2PolygonShape : public b2Shape
00029 {
00030 public:
00031 b2PolygonShape();
00032
00034 b2Shape* Clone(b2BlockAllocator* allocator) const;
00035
00037 int32 GetChildCount() const;
00038
00044 void Set(const b2Vec2* points, int32 count);
00045
00049 void SetAsBox(float32 hx, float32 hy);
00050
00056 void SetAsBox(float32 hx, float32 hy, const b2Vec2& center, float32 angle);
00057
00059 bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
00060
00062 bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
00063 const b2Transform& transform, int32 childIndex) const;
00064
00066 void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
00067
00069 void ComputeMass(b2MassData* massData, float32 density) const;
00070
00072 int32 GetVertexCount() const { return m_count; }
00073
00075 const b2Vec2& GetVertex(int32 index) const;
00076
00079 bool Validate() const;
00080
00081 b2Vec2 m_centroid;
00082 b2Vec2 m_vertices[b2_maxPolygonVertices];
00083 b2Vec2 m_normals[b2_maxPolygonVertices];
00084 int32 m_count;
00085 };
00086
00087 inline b2PolygonShape::b2PolygonShape()
00088 {
00089 m_type = e_polygon;
00090 m_radius = b2_polygonRadius;
00091 m_count = 0;
00092 m_centroid.SetZero();
00093 }
00094
00095 inline const b2Vec2& b2PolygonShape::GetVertex(int32 index) const
00096 {
00097 b2Assert(0 <= index && index < m_count);
00098 return m_vertices[index];
00099 }
00100
00101 #endif