Package com.github.stephengold.joltjni
Class BodyManager
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.BodyManager
- All Implemented Interfaces:
ConstJoltPhysicsObject,AutoCloseable,Comparable<ConstJoltPhysicsObject>
A container for bodies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivateBodies(ConstBodyId... idArray) Activate the specified bodies.voidactivateBodies(ConstBodyId[] idArray, int number) Activate the specified bodies.booleanAdd a body, assigning the next available ID.allocateBody(ConstBodyCreationSettings settings) Create a body using the specified settings, but do not add it.voiddeactivateBodies(ConstBodyId... idArray) Deactivate the specified bodies.voiddeactivateBodies(ConstBodyId[] idArray, int number) Deactivate the specified bodies.voiddestroyBodies(ConstBodyId... idArray) Remove the specified bodies from the manager.voiddestroyBodies(ConstBodyId[] idArray, int number) Remove the specified bodies from the manager.voiddraw(BodyManagerDrawSettings drawSettings, PhysicsSettings physicsSettings, DebugRenderer renderer) Draw the state of the bodies.Return all bodies.Access the (application-provided) interface for mapping object layers to broadphase layers.intReturn the maximum number of bodies the manager can support.voidinit(int maxBodies, int numBodyMutexes, ConstBroadPhaseLayerInterface map) Initialize the manager.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, startCleaner, toString, va
-
Constructor Details
-
BodyManager
public BodyManager()Instantiate a default manager.
-
-
Method Details
-
activateBodies
Activate the specified bodies.- Parameters:
idArray- the IDs of the bodies to activate (not null, unaffected)
-
activateBodies
Activate the specified bodies.- Parameters:
idArray- the IDs of the bodies to activate (not null, unaffected)number- the number of IDs in the array (≥0)
-
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
Deactivate the specified bodies.- Parameters:
idArray- the IDs of the bodies to deactivate (not null, unaffected)
-
deactivateBodies
Deactivate the specified bodies.- Parameters:
idArray- the IDs of the bodies to deactivate (not null, unaffected)number- the number of IDs in the array (≥0)
-
destroyBodies
Remove the specified bodies from the manager.- Parameters:
idArray- the IDs of the bodies to destroy (not null, unaffected)
-
destroyBodies
Remove the specified bodies from the manager.- Parameters:
idArray- the IDs of the bodies to destroy (not null, unaffected)number- the number of IDs in the array (≥0)
-
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)
-
getBroadPhaseLayerInterface
Access the (application-provided) interface for mapping object layers to broadphase layers.- Returns:
- the pre-existing instance, or
nullif 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)
-