-
- Type Parameters:
T
- thePhysicsBody
type
- All Superinterfaces:
WorldEventListener
- All Known Implementing Classes:
ContactListenerAdapter
public interface ContactListener<T extends PhysicsBody> extends WorldEventListener
Represents an object that is notified of contact events.Implement this interface and register it with a
PhysicsWorld
to be notified when contact events occur. Contact events occur after allCollisionListener
events have been raised.- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
begin(ContactCollisionData<T> collision, Contact contact)
Called when twoBodyFixture
s begin to overlap, generating a contact point.void
destroyed(ContactCollisionData<T> collision, Contact contact)
Called when a body or fixture is removed from the world that had existing contacts.void
end(ContactCollisionData<T> collision, Contact contact)
Called when twoBodyFixture
s begin to separate and the contact point is no longer valid.void
persist(ContactCollisionData<T> collision, Contact oldContact, Contact newContact)
Called when twoBodyFixture
s remain in contact.void
postSolve(ContactCollisionData<T> collision, SolvedContact contact)
Called after contacts have been solved.void
preSolve(ContactCollisionData<T> collision, Contact contact)
Called before contact constraints are solved.
-
-
-
Method Detail
-
begin
void begin(ContactCollisionData<T> collision, Contact contact)
Called when twoBodyFixture
s begin to overlap, generating a contact point.- Parameters:
collision
- the collision datacontact
- the contact
-
end
void end(ContactCollisionData<T> collision, Contact contact)
Called when twoBodyFixture
s begin to separate and the contact point is no longer valid.This can happen in one of two ways. First, the fixtures in question have separated such that there's no longer any collision between them. Second, the fixtures could still be in collision, but the features that are in collision on those fixtures have changed.
- Parameters:
collision
- the collision datacontact
- the contact
-
destroyed
void destroyed(ContactCollisionData<T> collision, Contact contact)
Called when a body or fixture is removed from the world that had existing contacts.This is different than the
end(ContactCollisionData, Contact)
event. This will only be called when a user removes a fixture or body that's currently in collision. Theend(ContactCollisionData, Contact)
applies when the fixtures separate and are no longer in collision.This is called before the
DestructionListener.destroyed(org.dyn4j.dynamics.contact.ContactConstraint)
method in the event processing needed to occur by both listeners. There's no requirement that it must be processed in both (or at all) though.- Parameters:
collision
- the collision datacontact
- the contact
-
persist
void persist(ContactCollisionData<T> collision, Contact oldContact, Contact newContact)
Called when twoBodyFixture
s remain in contact.For a
Contact
to persist, theSettings.isWarmStartingEnabled()
must be true and theManifoldPointId
s must match.For shapes with vertices only, the manifold ids will be identical when the features of the colliding fixtures are the same. For rounded shapes, the manifold points must be within a specified tolerance defined in
Settings.getMaximumWarmStartDistance()
.- Parameters:
collision
- the collision dataoldContact
- the old contactnewContact
- the new contact
-
preSolve
void preSolve(ContactCollisionData<T> collision, Contact contact)
Called before contact constraints are solved.- Parameters:
collision
- the collision datacontact
- the contact
-
postSolve
void postSolve(ContactCollisionData<T> collision, SolvedContact contact)
Called after contacts have been solved.NOTE: This method will be called for
SolvedContact
s even when theSolvedContact.isSolved()
is false. This should only occur in situations with multiple contact points that produce a linearly dependent system. These contacts are thus ignored during solving, but still reported here.- Parameters:
collision
- the collision datacontact
- the contact
-
-