java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.BodyManager
- All Implemented Interfaces:
ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
A container for bodies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateBodies
(int... idArray) Activate the specified bodies.boolean
Add a body, assigning the next available ID.allocateBody
(ConstBodyCreationSettings settings) Create a body using the specified settings, but do not add it.void
deactivateBodies
(int... idArray) Deactivate the specified bodies.void
destroyBodies
(int... idArray) Remove the specified bodies from the manager.void
draw
(BodyManagerDrawSettings drawSettings, PhysicsSettings physicsSettings, DebugRenderer renderer) Draw the state of the bodies.Return all bodies.getBody
(int bodyId) Access a body using its ID.Access the (application-provided) interface for mapping object layers to broadphase layers.int
Return the maximum number of bodies the manager can support.void
init
(int maxBodies, int numBodyMutexes, ConstBroadPhaseLayerInterface map) Initialize the manager.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
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
Add a body, assigning the next available ID.- Parameters:
body
- (not null, modified)- Returns:
true
if successful,false
if no ID is available
-
allocateBody
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
Return all bodies.- Returns:
- a new vector (may contain invalid body pointers)
-
getBody
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
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
Initialize the manager.- Parameters:
maxBodies
- the desired maximum number of rigid bodies that can be addednumBodyMutexes
- the desired number of mutexes to allocate, or 0 for the default numbermap
- the desired map from object layers to broad-phase layers (not null, alias created)
-