Box2D 2.3.0 A 2D Physics Engine for Games

- Main Page
- Classes
- Files

- File List
- File Members

b2EdgeShape.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_EDGE_SHAPE_H
20 #define B2_EDGE_SHAPE_H
21
22 #include <Box2D/Collision/Shapes/b2Shape.h>
23
27 class b2EdgeShape : public b2Shape
28 {
29 public:
30 b2EdgeShape();
31
33 void Set(const b2Vec2& v1, const b2Vec2& v2);
34
36 b2Shape* Clone(b2BlockAllocator* allocator) const;
37
39 int32 GetChildCount() const;
40
42 bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
43
45 bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
46 const b2Transform& transform, int32 childIndex) const;
47
49 void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
50
52 void ComputeMass(b2MassData* massData, float32 density) const;
53
55 b2Vec2 m_vertex1, m_vertex2;
56
58 b2Vec2 m_vertex0, m_vertex3;
59 bool m_hasVertex0, m_hasVertex3;
60 };
61
62 inline b2EdgeShape::b2EdgeShape()
63 {
64 m_type = e_edge;
65 m_radius = b2_polygonRadius;
66 m_vertex0.x = 0.0f;
67 m_vertex0.y = 0.0f;
68 m_vertex3.x = 0.0f;
69 m_vertex3.y = 0.0f;
70 m_hasVertex0 = false;
71 m_hasVertex3 = false;
72 }
73
74 #endif
b2Transform
Definition: b2Math.h:350
b2EdgeShape::TestPoint
bool TestPoint(const b2Transform &transform, const b2Vec2 &p) const
Definition: b2EdgeShape.cpp:43
b2EdgeShape::GetChildCount
int32 GetChildCount() const
Definition: b2EdgeShape.cpp:38
b2BlockAllocator
Definition: b2BlockAllocator.h:35
b2MassData
This holds the mass data computed for a shape.
Definition: b2Shape.h:27
b2Shape
Definition: b2Shape.h:42
b2EdgeShape::m_vertex0
b2Vec2 m_vertex0
Optional adjacent vertices. These are used for smooth collision.
Definition: b2EdgeShape.h:58
b2RayCastOutput
Definition: b2Collision.h:155
b2EdgeShape::RayCast
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const
Implement b2Shape.
Definition: b2EdgeShape.cpp:54
b2EdgeShape::Clone
b2Shape * Clone(b2BlockAllocator *allocator) const
Implement b2Shape.
Definition: b2EdgeShape.cpp:30
b2_polygonRadius
#define b2_polygonRadius
Definition: b2Settings.h:77
b2AABB
An axis aligned bounding box.
Definition: b2Collision.h:162
b2RayCastInput
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
Definition: b2Collision.h:147
b2EdgeShape
Definition: b2EdgeShape.h:27
b2EdgeShape::ComputeAABB
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const
Definition: b2EdgeShape.cpp:116
b2EdgeShape::m_vertex1
b2Vec2 m_vertex1
These are the edge vertices.
Definition: b2EdgeShape.h:55
b2EdgeShape::Set
void Set(const b2Vec2 &v1, const b2Vec2 &v2)
Set this as an isolated edge.
Definition: b2EdgeShape.cpp:22
b2Vec2
A 2D column vector.
Definition: b2Math.h:53
b2EdgeShape::ComputeMass
void ComputeMass(b2MassData *massData, float32 density) const
Definition: b2EdgeShape.cpp:131