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;
101 bool IsTouching()
const;
106 void SetEnabled(
bool flag);
109 bool IsEnabled()
const;
120 int32 GetChildIndexA()
const;
127 int32 GetChildIndexB()
const;
131 void SetFriction(
float friction);
134 float GetFriction()
const;
137 void ResetFriction();
141 void SetRestitution(
float restitution);
144 float GetRestitution()
const;
147 void ResetRestitution();
151 void SetRestitutionThreshold(
float threshold);
154 float GetRestitutionThreshold()
const;
157 void ResetRestitutionThreshold();
160 void SetTangentSpeed(
float speed);
163 float GetTangentSpeed()
const;
171 friend class b2ContactSolver;
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) {}
213 static b2ContactRegister s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount];
214 static bool s_initialized;
239 float m_restitutionThreshold;
241 float m_tangentSpeed;
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:476
Definition b2_fixture.h:117
b2Body * GetBody()
Definition b2_fixture.h:289
b2Shape * GetShape()
Definition b2_fixture.h:259
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)