28#include "b2_fixture.h"
42inline float b2MixFriction(
float friction1,
float friction2)
44 return b2Sqrt(friction1 * friction2);
49inline float b2MixRestitution(
float restitution1,
float restitution2)
51 return restitution1 > restitution2 ? restitution1 : restitution2;
55inline float b2MixRestitutionThreshold(
float threshold1,
float threshold2)
57 return threshold1 < threshold2 ? threshold1 : threshold2;
67 b2ContactCreateFcn* createFcn;
68 b2ContactDestroyFcn* destroyFcn;
113 const b2Contact*
GetNext()
const;
169 friend class b2ContactManager;
170 friend class b2World;
171 friend class b2ContactSolver;
173 friend class b2Fixture;
179 e_islandFlag = 0x0001,
182 e_touchingFlag = 0x0002,
185 e_enabledFlag = 0x0004,
188 e_filterFlag = 0x0008,
191 e_bulletHitFlag = 0x0010,
198 void FlagForFiltering();
200 static void AddType(b2ContactCreateFcn* createFcn, b2ContactDestroyFcn* destroyFcn,
201 b2Shape::Type typeA, b2Shape::Type typeB);
202 static void InitializeRegisters();
207 b2Contact() : m_fixtureA(nullptr), m_fixtureB(nullptr) {}
208 b2Contact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB);
209 virtual ~b2Contact() {}
211 void Update(b2ContactListener* listener);
213 static b2ContactRegister s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount];
214 static bool s_initialized;
223 b2ContactEdge m_nodeA;
224 b2ContactEdge m_nodeB;
226 b2Fixture* m_fixtureA;
227 b2Fixture* m_fixtureB;
232 b2Manifold m_manifold;
239 float m_restitutionThreshold;
241 float m_tangentSpeed;
256 const b2Body* bodyA = m_fixtureA->GetBody();
257 const b2Body* bodyB = m_fixtureB->GetBody();
258 const b2Shape* shapeA = m_fixtureA->GetShape();
259 const b2Shape* shapeB = m_fixtureB->GetShape();
268 m_flags |= e_enabledFlag;
272 m_flags &= ~e_enabledFlag;
278 return (m_flags & e_enabledFlag) == e_enabledFlag;
283 return (m_flags & e_touchingFlag) == e_touchingFlag;
328 m_flags |= e_filterFlag;
333 m_friction = friction;
343 m_friction = b2MixFriction(m_fixtureA->m_friction, m_fixtureB->m_friction);
348 m_restitution = restitution;
353 return m_restitution;
358 m_restitution = b2MixRestitution(m_fixtureA->m_restitution, m_fixtureB->m_restitution);
363 m_restitutionThreshold = threshold;
368 return m_restitutionThreshold;
373 m_restitutionThreshold = b2MixRestitutionThreshold(m_fixtureA->m_restitutionThreshold, m_fixtureB->m_restitutionThreshold);
378 m_tangentSpeed = speed;
383 return m_tangentSpeed;
Definition b2_block_allocator.h:38
A rigid body. These are created via b2World::CreateBody.
Definition b2_body.h:129
const b2Transform & GetTransform() const
Definition b2_body.h:479
Definition b2_fixture.h:117
float m_radius
Definition b2_shape.h:102
Definition b2_stack_allocator.h:43
Definition b2_collision.h:100
This is used to compute the current state of a contact manifold.
Definition b2_collision.h:117
void Initialize(const b2Manifold *manifold, const b2Transform &xfA, float radiusA, const b2Transform &xfB, float radiusB)