LiquidFun
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
b2EdgeShape.h
1 /*
2 * Copyright (c) 2006-2010 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_EDGE_SHAPE_H
21 #define B2_EDGE_SHAPE_H
22 
23 #include <Box2D/Collision/Shapes/b2Shape.h>
24 
28 class b2EdgeShape : public b2Shape
29 {
30 public:
31  b2EdgeShape();
32 
34  void Set(const b2Vec2& v1, const b2Vec2& v2);
35 
37  b2Shape* Clone(b2BlockAllocator* allocator) const;
38 
40  int32 GetChildCount() const;
41 
43  bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
44 
45  // @see b2Shape::ComputeDistance
46  void ComputeDistance(const b2Transform& xf, const b2Vec2& p, float32* distance, b2Vec2* normal, int32 childIndex) const;
47 
49  bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
50  const b2Transform& transform, int32 childIndex) const;
51 
53  void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
54 
56  void ComputeMass(b2MassData* massData, float32 density) const;
57 
59  b2Vec2 m_vertex1, m_vertex2;
60 
62  b2Vec2 m_vertex0, m_vertex3;
63  bool m_hasVertex0, m_hasVertex3;
64 };
65 
66 inline b2EdgeShape::b2EdgeShape()
67 {
68  m_type = e_edge;
69  m_radius = b2_polygonRadius;
70  m_vertex0.x = 0.0f;
71  m_vertex0.y = 0.0f;
72  m_vertex3.x = 0.0f;
73  m_vertex3.y = 0.0f;
74  m_hasVertex0 = false;
75  m_hasVertex3 = false;
76 }
77 
78 #endif
Definition: b2Math.h:411
bool TestPoint(const b2Transform &transform, const b2Vec2 &p) const
Definition: b2EdgeShape.cpp:44
int32 GetChildCount() const
Definition: b2EdgeShape.cpp:39
Definition: b2BlockAllocator.h:36
This holds the mass data computed for a shape.
Definition: b2Shape.h:28
Definition: b2Shape.h:43
b2Vec2 m_vertex0
Optional adjacent vertices. These are used for smooth collision.
Definition: b2EdgeShape.h:62
Definition: b2Collision.h:155
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const
Implement b2Shape.
Definition: b2EdgeShape.cpp:84
b2Shape * Clone(b2BlockAllocator *allocator) const
Implement b2Shape.
Definition: b2EdgeShape.cpp:31
#define b2_polygonRadius
Definition: b2Settings.h:110
An axis aligned bounding box.
Definition: b2Collision.h:162
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
Definition: b2Collision.h:147
Definition: b2EdgeShape.h:28
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const
Definition: b2EdgeShape.cpp:146
void ComputeDistance(const b2Transform &xf, const b2Vec2 &p, float32 *distance, b2Vec2 *normal, int32 childIndex) const
Definition: b2EdgeShape.cpp:51
b2Vec2 m_vertex1
These are the edge vertices.
Definition: b2EdgeShape.h:59
void Set(const b2Vec2 &v1, const b2Vec2 &v2)
Set this as an isolated edge.
Definition: b2EdgeShape.cpp:23
A 2D column vector.
Definition: b2Math.h:56
void ComputeMass(b2MassData *massData, float32 density) const
Definition: b2EdgeShape.cpp:161