Box2D 2.4.1
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_api.h"
27#include "b2_settings.h"
28
29struct b2Vec2;
30struct b2Transform;
31class b2Fixture;
32class b2Body;
33class b2Joint;
34class b2Contact;
35struct b2ContactResult;
36struct b2Manifold;
37
42{
43public:
44 virtual ~b2DestructionListener() {}
45
48 virtual void SayGoodbye(b2Joint* joint) = 0;
49
52 virtual void SayGoodbye(b2Fixture* fixture) = 0;
53};
54
57class B2_API b2ContactFilter
58{
59public:
60 virtual ~b2ContactFilter() {}
61
64 virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB);
65};
66
70struct B2_API b2ContactImpulse
71{
72 float normalImpulses[b2_maxManifoldPoints];
73 float tangentImpulses[b2_maxManifoldPoints];
74 int32 count;
75};
76
87{
88public:
89 virtual ~b2ContactListener() {}
90
92 virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); }
93
95 virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); }
96
107 virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
108 {
109 B2_NOT_USED(contact);
110 B2_NOT_USED(oldManifold);
111 }
112
119 virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
120 {
121 B2_NOT_USED(contact);
122 B2_NOT_USED(impulse);
123 }
124};
125
128class B2_API b2QueryCallback
129{
130public:
131 virtual ~b2QueryCallback() {}
132
135 virtual bool ReportFixture(b2Fixture* fixture) = 0;
136};
137
141{
142public:
143 virtual ~b2RayCastCallback() {}
144
157 virtual float ReportFixture( b2Fixture* fixture, const b2Vec2& point,
158 const b2Vec2& normal, float fraction) = 0;
159};
160
161#endif
#define b2_maxManifoldPoints
Definition: b2_common.h:51
A rigid body. These are created via b2World::CreateBody.
Definition: b2_body.h:129
Definition: b2_world_callbacks.h:58
virtual bool ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB)
Definition: b2_contact.h:89
Definition: b2_world_callbacks.h:87
virtual void BeginContact(b2Contact *contact)
Called when two fixtures begin to touch.
Definition: b2_world_callbacks.h:92
virtual void PreSolve(b2Contact *contact, const b2Manifold *oldManifold)
Definition: b2_world_callbacks.h:107
virtual void PostSolve(b2Contact *contact, const b2ContactImpulse *impulse)
Definition: b2_world_callbacks.h:119
virtual void EndContact(b2Contact *contact)
Called when two fixtures cease to touch.
Definition: b2_world_callbacks.h:95
Definition: b2_world_callbacks.h:42
virtual void SayGoodbye(b2Joint *joint)=0
virtual void SayGoodbye(b2Fixture *fixture)=0
Definition: b2_fixture.h:117
Definition: b2_joint.h:111
Definition: b2_world_callbacks.h:129
virtual bool ReportFixture(b2Fixture *fixture)=0
Definition: b2_world_callbacks.h:141
virtual float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction)=0
Definition: b2_world_callbacks.h:71
Definition: b2_collision.h:100
Definition: b2_math.h:339
A 2D column vector.
Definition: b2_math.h:42