Box2D: b2CircleShape.h Source File

| Box2D 2.3.0 A 2D Physics Engine for Games

- Main Page
- Classes
- Files

- File List
- File Members

b2CircleShape.h
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
25 class b2CircleShape : public b2Shape
26 {
27 public:
28 b2CircleShape();
29
31 b2Shape* Clone(b2BlockAllocator* allocator) const;
32
34 int32 GetChildCount() const;
35
37 bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
38
40 bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
41 const b2Transform& transform, int32 childIndex) const;
42
44 void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
45
47 void ComputeMass(b2MassData* massData, float32 density) const;
48
50 int32 GetSupport(const b2Vec2& d) const;
51
53 const b2Vec2& GetSupportVertex(const b2Vec2& d) const;
54
56 int32 GetVertexCount() const { return 1; }
57
59 const b2Vec2& GetVertex(int32 index) const;
60
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
b2Transform
Definition: b2Math.h:350
b2CircleShape
A circle shape.
Definition: b2CircleShape.h:25
b2CircleShape::ComputeAABB
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const
Definition: b2CircleShape.cpp:83
b2CircleShape::TestPoint
bool TestPoint(const b2Transform &transform, const b2Vec2 &p) const
Implement b2Shape.
Definition: b2CircleShape.cpp:35
b2CircleShape::RayCast
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const
Implement b2Shape.
Definition: b2CircleShape.cpp:46
b2BlockAllocator
Definition: b2BlockAllocator.h:35
b2MassData
This holds the mass data computed for a shape.
Definition: b2Shape.h:27
b2Shape
Definition: b2Shape.h:42
b2RayCastOutput
Definition: b2Collision.h:155
b2Vec2::SetZero
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:62
b2CircleShape::ComputeMass
void ComputeMass(b2MassData *massData, float32 density) const
Definition: b2CircleShape.cpp:92
b2AABB
An axis aligned bounding box.
Definition: b2Collision.h:162
b2CircleShape::GetChildCount
int32 GetChildCount() const
Definition: b2CircleShape.cpp:30
b2CircleShape::GetSupportVertex
const b2Vec2 & GetSupportVertex(const b2Vec2 &d) const
Get the supporting vertex in the given direction.
Definition: b2CircleShape.h:78
b2CircleShape::GetVertex
const b2Vec2 & GetVertex(int32 index) const
Get a vertex by index. Used by b2Distance.
Definition: b2CircleShape.h:84
b2RayCastInput
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
Definition: b2Collision.h:147
b2CircleShape::m_p
b2Vec2 m_p
Position.
Definition: b2CircleShape.h:62
b2CircleShape::Clone
b2Shape * Clone(b2BlockAllocator *allocator) const
Implement b2Shape.
Definition: b2CircleShape.cpp:22
b2Vec2
A 2D column vector.
Definition: b2Math.h:53
b2CircleShape::GetSupport
int32 GetSupport(const b2Vec2 &d) const
Get the supporting vertex index in the given direction.
Definition: b2CircleShape.h:72
b2CircleShape::GetVertexCount
int32 GetVertexCount() const
Get the vertex count.
Definition: b2CircleShape.h:56