Box2D  3.0.0
A Real-Time-Oriented 2-D Physics Engine
Public Types | Public Member Functions | Friends | List of all members
box2d::Contact Class Reference

A potential contact between the chidren of two Fixture objects. More...

#include <Contact.hpp>

Public Types

using substep_type = ts_iters_t
 
using ManifoldCalcFunc = Manifold(*)(const Fixture *fixtureA, child_count_t indexA, const Fixture *fixtureB, child_count_t indexB, const Manifold::Conf conf)
 

Public Member Functions

 Contact ()=delete
 
 Contact (const Contact &copy)=delete
 
ManifoldGetManifold () noexcept
 Gets the contact manifold. More...
 
const ManifoldGetManifold () const noexcept
 
bool IsTouching () const noexcept
 Is this contact touching? More...
 
void SetEnabled (bool flag) noexcept
 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). More...
 
void SetEnabled () noexcept
 Enables this contact. More...
 
void UnsetEnabled () noexcept
 Disables this contact. More...
 
bool IsEnabled () const noexcept
 Has this contact been disabled? More...
 
FixtureGetFixtureA () noexcept
 Gets fixture A in this contact. More...
 
const FixtureGetFixtureA () const noexcept
 Gets fixture A in this contact. More...
 
child_count_t GetChildIndexA () const noexcept
 Get the child primitive index for fixture A. More...
 
FixtureGetFixtureB () noexcept
 Gets fixture B in this contact. More...
 
const FixtureGetFixtureB () const noexcept
 Gets fixture B in this contact. More...
 
child_count_t GetChildIndexB () const noexcept
 Get the child primitive index for fixture B. More...
 
void SetFriction (RealNum friction) noexcept
 Override the default friction mixture. You can call this in ContactListener::PreSolve. This value persists until set or reset. More...
 
RealNum GetFriction () const noexcept
 Gets the combined friction of the two fixtures associated with this contact. More...
 
void SetRestitution (RealNum restitution) noexcept
 Override the default restitution mixture. You can call this in ContactListener::PreSolve. The value persists until you set or reset. More...
 
RealNum GetRestitution () const noexcept
 Get the restitution. More...
 
void SetTangentSpeed (LinearVelocity speed) noexcept
 Set the desired tangent speed for a conveyor belt behavior. In meters per second. More...
 
LinearVelocity GetTangentSpeed () const noexcept
 Gets the desired tangent speed. In meters per second. More...
 
Manifold CalcManifold (const Manifold::Conf conf) const
 Calculates this contact's collision manifold. More...
 
substep_type GetToiCount () const noexcept
 
bool HasValidToi () const noexcept
 Gets whether a TOI is set. More...
 
RealNum GetToi () const
 Gets the time of impact (TOI) as a fraction. More...
 
void FlagForFiltering () noexcept
 
bool NeedsFiltering () const noexcept
 

Friends

class ContactAtty
 

Detailed Description

A potential contact between the chidren of two Fixture objects.

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.

Note
This data structure is 112-bytes large (on at least one 64-bit platform).

Member Typedef Documentation

◆ ManifoldCalcFunc

using box2d::Contact::ManifoldCalcFunc = Manifold (*)(const Fixture* fixtureA, child_count_t indexA, const Fixture* fixtureB, child_count_t indexB, const Manifold::Conf conf)

◆ substep_type

Constructor & Destructor Documentation

◆ Contact() [1/2]

box2d::Contact::Contact ( )
delete

◆ Contact() [2/2]

box2d::Contact::Contact ( const Contact copy)
delete

Member Function Documentation

◆ CalcManifold()

Manifold box2d::Contact::CalcManifold ( const Manifold::Conf  conf) const
inline

Calculates this contact's collision manifold.

Returns
Contact manifold with one or more points if the shapes are considered touching (collided).

◆ FlagForFiltering()

void box2d::Contact::FlagForFiltering ( )
inlinenoexcept

◆ GetChildIndexA()

