All Implemented Interfaces:
ConstJoltPhysicsObject, AutoCloseable, Comparable<JoltPhysicsObject>

public class BodyManager extends NonCopyable
A container for bodies.
  • Constructor Details

    • BodyManager

      public BodyManager()
      Instantiate a default manager.
  • Method Details

    • activateBodies

      public void activateBodies(int... idArray)
      Activate the specified bodies.
      Parameters:
      idArray - the IDs of the bodies to activate (not null, unaffected)
    • addBody

      public boolean addBody(Body body)
      Add a body, assigning the next available ID.
      Parameters:
      body - (not null, modified)
      Returns:
      true if successful, false if no ID is available
    • allocateBody

      public Body allocateBody(ConstBodyCreationSettings settings)
      Create a body using the specified settings, but do not add it.
      Parameters:
      settings - the settings to use (not null, unaffected)
      Returns:
      a new body, not added to any manager
    • deactivateBodies

      public void deactivateBodies(int... idArray)
      Deactivate the specified bodies.
      Parameters:
      idArray - the IDs of the bodies to deactivate (not null, unaffected)
    • destroyBodies

      public void destroyBodies(int... idArray)
      Remove the specified bodies from the manager.
      Parameters:
      idArray - the IDs of the bodies to destroy (not null, unaffected)
    • draw

      public void draw(BodyManagerDrawSettings drawSettings, PhysicsSettings physicsSettings, DebugRenderer renderer)
      Draw the state of the bodies.
      Parameters:
      drawSettings - the draw settings to use (not null, unaffected)
      physicsSettings - the physics settings to use (not null, unaffected)
      renderer - the renderer to use (not null)
    • getBodies

      public BodyVector getBodies()
      Return all bodies.
      Returns:
      a new vector (may contain invalid body pointers)
    • getBody

      public Body getBody(int bodyId)
      Access a body using its ID.
      Parameters:
      bodyId - the ID of the body to access
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getBroadPhaseLayerInterface

      public ConstBroadPhaseLayerInterface getBroadPhaseLayerInterface()
      Access the (application-provided) interface for mapping object layers to broadphase layers.
      Returns:
      the pre-existing instance, or null if none
    • getMaxBodies

      public int getMaxBodies()
      Return the maximum number of bodies the manager can support.
      Returns:
      the count (≥0)
    • init

      public void init(int maxBodies, int numBodyMutexes, ConstBroadPhaseLayerInterface map)
      Initialize the manager.
      Parameters:
      maxBodies - the desired maximum number of rigid bodies that can be added
      numBodyMutexes - the desired number of mutexes to allocate, or 0 for the default number
      map - the desired map from object layers to broad-phase layers (not null, alias created)