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, boolean doEnded, boolean doProcessed, boolean doStarted)
      Register the specified listener for immediate contact notifications.
      Specified by:
      addContactListener in interface ContactManager
      Parameters:
      listener - the listener to register (not null, alias created)
      doEnded - true to enable onContactEnded() callbacks for the listener, false to skip them
      doProcessed - true to enable onContactProcessed() callbacks for the listener, false to skip them
      doStarted - true to enable onContactStarted() callbacks for the listener, false to skip them
    • 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)
    • 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)
    • 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)
    • 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 interface ContactManager
      Parameters:
      timeInterval - the time interval to simulate (in seconds, ≥0)
      maxSteps - the maximum number of steps of size accuracy (≥1) or 0 for a single step of size timeInterval
    • 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 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. Skipped if stepSimulation() was invoked with doProcessed=false.
      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. Skipped if stepSimulation() was invoked with doStarted=false.
      Specified by:
      onContactStarted in interface ContactListener
      Parameters:
      manifoldId - the native ID of the btPersistentManifold (not zero)