Box2D  2.4.1
A 2D physics engine for games
b2Contact Class Referenceabstract

#include <b2_contact.h>

Public Member Functions

b2ManifoldGetManifold ()
 
const b2ManifoldGetManifold () const
 
void GetWorldManifold (b2WorldManifold *worldManifold) const
 Get the world manifold.
 
bool IsTouching () const
 Is this contact touching?
 
void SetEnabled (bool flag)
 
bool IsEnabled () const
 Has this contact been disabled?
 
b2ContactGetNext ()
 Get the next contact in the world's contact list.
 
const b2ContactGetNext () const
 
b2FixtureGetFixtureA ()
 Get fixture A in this contact.
 
const b2FixtureGetFixtureA () const
 
int32 GetChildIndexA () const
 Get the child primitive index for fixture A.
 
b2FixtureGetFixtureB ()
 Get fixture B in this contact.
 
const b2FixtureGetFixtureB () const
 
int32 GetChildIndexB () const
 Get the child primitive index for fixture B.
 
void SetFriction (float friction)
 
float GetFriction () const
 Get the friction.
 
void ResetFriction ()
 Reset the friction mixture to the default value.
 
void SetRestitution (float restitution)
 
float GetRestitution () const
 Get the restitution.
 
void ResetRestitution ()
 Reset the restitution to the default value.
 
void SetRestitutionThreshold (float threshold)
 
float GetRestitutionThreshold () const
 Get the restitution threshold.
 
void ResetRestitutionThreshold ()
 Reset the restitution threshold to the default value.
 
void SetTangentSpeed (float speed)
 Set the desired tangent speed for a conveyor belt behavior. In meters per second.
 
float GetTangentSpeed () const
 Get the desired tangent speed. In meters per second.
 
virtual void Evaluate (b2Manifold *manifold, const b2Transform &xfA, const b2Transform &xfB)=0
 Evaluate this contact with your own manifold and transforms.
 

Protected Types

enum  {
  e_islandFlag = 0x0001, e_touchingFlag = 0x0002, e_enabledFlag = 0x0004, e_filterFlag = 0x0008,
  e_bulletHitFlag = 0x0010, e_toiFlag = 0x0020
}
 

Protected Member Functions

void FlagForFiltering ()
 Flag this contact for filtering. Filtering will occur the next time step.
 
 b2Contact (b2Fixture *fixtureA, int32 indexA, b2Fixture *fixtureB, int32 indexB)
 
void Update (b2ContactListener *listener)
 

Static Protected Member Functions

static void AddType (b2ContactCreateFcn *createFcn, b2ContactDestroyFcn *destroyFcn, b2Shape::Type typeA, b2Shape::Type typeB)
 
static void InitializeRegisters ()
 
static b2ContactCreate (b2Fixture *fixtureA, int32 indexA, b2Fixture *fixtureB, int32 indexB, b2BlockAllocator *allocator)
 
static void Destroy (b2Contact *contact, b2Shape::Type typeA, b2Shape::Type typeB, b2BlockAllocator *allocator)
 
static void Destroy (b2Contact *contact, b2BlockAllocator *allocator)
 

Protected Attributes

uint32 m_flags
 
b2Contactm_prev
 
b2Contactm_next
 
b2ContactEdge m_nodeA
 
b2ContactEdge m_nodeB
 
b2Fixturem_fixtureA
 
b2Fixturem_fixtureB
 
int32 m_indexA
 
int32 m_indexB
 
b2Manifold m_manifold
 
int32 m_toiCount
 
float m_toi
 
float m_friction
 
float m_restitution
 
float m_restitutionThreshold
 
float m_tangentSpeed
 

Static Protected Attributes

static b2ContactRegister s_registers [b2Shape::e_typeCount][b2Shape::e_typeCount]
 
static bool s_initialized
 

Friends

class b2ContactManager
 
class b2World
 
class b2ContactSolver
 
class b2Body
 
class b2Fixture
 

Detailed Description

The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.

Member Function Documentation

◆ GetManifold()

const b2Manifold * b2Contact::GetManifold ( )
inline

Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.

◆ SetEnabled()

void b2Contact::SetEnabled ( bool  flag)
inline

Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).

◆ SetFriction()

void b2Contact::SetFriction ( float  friction)
inline

Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.

◆ SetRestitution()

void b2Contact::SetRestitution ( float  restitution)
inline

Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.

◆ SetRestitutionThreshold()

void b2Contact::SetRestitutionThreshold ( float  threshold)
inline

Override the default restitution velocity threshold mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.


The documentation for this class was generated from the following file: