00001 /* 00002 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org 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 b2ContactResult; 00031 struct b2Manifold; 00032 00036 class b2DestructionListener 00037 { 00038 public: 00039 virtual ~b2DestructionListener() {} 00040 00043 virtual void SayGoodbye(b2Joint* joint) = 0; 00044 00047 virtual void SayGoodbye(b2Fixture* fixture) = 0; 00048 }; 00049 00052 class b2ContactFilter 00053 { 00054 public: 00055 virtual ~b2ContactFilter() {} 00056 00059 virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB); 00060 }; 00061 00065 struct b2ContactImpulse 00066 { 00067 float32 normalImpulses[b2_maxManifoldPoints]; 00068 float32 tangentImpulses[b2_maxManifoldPoints]; 00069 int32 count; 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 00155 #endif