A pure-virtual interface for "listeners" for contacts. More...
#include <WorldCallbacks.hpp>
Public Types | |
using | iteration_type = unsigned |
Iteration type. More... | |
Public Member Functions | |
virtual | ~ContactListener ()=default |
virtual void | BeginContact (Contact &contact)=0 |
Called when two fixtures begin to touch. More... | |
virtual void | EndContact (Contact &contact)=0 |
End contact callback. More... | |
virtual void | PreSolve (Contact &contact, const Manifold &oldManifold)=0 |
Pre-solve callback. More... | |
virtual void | PostSolve (Contact &contact, const ContactImpulsesList &impulses, iteration_type solved)=0 |
Post-solve callback. More... | |
Detailed Description
A pure-virtual interface for "listeners" for contacts.
Implement this class to get contact information. You can use these results for things like sounds and game logic. You can also get contact results by traversing the contact lists after the time step. However, you might miss some contacts because continuous physics leads to sub-stepping. Additionally you may receive multiple callbacks for the same contact in a single time step. You should strive to make your callbacks efficient because there may be many callbacks per time step.
- Warning
- You cannot create/destroy PlayRho entities inside these callbacks.
- Examples
- World.cpp.
Definition at line 69 of file WorldCallbacks.hpp.
Member Typedef Documentation
◆ iteration_type
using playrho::d2::ContactListener::iteration_type = unsigned |
Iteration type.
Definition at line 74 of file WorldCallbacks.hpp.
Constructor & Destructor Documentation
◆ ~ContactListener()
|
virtualdefault |
Member Function Documentation
◆ BeginContact()
|
pure virtual |
Called when two fixtures begin to touch.
- Examples
- World.cpp.
◆ EndContact()
|
pure virtual |
End contact callback.
Called when the contact's "touching" property becomes false, or just before the contact is destroyed.
- Note
- This contact persists until the broad phase determines there's no overlap anymore between the two fixtures.
-
If the contact's "touching" property becomes true again,
BeginContact
will be called again for this contact.
- Parameters
-
contact Contact that's about to be destroyed or whose "touching" property has become false.
- See also
- Contact::IsTouching().
◆ PreSolve()
|
pure virtual |
Pre-solve callback.
This is called after a contact is updated. This allows you to inspect a contact before it goes to the solver. If you are careful, you can modify the contact manifold (e.g. disable contact). A copy of the old manifold is provided so that you can detect changes.
- Note
- This is called only for awake bodies.
- This is called even when the number of contact points is zero.
- This is not called for sensors.
-
If you set the number of contact points to zero, you will not get an
EndContact
callback. However, you may get aBeginContact
callback the next step.
◆ PostSolve()
|
pure virtual |
Post-solve callback.
This lets you inspect a contact after the solver is finished. This is useful for inspecting impulses.
- Note
- The contact manifold does not include time of impact impulses, which can be arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly in a separate data structure.
- This is only called for contacts that are touching, solid, and awake.
The documentation for this class was generated from the following file:
- Dynamics/WorldCallbacks.hpp