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