Class DefaultContactManager

java.lang.Object
com.jme3.bullet.DefaultContactManager
All Implemented Interfaces:
ContactListener, ContactManager

public class DefaultContactManager extends Object implements ContactManager
The default implementation of the ContactManager interface.
  • Constructor Details

    • DefaultContactManager

      public DefaultContactManager(PhysicsSpace space)
      Instantiate a manager for the specified PhysicsSpace.
      Parameters:
      space - the PhysicsSpace whose notifications will be managed (not null, alias created)
  • Method Details

    • addCollisionListener

      public void addCollisionListener(PhysicsCollisionListener listener)
      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 interface ContactManager
      Parameters:
      listener - the listener to register (not null, alias created)
    • addContactListener

      public void addContactListener(ContactListener listener, int stepFlags)
      Register the specified listener for immediate contact notifications.
      Specified by:
      addContactListener in interface ContactManager
      Parameters:
      listener - the listener to register (not null, alias created)
      stepFlags - the step flags for this listener, ORed together
      See Also:
    • addOngoingCollisionListener

      public void addOngoingCollisionListener(PhysicsCollisionListener listener)
      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 interface ContactManager
      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 interface ContactManager
      Returns:
      the count (≥0)
    • distributeEvents

      public void distributeEvents()
      Distribute queued collision events to registered listeners.
      Specified by:
      distributeEvents in interface ContactManager
    • removeCollisionListener

      public void removeCollisionListener(PhysicsCollisionListener listener)
      De-register the specified listener for new contacts.
      Specified by:
      removeCollisionListener in interface ContactManager
      Parameters:
      listener - the listener to de-register (not null)
      See Also:
    • removeContactListener

      public void removeContactListener(ContactListener listener)
      De-register the specified listener for immediate contact notifications.
      Specified by:
      removeContactListener in interface ContactManager
      Parameters:
      listener - the listener to de-register (not null)
      See Also:
    • removeOngoingCollisionListener

      public void removeOngoingCollisionListener(PhysicsCollisionListener listener)
      De-register the specified listener for ongoing contacts.
      Specified by:
      removeOngoingCollisionListener in interface ContactManager
      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:
      update in interface ContactManager
      Parameters:
      timeInterval - the time interval to simulate (in seconds, ≥0)
      maxSteps - the maximum number of simulation steps of size accuracy (≥1) or 0 for a single simulation step of size timeInterval
      addFlags - 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:
      onContactConceived in interface ContactListener
      Parameters:
      pointId - the native ID of the btManifoldPoint (not zero)
      manifoldId - the native ID of the btPersistentManifold (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:
      onContactEnded in interface ContactListener
      Parameters:
      manifoldId - the native ID of the btPersistentManifold (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:
      onContactProcessed in interface ContactListener
      Parameters:
      pcoA - the first involved object (not null)
      pcoB - the 2nd involved object (not null)
      pointId - the native ID of the btManifoldPoint (not zero)
    • onContactStarted

      public void onContactStarted(long manifoldId)
      Invoked immediately after a contact manifold is created.
      Specified by:
      onContactStarted in interface ContactListener
      Parameters:
      manifoldId - the native ID of the btPersistentManifold (not zero)