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

#include <Contact.hpp>

Classes

struct  UpdateConf
 Update configuration. More...
 

Public Types

using substep_type = TimestepIters
 Substep type. More...
 

Public Member Functions

 Contact (Fixture *fA, ChildCounter iA, Fixture *fB, ChildCounter iB)
 Initializing constructor. More...
 
 Contact ()=delete
 Default construction not allowed. More...
 
 Contact (const Contact &copy)=default
 Copy constructor. More...
 
const ManifoldGetManifold () const noexcept
 Gets the contact manifold. More...
 
bool IsTouching () const noexcept
 Is this contact touching? More...
 
void SetEnabled (bool flag) noexcept
 Enables or disables this contact. 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 () const noexcept
 Gets fixture A in this contact. More...
 
ChildCounter GetChildIndexA () const noexcept
 Get the child primitive index for fixture A. More...
 
FixtureGetFixtureB () const noexcept
 Gets fixture B in this contact. More...
 
ChildCounter GetChildIndexB () const noexcept
 Get the child primitive index for fixture B. More...
 
void SetFriction (Real friction) noexcept
 Sets the friction value for this contact. More...
 
Real GetFriction () const noexcept
 Gets the coefficient of friction. More...
 
void SetRestitution (Real restitution) noexcept
 Sets the restitution. More...
 
Real GetRestitution () const noexcept
 Gets the restitution. More...
 
void SetTangentSpeed (LinearVelocity speed) noexcept
 Sets the desired tangent speed for a conveyor belt behavior. More...
 
LinearVelocity GetTangentSpeed () const noexcept
 Gets the desired tangent speed. More...
 
substep_type GetToiCount () const noexcept
 Gets the time of impact count. More...
 
bool HasValidToi () const noexcept
 Gets whether a TOI is set. More...
 
Real GetToi () const
 Gets the time of impact (TOI) as a fraction. More...
 
void FlagForFiltering () noexcept
 Flags the contact for filtering. More...
 
bool NeedsFiltering () const noexcept
 Whether or not the contact needs filtering. More...
 
void FlagForUpdating () noexcept
 Flags the contact for updating. More...
 
bool NeedsUpdating () const noexcept
 Whether or not the contact needs updating. More...
 

Static Public Member Functions

static UpdateConf GetUpdateConf (const StepConf &conf) noexcept
 Gets the update configuration from the given step configuration data. More...
 

Friends

class ContactAtty
 

Related Functions

(Note that these are not member functions.)

AABB ComputeIntersectingAABB (const Contact &contact)
 Computes the intersecting AABB for the given contact. More...
 
WorldManifold GetWorldManifold (const Contact &contact)
 
BodyGetBodyA (const Contact &contact) noexcept
 Gets the body A associated with the given contact. More...
 
BodyGetBodyB (const Contact &contact) noexcept
 Gets the body B associated with the given contact. More...
 
FixtureGetFixtureA (const Contact &contact) noexcept
 Gets the fixture A associated with the given contact. More...
 
FixtureGetFixtureB (const Contact &contact) noexcept
 Gets the fixture B associated with the given contact. More...
 
ChildCounter GetChildIndexA (const Contact &contact) noexcept
 Gets the child index A of the given contact. More...
 
ChildCounter GetChildIndexB (const Contact &contact) noexcept
 Gets the child index B of the given contact. More...
 
bool HasSensor (const Contact &contact) noexcept
 Whether the given contact has a sensor. More...
 
bool IsImpenetrable (const Contact &contact) noexcept
 Whether the given contact is "impenetrable". More...
 
bool IsActive (const Contact &contact) noexcept
 Determines whether the given contact is "active". More...
 
void SetAwake (const Contact &c) noexcept
 Sets awake the fixtures of the given contact. More...
 
void ResetFriction (Contact &contact)
 
void ResetRestitution (Contact &contact) noexcept
 
TOIOutput CalcToi (const Contact &contact, ToiConf conf)
 Calculates the Time Of Impact for the given contact with the given configuration. More...
 

Detailed Description

A potential contact between the children 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 actual contact points.

Note
These are created by World instances. Users have no need to instantiate these themselves.
This data structure is 104-bytes large (on at least one 64-bit platform).
Examples
Contact.cpp, and World.cpp.

Definition at line 81 of file Contact.hpp.

Member Typedef Documentation

◆ substep_type

Substep type.

Definition at line 86 of file Contact.hpp.

Constructor & Destructor Documentation

◆ Contact() [1/3]

playrho::d2::Contact::Contact ( Fixture fA,
ChildCounter  iA,
Fixture fB,
ChildCounter  iB 
)

