Box2D  2.4.0
A 2D physics engine for games
b2_world_callbacks.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_WORLD_CALLBACKS_H
24 #define B2_WORLD_CALLBACKS_H
25 
26 #include "b2_settings.h"
27 
28 struct b2Vec2;
29 struct b2Transform;
30 class b2Fixture;
31 class b2Body;
32 class b2Joint;
33 class b2Contact;
34 struct b2ContactResult;
35 struct b2Manifold;
36 
41 {
42 public:
43  virtual ~b2DestructionListener() {}
44 
47  virtual void SayGoodbye(b2Joint* joint) = 0;
48 
51  virtual void SayGoodbye(b2Fixture* fixture) = 0;
52 };
53 
57 {
58 public:
59  virtual ~b2ContactFilter() {}
60 
63  virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB);
64 };
65 
70 {
71  float normalImpulses[b2_maxManifoldPoints];
72  float tangentImpulses[b2_maxManifoldPoints];
73  int32 count;
74 };
75 
86 {
87 public:
88  virtual ~b2ContactListener() {}
89 
91  virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); }
92 
94  virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); }
95 
106  virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
107  {
108  B2_NOT_USED(contact);
109  B2_NOT_USED(oldManifold);
110  }
111 
118  virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
119  {
120  B2_NOT_USED(contact);
121  B2_NOT_USED(impulse);
122  }
123 };
124 
128 {
129 public:
130  virtual ~b2QueryCallback() {}
131 
134  virtual bool ReportFixture(b2Fixture* fixture) = 0;
135 };
136 
140 {
141 public:
142  virtual ~b2RayCastCallback() {}
143 
156  virtual float ReportFixture( b2Fixture* fixture, const b2Vec2& point,
157  const b2Vec2& normal, float fraction) = 0;
158 };
159 
160 #endif
b2Vec2
A 2D column vector.
Definition: b2_math.h:39
b2ContactListener::PreSolve
virtual void PreSolve(b2Contact *contact, const b2Manifold *oldManifold)
Definition: b2_world_callbacks.h:106
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition: b2_body.h:131
b2_settings.h
b2ContactFilter::ShouldCollide
virtual bool ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB)
b2ContactListener
Definition: b2_world_callbacks.h:85
b2Transform
Definition: b2_math.h:336
b2ContactListener::BeginContact
virtual void BeginContact(b2Contact *contact)
Called when two fixtures begin to touch.
Definition: b2_world_callbacks.h:91
b2RayCastCallback::ReportFixture
virtual float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction)=0
b2Manifold
Definition: b2_collision.h:97
b2QueryCallback
Definition: b2_world_callbacks.h:127
b2DestructionListener::SayGoodbye
virtual void SayGoodbye(b2Joint *joint)=0
b2ContactListener::PostSolve
virtual void PostSolve(b2Contact *contact, const b2ContactImpulse *impulse)
Definition: b2_world_callbacks.h:118
b2ContactListener::EndContact
virtual void EndContact(b2Contact *contact)
Called when two fixtures cease to touch.
Definition: b2_world_callbacks.h:94
b2Fixture
Definition: b2_fixture.h:111
b2QueryCallback::ReportFixture
virtual bool ReportFixture(b2Fixture *fixture)=0
b2ContactImpulse
Definition: b2_world_callbacks.h:69
b2_maxManifoldPoints
#define b2_maxManifoldPoints
Definition: b2_settings.h:56
b2Contact
Definition: b2_contact.h:81
b2RayCastCallback
Definition: b2_world_callbacks.h:139
b2ContactFilter
Definition: b2_world_callbacks.h:56
b2Joint
Definition: b2_joint.h:107
b2DestructionListener
Definition: b2_world_callbacks.h:40