java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.RagdollSettings
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstRagdollSettings,RefTarget,AutoCloseable,Comparable<JoltPhysicsObject>
Settings and structure used to create a
Ragdoll.-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate default settings.RagdollSettings(ConstRagdollSettings original) Instantiate a copy of the specified settings. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalConstraint(AdditionalConstraint constraint) Add the specified constraint.voidPre-calculate the map used bygetBodyIndexToConstraintIndex().voidPre-calculate the map used bygetConstraintIndexToBodyIdxPair().voidInitialize the constraint priorities so that constraints near the leaves have priority than those near the root.voidcalculateConstraintPriorities(int basePriority) Initialize the constraint priorities so that constraints near the leaves have priority than those near the root.createRagdoll(int groupId, long userData, PhysicsSystem physicsSystem) Generate a ragdoll instance from the settings, which are unaffected.voidCreate and add collision filters to all bodies in the ragdoll and configure them so parents and children don't collide.getBodyIndicesForConstraintIndex(int constraintIndex) Copy the body-index pair for the specified constraint.intgetConstraintIndexForBodyIndex(int bodyIndex) Return the index of the constraint upstream from the specified body.intCount the parts.getPart(int partIndex) Access the part for the specified index.Part[]getParts()Access the parts by way of a Java array.intCount the active references to the nativeRagdollSettings.Access the skeleton.voidresizeParts(int numParts) Resize the parts array.voidsaveBinaryState(StreamOut stream, boolean saveShapes, boolean saveGroupFilter) Save the settings to the specified binary stream.voidset(ConstRagdollSettings source) Copy the argument to the current settings.voidMark the nativeRagdollSettingsas embedded.voidsetSkeleton(Skeleton skeleton) Replace the skeleton.static RagdollResultsRestoreFromBinaryState(StreamIn stream) Read a ragdoll from the specified input stream.booleanStabilize the constraints.toRef()Create a counted reference to the current settings.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, targetVaOrZero, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa, targetVaOrZero
-
Constructor Details
-
RagdollSettings
public RagdollSettings()Instantiate default settings. -
RagdollSettings
Instantiate a copy of the specified settings.- Parameters:
original- the settings to copy (notnull, unaffected)
-
-
Method Details
-
addAdditionalConstraint
Add the specified constraint.- Parameters:
constraint- (notnull)
-
calculateBodyIndexToConstraintIndex
public void calculateBodyIndexToConstraintIndex()Pre-calculate the map used bygetBodyIndexToConstraintIndex(). -
calculateConstraintIndexToBodyIdxPair
public void calculateConstraintIndexToBodyIdxPair()Pre-calculate the map used bygetConstraintIndexToBodyIdxPair(). -
calculateConstraintPriorities
public void calculateConstraintPriorities()Initialize the constraint priorities so that constraints near the leaves have priority than those near the root. -
calculateConstraintPriorities
public void calculateConstraintPriorities(int basePriority) Initialize the constraint priorities so that constraints near the leaves have priority than those near the root.- Parameters:
basePriority- the lowest priority to use (default=0)
-
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
-
resizeParts
public void resizeParts(int numParts) Resize the parts array.- Parameters:
numParts- the desired number of parts (≥0)
-
set
Copy the argument to the current settings.- Parameters:
source- the settings to copy (notnull, unaffected)
-
setSkeleton
Replace the skeleton. (native attribute: mSkeleton)- Parameters:
skeleton- the desired skeleton (notnull)
-
sRestoreFromBinaryState
Read a ragdoll from the specified input stream.- Parameters:
stream- the stream to read from (notnull)- Returns:
- the result of the read (not
null)
-
stabilize
public boolean stabilize()Stabilize the constraints.- Returns:
trueif successful, otherwisefalse
-
createRagdoll
Generate a ragdoll instance from the settings, which are unaffected.- Specified by:
createRagdollin interfaceConstRagdollSettings- Parameters:
groupId- the collision group for the bodiesuserData- the desired user-data valuephysicsSystem- where to add the bodies and constraints (notnull, modified)- Returns:
- a new ragdoll instance, or
nullwhen out of bodies
-
getBodyIndicesForConstraintIndex
Copy the body-index pair for the specified constraint.- Specified by:
getBodyIndicesForConstraintIndexin interfaceConstRagdollSettings- Parameters:
constraintIndex- the index of the constraint (≥0)- Returns:
- a new object
-
getConstraintIndexForBodyIndex
public int getConstraintIndexForBodyIndex(int bodyIndex) Return the index of the constraint upstream from the specified body. The settings are unaffected.- Specified by:
getConstraintIndexForBodyIndexin interfaceConstRagdollSettings- Parameters:
bodyIndex- index of the body in the ragdoll (≥0)- Returns:
- the constraint index
-
getNumParts
public int getNumParts()Count the parts. The settings are unaffected.- Specified by:
getNumPartsin interfaceConstRagdollSettings- Returns:
- the count (≥0)
-
getPart
Access the part for the specified index.- Specified by:
getPartin interfaceConstRagdollSettings- Parameters:
partIndex- index of the part (≥0)- Returns:
- a new JVM object with pre-existing native object assigned
-
getSkeleton
Access the skeleton. (native attribute: mSkeleton)- Specified by:
getSkeletonin interfaceConstRagdollSettings- Returns:
- a new JVM object with the pre-existing native object assigned
-
saveBinaryState
Save the settings to the specified binary stream. The settings are unaffected.- Specified by:
saveBinaryStatein interfaceConstRagdollSettings- Parameters:
stream- the stream to write to (notnull)saveShapes- if true, save the shapessaveGroupFilter- if true, save the group filter
-
getRefCount
public int getRefCount()Count the active references to the nativeRagdollSettings. The settings are unaffected.- Specified by:
getRefCountin interfaceRefTarget- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativeRagdollSettingsas embedded.- Specified by:
setEmbeddedin interfaceRefTarget
-
toRef
Create a counted reference to the current settings.
-