child_count_t box2d::Contact::GetChildIndexA ( ) const
inlinenoexcept

Get the child primitive index for fixture A.

◆ GetChildIndexB()

child_count_t box2d::Contact::GetChildIndexB ( ) const
inlinenoexcept

Get the child primitive index for fixture B.

◆ GetFixtureA() [1/2]

Fixture * box2d::Contact::GetFixtureA ( )
inlinenoexcept

Gets fixture A in this contact.

◆ GetFixtureA() [2/2]

const Fixture * box2d::Contact::GetFixtureA ( ) const
inlinenoexcept

Gets fixture A in this contact.

◆ GetFixtureB() [1/2]

Fixture * box2d::Contact::GetFixtureB ( )
inlinenoexcept

Gets fixture B in this contact.

◆ GetFixtureB() [2/2]

const Fixture * box2d::Contact::GetFixtureB ( ) const
inlinenoexcept

Gets fixture B in this contact.

◆ GetFriction()

RealNum box2d::Contact::GetFriction ( ) const
inlinenoexcept

Gets the combined friction of the two fixtures associated with this contact.

See also
MixFriction.

◆ GetManifold() [1/2]

Manifold & box2d::Contact::GetManifold ( )
inlinenoexcept

Gets the contact manifold.

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

◆ GetManifold() [2/2]

const Manifold & box2d::Contact::GetManifold ( ) const
inlinenoexcept

◆ GetRestitution()

RealNum box2d::Contact::GetRestitution ( ) const
inlinenoexcept

Get the restitution.

◆ GetTangentSpeed()

LinearVelocity box2d::Contact::GetTangentSpeed ( ) const
inlinenoexcept

Gets the desired tangent speed. In meters per second.

◆ GetToi()

RealNum box2d::Contact::GetToi ( ) const
inline

Gets the time of impact (TOI) as a fraction.

Note
This is only valid if a TOI has been set.
See also
void SetToi(RealNum toi).
Returns
Time of impact fraction in the range of 0 to 1 if set (where 1 means no actual impact in current time slot), otheriwse undefined.

◆ GetToiCount()

Contact::substep_type box2d::Contact::GetToiCount ( ) const
inlinenoexcept

◆ HasValidToi()

bool box2d::Contact::HasValidToi ( ) const
inlinenoexcept

Gets whether a TOI is set.

Returns
true if this object has a TOI set for it, false otherwise.

◆ IsEnabled()

bool box2d::Contact::IsEnabled ( ) const
inlinenoexcept

Has this contact been disabled?

◆ IsTouching()

bool box2d::Contact::IsTouching ( ) const
inlinenoexcept

Is this contact touching?

Touching is defined as either:

  1. This contact's manifold has more than 0 contact points, or
  2. This contact has sensors and the two shapes of this contact are found to be overlapping.
    Returns
    true if this contact is said to be touching, false otherwise.

◆ NeedsFiltering()

bool box2d::Contact::NeedsFiltering ( ) const
inlinenoexcept

◆ SetEnabled() [1/2]

void box2d::Contact::SetEnabled ( bool  flag)
inlinenoexcept

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).

◆ SetEnabled() [2/2]

void box2d::Contact::SetEnabled ( )
inlinenoexcept

Enables this contact.

◆ SetFriction()

void box2d::Contact::SetFriction ( RealNum  friction)
inlinenoexcept

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

◆ SetRestitution()

void box2d::Contact::SetRestitution ( RealNum  restitution)
inlinenoexcept

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

◆ SetTangentSpeed()

void box2d::Contact::SetTangentSpeed ( LinearVelocity  speed)
inlinenoexcept

Set the desired tangent speed for a conveyor belt behavior. In meters per second.

◆ UnsetEnabled()

void box2d::Contact::UnsetEnabled ( )
inlinenoexcept

Disables this contact.

Friends And Related Function Documentation

◆ ContactAtty

friend class ContactAtty
friend

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