Class RagdollSettings

java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.RagdollSettings
All Implemented Interfaces:
ConstJoltPhysicsObject, RefTarget, AutoCloseable, Comparable<JoltPhysicsObject>

public class RagdollSettings extends JoltPhysicsObject implements RefTarget
Settings and structure used to create a Ragdoll.
  • Constructor Details

    • RagdollSettings

      public RagdollSettings()
      Instantiate default settings.
  • Method Details

    • addAdditionalConstraint

      public void addAdditionalConstraint(AdditionalConstraint constraint)
      Add the specified constraint.
      Parameters:
      constraint - (not null)
    • calculateBodyIndexToConstraintIndex

      public void calculateBodyIndexToConstraintIndex()
      Pre-calculate the map used by getBodyIndexToConstraintIndex().
    • calculateConstraintIndexToBodyIdxPair

      public void calculateConstraintIndexToBodyIdxPair()
      Pre-calculate the map used by getConstraintIndexToBodyIdxPair().
    • createRagdoll

      public Ragdoll createRagdoll(int groupId, long userData, PhysicsSystem physicsSystem)
      Generate a ragdoll instance from the settings, which are unaffected.
      Parameters:
      groupId - the collision group for the bodies
      userData - the desired user-data value
      physicsSystem - 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

      public Part[] 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

      public Skeleton 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

      public void saveBinaryState(StreamOut stream, boolean saveShapes, boolean saveGroupFilter)
      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 shapes
      saveGroupFilter - if true, save the group filter
    • setSkeleton

      public void setSkeleton(Skeleton skeleton)
      Replace the skeleton. (native attribute: mSkeleton)
      Parameters:
      skeleton - the desired skeleton (not null)
    • sRestoreFromBinaryState

      public static RagdollResult sRestoreFromBinaryState(StreamIn stream)
      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, otherwise false
    • getRefCount

      public int getRefCount()
      Count the active references to the native RagdollSettings. The settings are unaffected.
      Specified by:
      getRefCount in interface RefTarget
      Returns:
      the count (≥0)
    • setEmbedded

      public void setEmbedded()
      Mark the native RagdollSettings as embedded.
      Specified by:
      setEmbedded in interface RefTarget
    • toRef

      public RagdollSettingsRef toRef()
      Create a counted reference to the native RagdollSettings.
      Specified by:
      toRef in interface RefTarget
      Returns:
      a new JVM object with a new native object assigned