Box2D: /build/box2d/src/box2d-2.4.2/include/box2d/b2_world_callbacks.h Source File

| Box2D 2.4.1 A 2D physics engine for games

Loading...
Searching...
No Matches
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
41 class B2_API b2DestructionListener
42{
43public:
44 virtual ~b2DestructionListener() {}
45
48 virtual void SayGoodbye(b2Joint* joint) = 0;
49
52 virtual void SayGoodbye(b2Fixture* fixture) = 0;
53};
54
57 class B2_API b2ContactFilter
58{
59public:
60 virtual ~b2ContactFilter() {}
61
64 virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB);
65};
66
70 struct B2_API b2ContactImpulse
71{
72 float normalImpulses[b2_maxManifoldPoints];
73 float tangentImpulses[b2_maxManifoldPoints];
74 int32 count;
75};
76
86 class B2_API b2ContactListener
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
128 class B2_API b2QueryCallback
129{
130public:
131 virtual ~b2QueryCallback() {}
132
135 virtual bool ReportFixture(b2Fixture* fixture) = 0;
136};
137
140 class B2_API b2RayCastCallback
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
b2_maxManifoldPoints
#define b2_maxManifoldPoints
Definition b2_common.h:51
b2_settings.h
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition b2_body.h:129
b2ContactFilter
Definition b2_world_callbacks.h:58
b2ContactFilter::ShouldCollide
virtual bool ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB)
b2Contact
Definition b2_contact.h:89
b2ContactListener
Definition b2_world_callbacks.h:87
b2ContactListener::BeginContact
virtual void BeginContact(b2Contact *contact)
Called when two fixtures begin to touch.
Definition b2_world_callbacks.h:92
b2ContactListener::PreSolve
virtual void PreSolve(b2Contact *contact, const b2Manifold *oldManifold)
Definition b2_world_callbacks.h:107
b2ContactListener::PostSolve
virtual void PostSolve(b2Contact *contact, const b2ContactImpulse *impulse)
Definition b2_world_callbacks.h:119
b2ContactListener::EndContact
virtual void EndContact(b2Contact *contact)
Called when two fixtures cease to touch.
Definition b2_world_callbacks.h:95
b2DestructionListener
Definition b2_world_callbacks.h:42
b2DestructionListener::SayGoodbye
virtual void SayGoodbye(b2Joint *joint)=0
b2DestructionListener::SayGoodbye
virtual void SayGoodbye(b2Fixture *fixture)=0
b2Fixture
Definition b2_fixture.h:117
b2Joint
Definition b2_joint.h:110
b2QueryCallback
Definition b2_world_callbacks.h:129
b2QueryCallback::ReportFixture
virtual bool ReportFixture(b2Fixture *fixture)=0
b2RayCastCallback
Definition b2_world_callbacks.h:141
b2RayCastCallback::ReportFixture
virtual float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction)=0
b2ContactImpulse
Definition b2_world_callbacks.h:71
b2Manifold
Definition b2_collision.h:100
b2Transform
Definition b2_math.h:339
b2Vec2
A 2D column vector.
Definition b2_math.h:42