Initializing constructor.

Parameters
fANon-null pointer to fixture A that must have a shape and may not be the same or have the same body as the other fixture.
iAChild index A.
fBNon-null pointer to fixture B that must have a shape and may not be the same or have the same body as the other fixture.
iBChild index B.
Note
This need never be called directly by a user.
Warning
Behavior is undefined if fA is null.
Behavior is undefined if fB is null.
Behavior is undefined if fA == fB.
Behavior is undefined if both fixture's have the same body.

Definition at line 60 of file Contact.cpp.

◆ Contact() [2/3]

playrho::d2::Contact::Contact ( )
delete

Default construction not allowed.

◆ Contact() [3/3]

playrho::d2::Contact::Contact ( const Contact copy)
default

Copy constructor.

Member Function Documentation

◆ GetUpdateConf()

Contact::UpdateConf playrho::d2::Contact::GetUpdateConf ( const StepConf conf)
staticnoexcept

Gets the update configuration from the given step configuration data.

Definition at line 55 of file Contact.cpp.

◆ GetManifold()

const Manifold & playrho::d2::Contact::GetManifold ( ) const
inlinenoexcept

Gets the contact manifold.

Examples
World.cpp.

Definition at line 341 of file Contact.hpp.

◆ IsTouching()

bool playrho::d2::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.
Examples
World.cpp.

Definition at line 380 of file Contact.hpp.

◆ SetEnabled() [1/2]

void playrho::d2::Contact::SetEnabled ( bool  flag)
inlinenoexcept

Enables or disables this contact.

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

Definition at line 353 of file Contact.hpp.

◆ SetEnabled() [2/2]

void playrho::d2::Contact::SetEnabled ( )
inlinenoexcept

Enables this contact.

Definition at line 365 of file Contact.hpp.

◆ UnsetEnabled()

void playrho::d2::Contact::UnsetEnabled ( )
inlinenoexcept

Disables this contact.

Definition at line 370 of file Contact.hpp.

◆ IsEnabled()

bool playrho::d2::Contact::IsEnabled ( ) const
inlinenoexcept

Has this contact been disabled?

Definition at line 375 of file Contact.hpp.

◆ GetFixtureA()

Fixture * playrho::d2::Contact::GetFixtureA ( ) const
inlinenoexcept

Gets fixture A in this contact.

Examples
World.cpp.

Definition at line 397 of file Contact.hpp.

◆ GetChildIndexA()

ChildCounter playrho::d2::Contact::GetChildIndexA ( ) const
inlinenoexcept

Get the child primitive index for fixture A.

Definition at line 516 of file Contact.hpp.

◆ GetFixtureB()

Fixture * playrho::d2::Contact::GetFixtureB ( ) const
inlinenoexcept

Gets fixture B in this contact.

Examples
World.cpp.

Definition at line 402 of file Contact.hpp.

◆ GetChildIndexB()

ChildCounter playrho::d2::Contact::GetChildIndexB ( ) const
inlinenoexcept

Get the child primitive index for fixture B.

Definition at line 521 of file Contact.hpp.

◆ SetFriction()

void playrho::d2::Contact::SetFriction ( Real  friction)
inlinenoexcept

Sets the friction value for this contact.

Override the default friction mixture.

Note
You can call this in ContactListener::PreSolve.
This value persists until set or reset.
Warning
Behavior is undefined if given a negative friction value.
Parameters
frictionCo-efficient of friction value of zero or greater.

Definition at line 437 of file Contact.hpp.

◆ GetFriction()

Real playrho::d2::Contact::GetFriction ( ) const
inlinenoexcept

Gets the coefficient of friction.

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

Returns
Value of 0 or higher.
See also
MixFriction.

Definition at line 443 of file Contact.hpp.

◆ SetRestitution()

void playrho::d2::Contact::SetRestitution ( Real  restitution)
inlinenoexcept

Sets the restitution.

This override the default restitution mixture.

Note
You can call this in ContactListener::PreSolve.
The value persists until you set or reset.

Definition at line 448 of file Contact.hpp.

◆ GetRestitution()

Real playrho::d2::Contact::GetRestitution ( ) const
inlinenoexcept

Gets the restitution.

Definition at line 453 of file Contact.hpp.

◆ SetTangentSpeed()

void playrho::d2::Contact::SetTangentSpeed ( LinearVelocity  speed)
inlinenoexcept

Sets the desired tangent speed for a conveyor belt behavior.

Definition at line 458 of file Contact.hpp.

◆ GetTangentSpeed()

LinearVelocity playrho::d2::Contact::GetTangentSpeed ( ) const
inlinenoexcept

