Box2D 2.4.1
A 2D physics engine for games
Loading...
Searching...
No Matches
b2_edge_shape.h
1// MIT License
2
3// Copyright (c) 2019 Erin Catto
4
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#ifndef B2_EDGE_SHAPE_H
24#define B2_EDGE_SHAPE_H
25
26#include "b2_api.h"
27#include "b2_shape.h"
28
32class B2_API b2EdgeShape : public b2Shape
33{
34public:
36
41 void SetOneSided(const b2Vec2& v0, const b2Vec2& v1,const b2Vec2& v2, const b2Vec2& v3);
42
44 void SetTwoSided(const b2Vec2& v1, const b2Vec2& v2);
45
47 b2Shape* Clone(b2BlockAllocator* allocator) const override;
48
50 int32 GetChildCount() const override;
51
53 bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override;
54
56 bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
57 const b2Transform& transform, int32 childIndex) const override;
58
60 void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override;
61
63 void ComputeMass(b2MassData* massData, float density) const override;
64
66 b2Vec2 m_vertex1, m_vertex2;
67
69 b2Vec2 m_vertex0, m_vertex3;
70
73};
74
75inline b2EdgeShape::b2EdgeShape()
76{
77 m_type = e_edge;
79 m_vertex0.x = 0.0f;
80 m_vertex0.y = 0.0f;
81 m_vertex3.x = 0.0f;
82 m_vertex3.y = 0.0f;
83 m_oneSided = false;
84}
85
86#endif
#define b2_polygonRadius
Definition b2_common.h:74
Definition b2_block_allocator.h:38
Definition b2_edge_shape.h:33
bool TestPoint(const b2Transform &transform, const b2Vec2 &p) const override
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const override
Implement b2Shape.
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const override
void ComputeMass(b2MassData *massData, float density) const override
b2Shape * Clone(b2BlockAllocator *allocator) const override
Implement b2Shape.
b2Vec2 m_vertex0
Optional adjacent vertices. These are used for smooth collision.
Definition b2_edge_shape.h:69
b2Vec2 m_vertex1
These are the edge vertices.
Definition b2_edge_shape.h:66
bool m_oneSided
Uses m_vertex0 and m_vertex3 to create smooth collision.
Definition b2_edge_shape.h:72
void SetOneSided(const b2Vec2 &v0, const b2Vec2 &v1, const b2Vec2 &v2, const b2Vec2 &v3)
void SetTwoSided(const b2Vec2 &v1, const b2Vec2 &v2)
Set this as an isolated edge. Collision is two-sided.
int32 GetChildCount() const override
Definition b2_shape.h:49
float m_radius
Definition b2_shape.h:102
An axis aligned bounding box.
Definition b2_collision.h:169
This holds the mass data computed for a shape.
Definition b2_shape.h:34
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
Definition b2_collision.h:154
Definition b2_collision.h:162
Definition b2_math.h:339
A 2D column vector.
Definition b2_math.h:42