Package com.jme3.bullet
Class DefaultContactManager
java.lang.Object
com.jme3.bullet.DefaultContactManager
- All Implemented Interfaces:
ContactListener
,ContactManager
The default implementation of the ContactManager interface.
-
Constructor Summary
ConstructorDescriptionInstantiate a manager for the specified PhysicsSpace. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCollisionListener
(PhysicsCollisionListener listener) Register the specified listener for new contacts.void
addContactListener
(ContactListener listener, boolean doEnded, boolean doProcessed, boolean doStarted) Register the specified listener for immediate contact notifications.void
Register the specified listener for ongoing contacts.int
Count how many collision listeners are registered.void
Distribute queued collision events to registered listeners.void
onContactEnded
(long manifoldId) Invoked immediately after a contact manifold is destroyed.void
onContactProcessed
(PhysicsCollisionObject pcoA, PhysicsCollisionObject pcoB, long pointId) Invoked immediately after a contact point is refreshed without being destroyed.void
onContactStarted
(long manifoldId) Invoked immediately after a contact manifold is created.void
De-register the specified listener for new contacts.void
removeContactListener
(ContactListener listener) De-register the specified listener for immediate contact notifications.void
De-register the specified listener for ongoing contacts.void
update
(float timeInterval, int maxSteps) Update the associated PhysicsSpace.
-
Constructor Details
-
DefaultContactManager
Instantiate a manager for the specified PhysicsSpace.- Parameters:
space
- the PhysicsSpace whose notifications will be managed (not null, alias created)
-
-
Method Details
-
addCollisionListener
Register the specified listener for new contacts.During distributeEvents(), registered listeners are notified of all new contacts since the previous distributeEvents().
- Specified by:
addCollisionListener
in interfaceContactManager
- Parameters:
listener
- the listener to register (not null, alias created)
-
addContactListener
public void addContactListener(ContactListener listener, boolean doEnded, boolean doProcessed, boolean doStarted) Register the specified listener for immediate contact notifications.- Specified by:
addContactListener
in interfaceContactManager
- Parameters:
listener
- the listener to register (not null, alias created)doEnded
- true to enableonContactEnded()
callbacks for the listener, false to skip themdoProcessed
- true to enableonContactProcessed()
callbacks for the listener, false to skip themdoStarted
- true to enableonContactStarted()
callbacks for the listener, false to skip them
-
addOngoingCollisionListener
Register the specified listener for ongoing contacts.During distributeEvents(), registered listeners are notified of all ongoing contacts EXCEPT Sphere-Sphere contacts.
- Specified by:
addOngoingCollisionListener
in interfaceContactManager
- Parameters:
listener
- the listener to register (not null, alias created)
-
countCollisionListeners
public int countCollisionListeners()Count how many collision listeners are registered.- Specified by:
countCollisionListeners
in interfaceContactManager
- Returns:
- the count (≥0)
-
distributeEvents
public void distributeEvents()Distribute queued collision events to registered listeners.- Specified by:
distributeEvents
in interfaceContactManager
-
removeCollisionListener
De-register the specified listener for new contacts.- Specified by:
removeCollisionListener
in interfaceContactManager
- Parameters:
listener
- the listener to de-register (not null)
-
removeContactListener
De-register the specified listener for immediate contact notifications.- Specified by:
removeContactListener
in interfaceContactManager
- Parameters:
listener
- the listener to de-register (not null)
-
removeOngoingCollisionListener
De-register the specified listener for ongoing contacts.- Specified by:
removeOngoingCollisionListener
in interfaceContactManager
- Parameters:
listener
- the listener to de-register (not null)
-
update
public void update(float timeInterval, int maxSteps) Update the associated PhysicsSpace. This method should be invoked from the thread that created the space.- Specified by:
update
in interfaceContactManager
- Parameters:
timeInterval
- the time interval to simulate (in seconds, ≥0)maxSteps
- the maximum number of steps of sizeaccuracy
(≥1) or 0 for a single step of sizetimeInterval
-
onContactEnded
public void onContactEnded(long manifoldId) Invoked immediately after a contact manifold is destroyed. Skipped if stepSimulation() was invoked with doEnded=false.- Specified by:
onContactEnded
in interfaceContactListener
- Parameters:
manifoldId
- the native ID of thebtPersistentManifold
(not zero)
-
onContactProcessed
public void onContactProcessed(PhysicsCollisionObject pcoA, PhysicsCollisionObject pcoB, long pointId) Invoked immediately after a contact point is refreshed without being destroyed. Skipped for Sphere-Sphere contacts. Skipped if stepSimulation() was invoked with doProcessed=false.- Specified by:
onContactProcessed
in interfaceContactListener
- Parameters:
pcoA
- the first involved object (not null)pcoB
- the 2nd involved object (not null)pointId
- the native ID of thebtManifoldPoint
(not zero)
-
onContactStarted
public void onContactStarted(long manifoldId) Invoked immediately after a contact manifold is created. Skipped if stepSimulation() was invoked with doStarted=false.- Specified by:
onContactStarted
in interfaceContactListener
- Parameters:
manifoldId
- the native ID of thebtPersistentManifold
(not zero)
-