Gets the desired tangent speed.

Definition at line 463 of file Contact.hpp.

◆ GetToiCount()

Contact::substep_type playrho::d2::Contact::GetToiCount ( ) const
inlinenoexcept

Gets the time of impact count.

Examples
World.cpp.

Definition at line 496 of file Contact.hpp.

◆ HasValidToi()

bool playrho::d2::Contact::HasValidToi ( ) const
inlinenoexcept

Gets whether a TOI is set.

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

Definition at line 468 of file Contact.hpp.

◆ GetToi()

Real playrho::d2::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(Real 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), otherwise undefined.

Definition at line 473 of file Contact.hpp.

◆ FlagForFiltering()

void playrho::d2::Contact::FlagForFiltering ( )
inlinenoexcept

Flags the contact for filtering.

Definition at line 407 of file Contact.hpp.

◆ NeedsFiltering()

bool playrho::d2::Contact::NeedsFiltering ( ) const
inlinenoexcept

Whether or not the contact needs filtering.

Definition at line 417 of file Contact.hpp.

◆ FlagForUpdating()

void playrho::d2::Contact::FlagForUpdating ( )
inlinenoexcept

Flags the contact for updating.

Definition at line 422 of file Contact.hpp.

◆ NeedsUpdating()

bool playrho::d2::Contact::NeedsUpdating ( ) const
inlinenoexcept

Whether or not the contact needs updating.

Definition at line 432 of file Contact.hpp.

Friends And Related Function Documentation

◆ ContactAtty

friend class ContactAtty
friend

Definition at line 217 of file Contact.hpp.

◆ ComputeIntersectingAABB()

AABB ComputeIntersectingAABB ( const Contact contact)
related

Computes the intersecting AABB for the given contact.

Definition at line 100 of file AABB.cpp.

◆ GetWorldManifold()

WorldManifold GetWorldManifold ( const Contact contact)
related

Gets the world manifold for the given data.

Note
This is a convenience function that in turn calls the GetWorldManifold(const Manifold&, const Transformation&, const Real, const Transformation& xfB, const Real) function.
Parameters
contactContact to return a world manifold for.
Returns
World manifold value for the given inputs which will have the same number of points as the given manifold has. The returned world manifold points will be the mid-points of the contact's intersection.

Definition at line 126 of file WorldManifold.cpp.

◆ GetBodyA()

Body * GetBodyA ( const Contact contact)
related

Gets the body A associated with the given contact.

Definition at line 227 of file Contact.cpp.

◆ GetBodyB()

Body * GetBodyB ( const Contact contact)
related

Gets the body B associated with the given contact.

Definition at line 232 of file Contact.cpp.

◆ GetFixtureA()

Fixture * GetFixtureA ( const Contact contact)
related

Gets the fixture A associated with the given contact.

Definition at line 541 of file Contact.hpp.

◆ GetFixtureB()

Fixture * GetFixtureB ( const Contact contact)
related

Gets the fixture B associated with the given contact.

Definition at line 548 of file Contact.hpp.

◆ GetChildIndexA()

ChildCounter GetChildIndexA ( const Contact contact)
related

Gets the child index A of the given contact.

Definition at line 555 of file Contact.hpp.

◆ GetChildIndexB()

ChildCounter GetChildIndexB ( const Contact contact)
related

Gets the child index B of the given contact.

Definition at line 562 of file Contact.hpp.

◆ HasSensor()

bool HasSensor ( const Contact contact)
related

Whether the given contact has a sensor.

Definition at line 237 of file Contact.cpp.

◆ IsImpenetrable()

bool IsImpenetrable ( const Contact contact)
related

Whether the given contact is "impenetrable".

Definition at line 242 of file Contact.cpp.

◆ IsActive()

bool IsActive ( const Contact contact)
related

Determines whether the given contact is "active".

Definition at line 249 of file Contact.cpp.

◆ SetAwake()

void SetAwake ( const Contact c)
related

Sets awake the fixtures of the given contact.

Definition at line 264 of file Contact.cpp.

◆ ResetFriction()

void ResetFriction ( Contact contact)
related

Resets the friction mixture to the default value.

Definition at line 271 of file Contact.cpp.

◆ ResetRestitution()

void ResetRestitution ( Contact contact)
related

Reset the restitution to the default value.

Definition at line 277 of file Contact.cpp.

◆ CalcToi()

TOIOutput CalcToi ( const Contact contact,
ToiConf  conf 
)
related

Calculates the Time Of Impact for the given contact with the given configuration.

Definition at line 284 of file Contact.cpp.


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