![]() |
Box2D
2.2.0
A 2D Physics Engine for Games
|
00001 /* 00002 * Copyright (c) 2006-2010 Erin Catto http://www.box2d.org 00003 * 00004 * This software is provided 'as-is', without any express or implied 00005 * warranty. In no event will the authors be held liable for any damages 00006 * arising from the use of this software. 00007 * Permission is granted to anyone to use this software for any purpose, 00008 * including commercial applications, and to alter it and redistribute it 00009 * freely, subject to the following restrictions: 00010 * 1. The origin of this software must not be misrepresented; you must not 00011 * claim that you wrote the original software. If you use this software 00012 * in a product, an acknowledgment in the product documentation would be 00013 * appreciated but is not required. 00014 * 2. Altered source versions must be plainly marked as such, and must not be 00015 * misrepresented as being the original software. 00016 * 3. This notice may not be removed or altered from any source distribution. 00017 */ 00018 00019 #ifndef B2_CHAIN_SHAPE_H 00020 #define B2_CHAIN_SHAPE_H 00021 00022 #include <Box2D/Collision/Shapes/b2Shape.h> 00023 00024 class b2EdgeShape; 00025 00032 class b2ChainShape : public b2Shape 00033 { 00034 public: 00035 b2ChainShape(); 00036 00038 ~b2ChainShape(); 00039 00043 void CreateLoop(const b2Vec2* vertices, int32 count); 00044 00048 void CreateChain(const b2Vec2* vertices, int32 count); 00049 00052 void SetPrevVertex(const b2Vec2& prevVertex); 00053 00056 void SetNextVertex(const b2Vec2& nextVertex); 00057 00059 b2Shape* Clone(b2BlockAllocator* allocator) const; 00060 00062 int32 GetChildCount() const; 00063 00065 void GetChildEdge(b2EdgeShape* edge, int32 index) const; 00066 00069 bool TestPoint(const b2Transform& transform, const b2Vec2& p) const; 00070 00072 bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, 00073 const b2Transform& transform, int32 childIndex) const; 00074 00076 void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const; 00077 00080 void ComputeMass(b2MassData* massData, float32 density) const; 00081 00083 int32 GetVertexCount() const { return m_count; } 00084 00086 const b2Vec2& GetVertex(int32 index) const 00087 { 00088 b2Assert(0 <= index && index < m_count); 00089 return m_vertices[index]; 00090 } 00091 00093 const b2Vec2* GetVertices() const { return m_vertices; } 00094 00095 protected: 00096 00098 b2Vec2* m_vertices; 00099 00101 int32 m_count; 00102 00103 b2Vec2 m_prevVertex, m_nextVertex; 00104 bool m_hasPrevVertex, m_hasNextVertex; 00105 }; 00106 00107 inline b2ChainShape::b2ChainShape() 00108 { 00109 m_type = e_chain; 00110 m_radius = b2_polygonRadius; 00111 m_vertices = NULL; 00112 m_count = 0; 00113 m_hasPrevVertex = NULL; 00114 m_hasNextVertex = NULL; 00115 } 00116 00117 #endif