java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.RagdollSettings
- All Implemented Interfaces:
ConstJoltPhysicsObject
,RefTarget
,AutoCloseable
,Comparable<JoltPhysicsObject>
Settings and structure used to create a
Ragdoll
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionalConstraint
(AdditionalConstraint constraint) Add the specified constraint.void
Pre-calculate the map used bygetBodyIndexToConstraintIndex()
.void
Pre-calculate the map used bygetConstraintIndexToBodyIdxPair()
.createRagdoll
(int groupId, long userData, PhysicsSystem physicsSystem) Generate a ragdoll instance from the settings, which are unaffected.void
Create and add collision filters to all bodies in the ragdoll and configure them so parents and children don't collide.Part[]
getParts()
Access the parts by way of a Java array.int
Count the active references to the nativeRagdollSettings
.Access the skeleton.void
resizeParts
(int numParts) Resize the parts array.void
saveBinaryState
(StreamOut stream, boolean saveShapes, boolean saveGroupFilter) Save the settings to the specified binary stream.void
Mark the nativeRagdollSettings
as embedded.void
setSkeleton
(Skeleton skeleton) Replace the skeleton.static RagdollResult
sRestoreFromBinaryState
(StreamIn stream) Read a ragdoll from the specified input stream.boolean
Stabilize the constraints.toRef()
Create a counted reference to the nativeRagdollSettings
.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
Constructor Details
-
RagdollSettings
public RagdollSettings()Instantiate default settings.
-
-
Method Details
-
addAdditionalConstraint
Add the specified constraint.- Parameters:
constraint
- (not null)
-
calculateBodyIndexToConstraintIndex
public void calculateBodyIndexToConstraintIndex()Pre-calculate the map used bygetBodyIndexToConstraintIndex()
. -
calculateConstraintIndexToBodyIdxPair
public void calculateConstraintIndexToBodyIdxPair()Pre-calculate the map used bygetConstraintIndexToBodyIdxPair()
. -
createRagdoll
Generate a ragdoll instance from the settings, which are unaffected.- Parameters:
groupId
- the collision group for the bodiesuserData
- the desired user-data valuephysicsSystem
- where to add the bodies and constraints (not null, modified)- Returns:
- a new ragdoll instance, or
null
when out of bodies
-
disableParentChildCollisions
public void disableParentChildCollisions()Create and add collision filters to all bodies in the ragdoll and configure them so parents and children don't collide. -
getParts
Access the parts by way of a Java array. (native attribute: mParts)- Returns:
- a new array of new JVM objects with pre-existing native objects assigned
-
getSkeleton
Access the skeleton. (native attribute: mSkeleton)- Returns:
- a new JVM object with the pre-existing native object assigned
-
resizeParts
public void resizeParts(int numParts) Resize the parts array.- Parameters:
numParts
- the desired number of parts (≥0)
-
saveBinaryState
Save the settings to the specified binary stream. The settings are unaffected.- Parameters:
stream
- the stream to write to (not null)saveShapes
- if true, save the shapessaveGroupFilter
- if true, save the group filter
-
setSkeleton
Replace the skeleton. (native attribute: mSkeleton)- Parameters:
skeleton
- the desired skeleton (not null)
-
sRestoreFromBinaryState
Read a ragdoll from the specified input stream.- Parameters:
stream
- the stream to read from (not null)- Returns:
- the result of the read (not null)
-
stabilize
public boolean stabilize()Stabilize the constraints.- Returns:
true
if successful, otherwisefalse
-
getRefCount
public int getRefCount()Count the active references to the nativeRagdollSettings
. The settings are unaffected.- Specified by:
getRefCount
in interfaceRefTarget
- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativeRagdollSettings
as embedded.- Specified by:
setEmbedded
in interfaceRefTarget
-
toRef
Create a counted reference to the nativeRagdollSettings
.
-