LiquidFun
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
b2WorldCallbacks.h
1 /*
2 * Copyright (c) 2006-2009 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_WORLD_CALLBACKS_H
21 #define B2_WORLD_CALLBACKS_H
22 
24 
25 struct b2Vec2;
26 struct b2Transform;
27 class b2Fixture;
28 class b2Body;
29 class b2Joint;
30 class b2Contact;
31 class b2ParticleSystem;
32 struct b2ContactResult;
33 struct b2Manifold;
34 class b2ParticleGroup;
36 struct b2ParticleContact;
37 
42 {
43 public:
44  virtual ~b2DestructionListener() {}
45 
48  virtual void SayGoodbye(b2Joint* joint) = 0;
49 
52  virtual void SayGoodbye(b2Fixture* fixture) = 0;
53 
55  virtual void SayGoodbye(b2ParticleGroup* group)
56  {
57  B2_NOT_USED(group);
58  }
59 
65  virtual void SayGoodbye(b2ParticleSystem* particleSystem, int32 index)
66  {
67  B2_NOT_USED(particleSystem);
68  B2_NOT_USED(index);
69  }
70 };
71 
75 {
76 public:
77  virtual ~b2ContactFilter() {}
78 
81  virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB);
82 
86  virtual bool ShouldCollide(b2Fixture* fixture,
87  b2ParticleSystem* particleSystem,
88  int32 particleIndex)
89  {
90  B2_NOT_USED(fixture);
91  B2_NOT_USED(particleIndex);
92  B2_NOT_USED(particleSystem);
93  return true;
94  }
95 
99  virtual bool ShouldCollide(b2ParticleSystem* particleSystem,
100  int32 particleIndexA, int32 particleIndexB)
101  {
102  B2_NOT_USED(particleSystem);
103  B2_NOT_USED(particleIndexA);
104  B2_NOT_USED(particleIndexB);
105  return true;
106  }
107 };
108 
113 {
114  float32 normalImpulses[b2_maxManifoldPoints];
115  float32 tangentImpulses[b2_maxManifoldPoints];
116  int32 count;
117 };
118 
129 {
130 public:
131  virtual ~b2ContactListener() {}
132 
134  virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); }
135 
137  virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); }
138 
141  virtual void BeginContact(b2ParticleSystem* particleSystem,
142  b2ParticleBodyContact* particleBodyContact)
143  {
144  B2_NOT_USED(particleSystem);
145  B2_NOT_USED(particleBodyContact);
146  }
147 
150  virtual void EndContact(b2Fixture* fixture,
151  b2ParticleSystem* particleSystem, int32 index)
152  {
153  B2_NOT_USED(fixture);
154  B2_NOT_USED(particleSystem);
155  B2_NOT_USED(index);
156  }
157 
160  virtual void BeginContact(b2ParticleSystem* particleSystem,
161  b2ParticleContact* particleContact)
162  {
163  B2_NOT_USED(particleSystem);
164  B2_NOT_USED(particleContact);
165  }
166 
169  virtual void EndContact(b2ParticleSystem* particleSystem,
170  int32 indexA, int32 indexB)
171  {
172  B2_NOT_USED(particleSystem);
173  B2_NOT_USED(indexA);
174  B2_NOT_USED(indexB);
175  }
176 
187  virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
188  {
189  B2_NOT_USED(contact);
190  B2_NOT_USED(oldManifold);
191  }
192 
199  virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
200  {
201  B2_NOT_USED(contact);
202  B2_NOT_USED(impulse);
203  }
204 };
205 
209 {
210 public:
211  virtual ~b2QueryCallback() {}
212 
215  virtual bool ReportFixture(b2Fixture* fixture) = 0;
216 
219  virtual bool ReportParticle(const b2ParticleSystem* particleSystem,
220  int32 index)
221  {
222  B2_NOT_USED(particleSystem);
223  B2_NOT_USED(index);
224  return false;
225  }
226 
232  const b2ParticleSystem* particleSystem)
233  {
234  B2_NOT_USED(particleSystem);
235  return true;
236  }
237 };
238 
242 {
243 public:
244  virtual ~b2RayCastCallback() {}
245 
257  virtual float32 ReportFixture( b2Fixture* fixture, const b2Vec2& point,
258  const b2Vec2& normal, float32 fraction) = 0;
259 
275  virtual float32 ReportParticle(const b2ParticleSystem* particleSystem,
276  int32 index, const b2Vec2& point,
277  const b2Vec2& normal, float32 fraction)
278  {
279  B2_NOT_USED(particleSystem);
280  B2_NOT_USED(index);
281  B2_NOT_USED(&point);
282  B2_NOT_USED(&normal);
283  B2_NOT_USED(fraction);
284  return 0;
285  }
286 
292  const b2ParticleSystem* particleSystem)
293  {
294  B2_NOT_USED(particleSystem);
295  return true;
296  }
297 };
298 
299 #endif
Definition: b2Math.h:411
Definition: b2WorldCallbacks.h:41
virtual float32 ReportParticle(const b2ParticleSystem *particleSystem, int32 index, const b2Vec2 &point, const b2Vec2 &normal, float32 fraction)
Definition: b2WorldCallbacks.h:275
virtual void SayGoodbye(b2ParticleGroup *group)
Called when any particle group is about to be destroyed.
Definition: b2WorldCallbacks.h:55
Definition: b2WorldCallbacks.h:112
virtual void EndContact(b2ParticleSystem *particleSystem, int32 indexA, int32 indexB)
Definition: b2WorldCallbacks.h:169
Definition: b2WorldCallbacks.h:241
virtual bool ShouldCollide(b2Fixture *fixture, b2ParticleSystem *particleSystem, int32 particleIndex)
Definition: b2WorldCallbacks.h:86
virtual void SayGoodbye(b2Joint *joint)=0
virtual void BeginContact(b2ParticleSystem *particleSystem, b2ParticleContact *particleContact)
Definition: b2WorldCallbacks.h:160
Definition: b2ParticleSystem.h:281
Definition: b2WorldCallbacks.h:74
Definition: b2WorldCallbacks.h:128
virtual void BeginContact(b2ParticleSystem *particleSystem, b2ParticleBodyContact *particleBodyContact)
Definition: b2WorldCallbacks.h:141
Definition: b2Joint.h:103
virtual bool ShouldQueryParticleSystem(const b2ParticleSystem *particleSystem)
Definition: b2WorldCallbacks.h:231
virtual bool ReportFixture(b2Fixture *fixture)=0
virtual void PreSolve(b2Contact *contact, const b2Manifold *oldManifold)
Definition: b2WorldCallbacks.h:187
A group of particles. b2ParticleGroup::CreateParticleGroup creates these.
Definition: b2ParticleGroup.h:172
virtual bool ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB)
Definition: b2WorldCallbacks.cpp:24
virtual bool ReportParticle(const b2ParticleSystem *particleSystem, int32 index)
Definition: b2WorldCallbacks.h:219
virtual bool ShouldCollide(b2ParticleSystem *particleSystem, int32 particleIndexA, int32 particleIndexB)
Definition: b2WorldCallbacks.h:99
virtual void EndContact(b2Fixture *fixture, b2ParticleSystem *particleSystem, int32 index)
Definition: b2WorldCallbacks.h:150
Definition: b2ParticleSystem.h:99
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:132
Definition: b2Collision.h:93
virtual void PostSolve(b2Contact *contact, const b2ContactImpulse *impulse)
Definition: b2WorldCallbacks.h:199
virtual float32 ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float32 fraction)=0
virtual void SayGoodbye(b2ParticleSystem *particleSystem, int32 index)
Definition: b2WorldCallbacks.h:65
virtual void BeginContact(b2Contact *contact)
Called when two fixtures begin to touch.
Definition: b2WorldCallbacks.h:134
Definition: b2ParticleSystem.h:53
A 2D column vector.
Definition: b2Math.h:56
virtual bool ShouldQueryParticleSystem(const b2ParticleSystem *particleSystem)
Definition: b2WorldCallbacks.h:291
Definition: b2Contact.h:77
#define b2_maxManifoldPoints
Definition: b2Settings.h:93
virtual void EndContact(b2Contact *contact)
Called when two fixtures cease to touch.
Definition: b2WorldCallbacks.h:137
Definition: b2WorldCallbacks.h:208
Definition: b2Fixture.h:108