Box2D: Box2D/Box2D/Dynamics/b2WorldCallbacks.h Source File

- Main Page
- Classes
- Files

- File List
- File Members

# Box2D/Box2D/Dynamics/b2WorldCallbacks.h

Go to the documentation of this file.

    00001 /*
    00002 * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
    00003 *
    00004 * This software is provided 'as-is', without any express or implied
    00005 * warranty.  In no event will the authors be held liable for any damages
    00006 * arising from the use of this software.
    00007 * Permission is granted to anyone to use this software for any purpose,
    00008 * including commercial applications, and to alter it and redistribute it
    00009 * freely, subject to the following restrictions:
    00010 * 1. The origin of this software must not be misrepresented; you must not
    00011 * claim that you wrote the original software. If you use this software
    00012 * in a product, an acknowledgment in the product documentation would be
    00013 * appreciated but is not required.
    00014 * 2. Altered source versions must be plainly marked as such, and must not be
    00015 * misrepresented as being the original software.
    00016 * 3. This notice may not be removed or altered from any source distribution.
    00017 */
    00018
    00019 #ifndef B2_WORLD_CALLBACKS_H
    00020 #define B2_WORLD_CALLBACKS_H
    00021
    00022 #include <Box2D/Common/b2Settings.h>
    00023
    00024 struct b2Vec2;
    00025 struct b2Transform;
    00026 class b2Fixture;
    00027 class b2Body;
    00028 class b2Joint;
    00029 class b2Contact;
    00030 struct b2ContactPoint;
    00031 struct b2ContactResult;
    00032 struct b2Manifold;
    00033
    00037 class b2DestructionListener
    00038 {
    00039 public:
    00040         virtual ~b2DestructionListener() {}
    00041
    00044         virtual void SayGoodbye(b2Joint* joint) = 0;
    00045
    00048         virtual void SayGoodbye(b2Fixture* fixture) = 0;
    00049 };
    00050
    00053 class b2ContactFilter
    00054 {
    00055 public:
    00056         virtual ~b2ContactFilter() {}
    00057
    00060         virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB);
    00061 };
    00062
    00066 struct b2ContactImpulse
    00067 {
    00068         float32 normalImpulses[b2_maxManifoldPoints];
    00069         float32 tangentImpulses[b2_maxManifoldPoints];
    00070 };
    00071
    00081 class b2ContactListener
    00082 {
    00083 public:
    00084         virtual ~b2ContactListener() {}
    00085
    00087         virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); }
    00088
    00090         virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); }
    00091
    00102         virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
    00103         {
    00104                 B2_NOT_USED(contact);
    00105                 B2_NOT_USED(oldManifold);
    00106         }
    00107
    00114         virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
    00115         {
    00116                 B2_NOT_USED(contact);
    00117                 B2_NOT_USED(impulse);
    00118         }
    00119 };
    00120
    00123 class b2QueryCallback
    00124 {
    00125 public:
    00126         virtual ~b2QueryCallback() {}
    00127
    00130         virtual bool ReportFixture(b2Fixture* fixture) = 0;
    00131 };
    00132
    00135 class b2RayCastCallback
    00136 {
    00137 public:
    00138         virtual ~b2RayCastCallback() {}
    00139
    00151         virtual float32 ReportFixture(  b2Fixture* fixture, const b2Vec2& point,
    00152                                                                         const b2Vec2& normal, float32 fraction) = 0;
    00153 };
    00154
    00156 struct b2Color
    00157 {
    00158         b2Color() {}
    00159         b2Color(float32 r, float32 g, float32 b) : r(r), g(g), b(b) {}
    00160         void Set(float32 ri, float32 gi, float32 bi) { r = ri; g = gi; b = bi; }
    00161         float32 r, g, b;
    00162 };
    00163
    00166 class b2DebugDraw
    00167 {
    00168 public:
    00169         b2DebugDraw();
    00170
    00171         virtual ~b2DebugDraw() {}
    00172
    00173         enum
    00174         {
    00175                 e_shapeBit                              = 0x0001,
    00176                 e_jointBit                              = 0x0002,
    00177                 e_aabbBit                               = 0x0004,
    00178                 e_pairBit                               = 0x0008,
    00179                 e_centerOfMassBit               = 0x0010,
    00180         };
    00181
    00183         void SetFlags(uint32 flags);
    00184
    00186         uint32 GetFlags() const;
    00187
    00189         void AppendFlags(uint32 flags);
    00190
    00192         void ClearFlags(uint32 flags);
    00193
    00195         virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0;
    00196
    00198         virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0;
    00199
    00201         virtual void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) = 0;
    00202
    00204         virtual void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) = 0;
    00205
    00207         virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) = 0;
    00208
    00211         virtual void DrawTransform(const b2Transform& xf) = 0;
    00212
    00213 protected:
    00214         uint32 m_drawFlags;
    00215 };
    00216
    00217 #endif