| Box2D 2.3.0 A 2D Physics Engine for Games

b2ChainShape.h
1 /*
2 * Copyright (c) 2006-2010 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_CHAIN_SHAPE_H
20 #define B2_CHAIN_SHAPE_H
21
22 #include <Box2D/Collision/Shapes/b2Shape.h>
23
24 class b2EdgeShape;
25
32 class b2ChainShape : public b2Shape
33 {
34 public:
35 b2ChainShape();
36
38 ~b2ChainShape();
39
41 void Clear();
42
46 void CreateLoop(const b2Vec2* vertices, int32 count);
47
51 void CreateChain(const b2Vec2* vertices, int32 count);
52
55 void SetPrevVertex(const b2Vec2& prevVertex);
56
59 void SetNextVertex(const b2Vec2& nextVertex);
60
62 b2Shape* Clone(b2BlockAllocator* allocator) const;
63
65 int32 GetChildCount() const;
66
68 void GetChildEdge(b2EdgeShape* edge, int32 index) const;
69
72 bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
73
75 bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
76 const b2Transform& transform, int32 childIndex) const;
77
79 void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
80
83 void ComputeMass(b2MassData* massData, float32 density) const;
84
86 b2Vec2* m_vertices;
87
89 int32 m_count;
90
91 b2Vec2 m_prevVertex, m_nextVertex;
92 bool m_hasPrevVertex, m_hasNextVertex;
93 };
94
95 inline b2ChainShape::b2ChainShape()
96 {
97 m_type = e_chain;
98 m_radius = b2_polygonRadius;
99 m_vertices = NULL;
100 m_count = 0;
101 m_hasPrevVertex = false;
102 m_hasNextVertex = false;
103 }
104
105 #endif
b2Transform
Definition: b2Math.h:350
b2ChainShape
Definition: b2ChainShape.h:32
b2ChainShape::ComputeMass
void ComputeMass(b2MassData *massData, float32 density) const
Definition: b2ChainShape.cpp:186
b2ChainShape::Clear
void Clear()
Clear all data.
Definition: b2ChainShape.cpp:29
b2ChainShape::Clone
b2Shape * Clone(b2BlockAllocator *allocator) const
Implement b2Shape. Vertices are cloned using b2Alloc.
Definition: b2ChainShape.cpp:91
b2ChainShape::CreateChain
void CreateChain(const b2Vec2 *vertices, int32 count)
Definition: b2ChainShape.cpp:58
b2ChainShape::RayCast
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const
Implement b2Shape.
Definition: b2ChainShape.cpp:148
b2BlockAllocator
Definition: b2BlockAllocator.h:35
b2MassData
This holds the mass data computed for a shape.
Definition: b2Shape.h:27
b2Shape
Definition: b2Shape.h:42
b2ChainShape::GetChildCount
int32 GetChildCount() const
Definition: b2ChainShape.cpp:103
b2RayCastOutput
Definition: b2Collision.h:155
b2ChainShape::m_count
int32 m_count
The vertex count.
Definition: b2ChainShape.h:89
b2_polygonRadius
#define b2_polygonRadius
Definition: b2Settings.h:77
b2AABB
An axis aligned bounding box.
Definition: b2Collision.h:162
b2ChainShape::SetNextVertex
void SetNextVertex(const b2Vec2 &nextVertex)
Definition: b2ChainShape.cpp:85
b2RayCastInput
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
Definition: b2Collision.h:147
b2EdgeShape
Definition: b2EdgeShape.h:27
b2ChainShape::ComputeAABB
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const
Definition: b2ChainShape.cpp:168
b2ChainShape::TestPoint
bool TestPoint(const b2Transform &transform, const b2Vec2 &p) const
Definition: b2ChainShape.cpp:141
b2ChainShape::CreateLoop
void CreateLoop(const b2Vec2 *vertices, int32 count)
Definition: b2ChainShape.cpp:36
b2ChainShape::~b2ChainShape
~b2ChainShape()
The destructor frees the vertices using b2Free.
Definition: b2ChainShape.cpp:24
b2ChainShape::m_vertices
b2Vec2 * m_vertices
The vertices. Owned by this class.
Definition: b2ChainShape.h:86
b2ChainShape::GetChildEdge
void GetChildEdge(b2EdgeShape *edge, int32 index) const
Get a child edge.
Definition: b2ChainShape.cpp:109
b2Vec2
A 2D column vector.
Definition: b2Math.h:53
b2ChainShape::SetPrevVertex
void SetPrevVertex(const b2Vec2 &prevVertex)
Definition: b2ChainShape.cpp:79