Class ContactListenerAdapter<T extends PhysicsBody>
- Object
-
- ContactListenerAdapter<T>
-
- Type Parameters:
T
- thePhysicsBody
type
- All Implemented Interfaces:
ContactListener<T>
,WorldEventListener
public class ContactListenerAdapter<T extends PhysicsBody> extends Object implements ContactListener<T>
Convenience class for implementing theContactListener
interface.- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Constructor Summary
Constructors Constructor Description ContactListenerAdapter()
-
Method Summary
All Methods Instance Methods Concrete 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
public void begin(ContactCollisionData<T> collision, Contact contact)
Description copied from interface:ContactListener
Called when twoBodyFixture
s begin to overlap, generating a contact point.- Specified by:
begin
in interfaceContactListener<T extends PhysicsBody>
- Parameters:
collision
- the collision datacontact
- the contact
-
end
public void end(ContactCollisionData<T> collision, Contact contact)
Description copied from interface:ContactListener
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.
- Specified by:
end
in interfaceContactListener<T extends PhysicsBody>
- Parameters:
collision
- the collision datacontact
- the contact
-
destroyed
public void destroyed(ContactCollisionData<T> collision, Contact contact)
Description copied from interface:ContactListener
Called when a body or fixture is removed from the world that had existing contacts.This is different than the
ContactListener.end(ContactCollisionData, Contact)
event. This will only be called when a user removes a fixture or body that's currently in collision. TheContactListener.end(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.- Specified by:
destroyed
in interfaceContactListener<T extends PhysicsBody>
- Parameters:
collision
- the collision datacontact
- the contact
-
persist
public void persist(ContactCollisionData<T> collision, Contact oldContact, Contact newContact)
Description copied from interface:ContactListener
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()
.- Specified by:
persist
in interfaceContactListener<T extends PhysicsBody>
- Parameters:
collision
- the collision dataoldContact
- the old contactnewContact
- the new contact
-
preSolve
public void preSolve(ContactCollisionData<T> collision, Contact contact)
Description copied from interface:ContactListener
Called before contact constraints are solved.- Specified by:
preSolve
in interfaceContactListener<T extends PhysicsBody>
- Parameters:
collision
- the collision datacontact
- the contact
-
postSolve
public void postSolve(ContactCollisionData<T> collision, SolvedContact contact)
Description copied from interface:ContactListener
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.- Specified by:
postSolve
in interfaceContactListener<T extends PhysicsBody>
- Parameters:
collision
- the collision datacontact
- the contact
-
-