LiquidFun
 All Classes Files Functions Variables 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 struct b2ContactResult;
32 struct b2Manifold;
33 class b2ParticleGroup;
34 
39 {
40 public:
41  virtual ~b2DestructionListener() {}
42 
45  virtual void SayGoodbye(b2Joint* joint) = 0;
46 
49  virtual void SayGoodbye(b2Fixture* fixture) = 0;
50 
52  virtual void SayGoodbye(b2ParticleGroup* group)
53  {
54  B2_NOT_USED(group);
55  }
56 
61  virtual void SayGoodbye(int32 index)
62  {
63  B2_NOT_USED(index);
64  }
65 };
66 
70 {
71 public:
72  virtual ~b2ContactFilter() {}
73 
76  virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB);
77 };
78 
83 {
84  float32 normalImpulses[b2_maxManifoldPoints];
85  float32 tangentImpulses[b2_maxManifoldPoints];
86  int32 count;
87 };
88 
99 {
100 public:
101  virtual ~b2ContactListener() {}
102 
104  virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); }
105 
107  virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); }
108 
119  virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
120  {
121  B2_NOT_USED(contact);
122  B2_NOT_USED(oldManifold);
123  }
124 
131  virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
132  {
133  B2_NOT_USED(contact);
134  B2_NOT_USED(impulse);
135  }
136 };
137 
141 {
142 public:
143  virtual ~b2QueryCallback() {}
144 
147  virtual bool ReportFixture(b2Fixture* fixture) = 0;
148 
151  virtual bool ReportParticle(int32 index)
152  {
153  B2_NOT_USED(index);
154  return false;
155  }
156 };
157 
161 {
162 public:
163  virtual ~b2RayCastCallback() {}
164 
176  virtual float32 ReportFixture( b2Fixture* fixture, const b2Vec2& point,
177  const b2Vec2& normal, float32 fraction) = 0;
178 
180  virtual float32 ReportParticle( int32 index, const b2Vec2& point,
181  const b2Vec2& normal, float32 fraction)
182  {
183  return 0;
184  }
185 };
186 
187 #endif
Definition: b2Math.h:361
Definition: b2WorldCallbacks.h:38
virtual void SayGoodbye(b2ParticleGroup *group)
Called when any particle group is about to be destroyed.
Definition: b2WorldCallbacks.h:52
Definition: b2WorldCallbacks.h:82
Definition: b2WorldCallbacks.h:160
virtual void SayGoodbye(b2Joint *joint)=0
virtual float32 ReportParticle(int32 index, const b2Vec2 &point, const b2Vec2 &normal, float32 fraction)
Called for each particle found in the query.
Definition: b2WorldCallbacks.h:180
Definition: b2WorldCallbacks.h:69
Definition: b2WorldCallbacks.h:98
Definition: b2Joint.h:103
virtual bool ReportFixture(b2Fixture *fixture)=0
virtual void PreSolve(b2Contact *contact, const b2Manifold *oldManifold)
Definition: b2WorldCallbacks.h:119
A group of particles. These are created via b2World::CreateParticleGroup.
Definition: b2ParticleGroup.h:93
virtual bool ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB)
Definition: b2WorldCallbacks.cpp:24
virtual void SayGoodbye(int32 index)
Definition: b2WorldCallbacks.h:61
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:127
Definition: b2Collision.h:93
virtual void PostSolve(b2Contact *contact, const b2ContactImpulse *impulse)
Definition: b2WorldCallbacks.h:131
virtual float32 ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float32 fraction)=0
virtual void BeginContact(b2Contact *contact)
Called when two fixtures begin to touch.
Definition: b2WorldCallbacks.h:104
A 2D column vector.
Definition: b2Math.h:64
Definition: b2Contact.h:77
#define b2_maxManifoldPoints
Definition: b2Settings.h:56
virtual void EndContact(b2Contact *contact)
Called when two fixtures cease to touch.
Definition: b2WorldCallbacks.h:107
Definition: b2WorldCallbacks.h:140
virtual bool ReportParticle(int32 index)
Definition: b2WorldCallbacks.h:151
Definition: b2Fixture.h:108