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 
58 #if LIQUIDFUN_EXTERNAL_LANGUAGE_API
59 public:
61  void Set(float32 vx1, float32 vy1, float32 vx2, float32 vy2);
62 #endif // LIQUIDFUN_EXTERNAL_LANGUAGE_API
63 
65  b2Vec2 m_vertex1, m_vertex2;
66 
68  b2Vec2 m_vertex0, m_vertex3;
69  bool m_hasVertex0, m_hasVertex3;
70 };
71 
72 inline b2EdgeShape::b2EdgeShape()
73 {
74  m_type = e_edge;
75  m_radius = b2_polygonRadius;
76  m_vertex0.x = 0.0f;
77  m_vertex0.y = 0.0f;
78  m_vertex3.x = 0.0f;
79  m_vertex3.y = 0.0f;
80  m_hasVertex0 = false;
81  m_hasVertex3 = false;
82 }
83 
84 #if LIQUIDFUN_EXTERNAL_LANGUAGE_API
85 inline void b2EdgeShape::Set(float32 vx1,
86  float32 vy1,
87  float32 vx2,
88  float32 vy2) {
89  Set(b2Vec2(vx1, vy1), b2Vec2(vx2, vy2));
90 }
91 #endif // LIQUIDFUN_EXTERNAL_LANGUAGE_API
92 
93 
94 #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:68
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:120
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:65
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