| 1 | /* | 
|---|
| 2 | * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org | 
|---|
| 3 | * | 
|---|
| 4 | * This software is provided 'as-is', without any express or implied | 
|---|
| 5 | * warranty.  In no event will the authors be held liable for any damages | 
|---|
| 6 | * arising from the use of this software. | 
|---|
| 7 | * Permission is granted to anyone to use this software for any purpose, | 
|---|
| 8 | * including commercial applications, and to alter it and redistribute it | 
|---|
| 9 | * freely, subject to the following restrictions: | 
|---|
| 10 | * 1. The origin of this software must not be misrepresented; you must not | 
|---|
| 11 | * claim that you wrote the original software. If you use this software | 
|---|
| 12 | * in a product, an acknowledgment in the product documentation would be | 
|---|
| 13 | * appreciated but is not required. | 
|---|
| 14 | * 2. Altered source versions must be plainly marked as such, and must not be | 
|---|
| 15 | * misrepresented as being the original software. | 
|---|
| 16 | * 3. This notice may not be removed or altered from any source distribution. | 
|---|
| 17 | */ | 
|---|
| 18 |  | 
|---|
| 19 | #ifndef B2_CIRCLE_SHAPE_H | 
|---|
| 20 | #define B2_CIRCLE_SHAPE_H | 
|---|
| 21 |  | 
|---|
| 22 | #include <Box2D/Collision/Shapes/b2Shape.h> | 
|---|
| 23 |  | 
|---|
| 24 | /// A circle shape. | 
|---|
| 25 | class b2CircleShape : public b2Shape | 
|---|
| 26 | { | 
|---|
| 27 | public: | 
|---|
| 28 | b2CircleShape(); | 
|---|
| 29 |  | 
|---|
| 30 | /// Implement b2Shape. | 
|---|
| 31 | b2Shape* Clone(b2BlockAllocator* allocator) const; | 
|---|
| 32 |  | 
|---|
| 33 | /// @see b2Shape::GetChildCount | 
|---|
| 34 | int32 GetChildCount() const; | 
|---|
| 35 |  | 
|---|
| 36 | /// Implement b2Shape. | 
|---|
| 37 | bool TestPoint(const b2Transform& transform, const b2Vec2& p) const; | 
|---|
| 38 |  | 
|---|
| 39 | /// Implement b2Shape. | 
|---|
| 40 | bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, | 
|---|
| 41 | const b2Transform& transform, int32 childIndex) const; | 
|---|
| 42 |  | 
|---|
| 43 | /// @see b2Shape::ComputeAABB | 
|---|
| 44 | void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const; | 
|---|
| 45 |  | 
|---|
| 46 | /// @see b2Shape::ComputeMass | 
|---|
| 47 | void ComputeMass(b2MassData* massData, float32 density) const; | 
|---|
| 48 |  | 
|---|
| 49 | /// Get the supporting vertex index in the given direction. | 
|---|
| 50 | int32 GetSupport(const b2Vec2& d) const; | 
|---|
| 51 |  | 
|---|
| 52 | /// Get the supporting vertex in the given direction. | 
|---|
| 53 | const b2Vec2& GetSupportVertex(const b2Vec2& d) const; | 
|---|
| 54 |  | 
|---|
| 55 | /// Get the vertex count. | 
|---|
| 56 | int32 GetVertexCount() const { return 1; } | 
|---|
| 57 |  | 
|---|
| 58 | /// Get a vertex by index. Used by b2Distance. | 
|---|
| 59 | const b2Vec2& GetVertex(int32 index) const; | 
|---|
| 60 |  | 
|---|
| 61 | /// Position | 
|---|
| 62 | b2Vec2 m_p; | 
|---|
| 63 | }; | 
|---|
| 64 |  | 
|---|
| 65 | inline b2CircleShape::b2CircleShape() | 
|---|
| 66 | { | 
|---|
| 67 | m_type = e_circle; | 
|---|
| 68 | m_radius = 0.0f; | 
|---|
| 69 | m_p.SetZero(); | 
|---|
| 70 | } | 
|---|
| 71 |  | 
|---|
| 72 | inline int32 b2CircleShape::GetSupport(const b2Vec2 &d) const | 
|---|
| 73 | { | 
|---|
| 74 | B2_NOT_USED(d); | 
|---|
| 75 | return 0; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | inline const b2Vec2& b2CircleShape::GetSupportVertex(const b2Vec2 &d) const | 
|---|
| 79 | { | 
|---|
| 80 | B2_NOT_USED(d); | 
|---|
| 81 | return m_p; | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 | inline const b2Vec2& b2CircleShape::GetVertex(int32 index) const | 
|---|
| 85 | { | 
|---|
| 86 | B2_NOT_USED(index); | 
|---|
| 87 | b2Assert(index == 0); | 
|---|
| 88 | return m_p; | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 | #endif | 
|---|
| 92 |  | 
|---|