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
ConstructorsConstructorDescriptionInstantiate a manager for the specified PhysicsSpace. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCollisionListener(PhysicsCollisionListener listener) Register the specified listener for new contacts.voidaddContactListener(ContactListener listener, int stepFlags) Register the specified listener for immediate contact notifications.voidRegister the specified listener for ongoing contacts.intCount how many collision listeners are registered.voidDistribute queued collision events to registered listeners.booleanonContactConceived(long pointId, long manifoldId, PhysicsCollisionObject pcoA, PhysicsCollisionObject pcoB) Invoked immediately before a contact point is added to a manifold.voidonContactEnded(long manifoldId) Invoked immediately after a contact manifold is destroyed.voidonContactProcessed(PhysicsCollisionObject pcoA, PhysicsCollisionObject pcoB, long pointId) Invoked immediately after a contact point is refreshed without being destroyed.voidonContactStarted(long manifoldId) Invoked immediately after a contact manifold is created.voidDe-register the specified listener for new contacts.voidremoveContactListener(ContactListener listener) De-register the specified listener for immediate contact notifications.voidDe-register the specified listener for ongoing contacts.voidupdate(float timeInterval, int maxSteps, int addFlags) Update the associated PhysicsSpace, enabling the specified additional callbacks.
-
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:
addCollisionListenerin interfaceContactManager- Parameters:
listener- the listener to register (not null, alias created)
-
addContactListener
Register the specified listener for immediate contact notifications.- Specified by:
addContactListenerin interfaceContactManager- Parameters:
listener- the listener to register (not null, alias created)stepFlags- the step flags for this listener, ORed together- See Also:
-
addOngoingCollisionListener
Register the specified listener for ongoing contacts.During distributeEvents(), registered listeners are notified of all ongoing contacts EXCEPT Sphere-Sphere contacts.
- Specified by:
addOngoingCollisionListenerin interfaceContactManager- Parameters:
listener- the listener to register (not null, alias created)
-
countCollisionListeners
public int countCollisionListeners()Count how many collision listeners are registered.- Specified by:
countCollisionListenersin interfaceContactManager- Returns:
- the count (≥0)
-
distributeEvents
public void distributeEvents()Distribute queued collision events to registered listeners.- Specified by:
distributeEventsin interfaceContactManager
-
removeCollisionListener
De-register the specified listener for new contacts.- Specified by:
removeCollisionListenerin interfaceContactManager- Parameters:
listener- the listener to de-register (not null)- See Also:
-
removeContactListener
De-register the specified listener for immediate contact notifications.- Specified by:
removeContactListenerin interfaceContactManager- Parameters:
listener- the listener to de-register (not null)- See Also:
-
removeOngoingCollisionListener
De-register the specified listener for ongoing contacts.- Specified by:
removeOngoingCollisionListenerin interfaceContactManager- Parameters:
listener- the listener to de-register (not null)- See Also:
-
update
public void update(float timeInterval, int maxSteps, int addFlags) Update the associated PhysicsSpace, enabling the specified additional callbacks. This method should be invoked from the thread that created the space.- Specified by:
updatein interfaceContactManager- Parameters:
timeInterval- the time interval to simulate (in seconds, ≥0)maxSteps- the maximum number of simulation steps of sizeaccuracy(≥1) or 0 for a single simulation step of sizetimeIntervaladdFlags- the desired callbacks, ORed together (default=0x0)- See Also:
-
onContactConceived
public boolean onContactConceived(long pointId, long manifoldId, PhysicsCollisionObject pcoA, PhysicsCollisionObject pcoB) Invoked immediately before a contact point is added to a manifold.- Specified by:
onContactConceivedin interfaceContactListener- Parameters:
pointId- the native ID of thebtManifoldPoint(not zero)manifoldId- the native ID of thebtPersistentManifold(not zero)pcoA- the "A" collision object (not null)pcoB- the "B" collision object (not null)- Returns:
- true to accept the contact, or false to reject it
-
onContactEnded
public void onContactEnded(long manifoldId) Invoked immediately after a contact manifold is destroyed.- Specified by:
onContactEndedin 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.- Specified by:
onContactProcessedin 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.- Specified by:
onContactStartedin interfaceContactListener- Parameters:
manifoldId- the native ID of thebtPersistentManifold(not zero)
-