Class SoftBodySharedSettings

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

public class SoftBodySharedSettings extends JoltPhysicsObject implements ConstSoftBodySharedSettings, RefTarget
Properties of a soft body that may be shared among multiple bodies.
  • Constructor Details

    • SoftBodySharedSettings

      public SoftBodySharedSettings()
      Instantiate with the default settings.
    • SoftBodySharedSettings

      public SoftBodySharedSettings(ConstSoftBodySharedSettings original)
      Instantiate a copy of the specified settings.
      Parameters:
      original - the settings to copy (not null, unaffected)
  • Method Details

    • addEdgeConstraint

      public void addEdgeConstraint(ConstEdge edge)
      Add the specified edge constraint.
      Parameters:
      edge - the edge to add (not null, unaffected)
    • addFace

      public void addFace(ConstFace face)
      Add the specified face.
      Parameters:
      face - the face to add (not null, unaffected)
    • addInvBindMatrix

      public void addInvBindMatrix(InvBind invBind)
      Append the specified inverse-bind matrix. (native member: mInvBindMatrices)
      Parameters:
      invBind - the matrix to add (not null)
    • addRodBendTwistConstraint

      public void addRodBendTwistConstraint(ConstRodBendTwist constraint)
      Append the specified bend-twist constraint. (native member: mRodBendTwistConstraints)
      Parameters:
      constraint - the constraint to add (not null)
    • addRodStretchShearConstraint

      public void addRodStretchShearConstraint(ConstRodStretchShear rod)
      Append the specified discrete Cosserat rod. (native member: mRodStretchShearConstraints)
      Parameters:
      rod - the rod to add (not null)
    • addSkinnedConstraint

      public void addSkinnedConstraint(Skinned skinned)
      Append the specified skinning constraint. (native member: mSkinnedConstraints)
      Parameters:
      skinned - the constraint to add (not null)
    • addVertex

      public void addVertex(ConstVertex vertex)
      Add the specified vertex. (native member: mVertices)
      Parameters:
      vertex - the vertex to add (not null, unaffected)
    • addVolumeConstraint

      public void addVolumeConstraint(ConstVolume volume)
      Add the specified volume constraint.
      Parameters:
      volume - the constraint to add (not null, unaffected)
    • calculateEdgeLengths

      public void calculateEdgeLengths()
      Calculate the initial lengths of all edges in the body.
    • calculateRodProperties

      public void calculateRodProperties()
      Calculate the information needed to simulate Cosserat rods.
    • calculateSkinnedConstraintNormals

      public void calculateSkinnedConstraintNormals()
      Calculate the information needed for skinned constraint normals.
    • calculateVolumeConstraintVolumes

      public void calculateVolumeConstraintVolumes()
      Calculate the initial volumes of all tetrahedra in the body.
    • createConstraints

      public void createConstraints(ConstVertexAttributes vertexAttributes, int numAttributes, EBendType bendType)
      Automatically generate constraints based on the faces.
      Parameters:
      vertexAttributes - the desired attributes (one for each vertex)
      numAttributes - the number of attributes provided (≥0)
      bendType - the desired type of bend constraint (not null, default=Distance)
    • createConstraints

      public void createConstraints(ConstVertexAttributes[] vertexAttributes, EBendType bendType)
      Automatically generate constraints based on the faces.
      Parameters:
      vertexAttributes - the desired attributes (one for each vertex)
      bendType - the desired type of bend constraint (not null, default=Distance)
    • createConstraints

      public void createConstraints(ConstVertexAttributes[] vertexAttributes, EBendType bendType, float angleTolerance)
      Automatically generate constraints based on the faces.
      Parameters:
      vertexAttributes - the desired attributes (one for each vertex)
      bendType - the desired type of bend constraint (not null, default=Distance)
      angleTolerance - the desired tolerance for creating shear edges (in radians, default=2*Pi/45)
    • getEdgeConstraints

      public Edge[] getEdgeConstraints()
      Enumerate all edge constraints in the settings. (native member: mEdgeConstraints)
      Returns:
      a new array of new JVM objects with the pre-existing native objects assigned
    • getRodBendTwistConstraints

      public RodBendTwist[] getRodBendTwistConstraints()
      Enumerate all bend-twist constraints in the settings. (native member: mRodBendTwistConstraints)
      Returns:
      a new array of new JVM objects with the pre-existing native objects assigned
    • getVertex

      public Vertex getVertex(int index)
      Access the specified vertex.
      Parameters:
      index - the index of the vertex (≥0)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getVertices

      public Vertex[] getVertices()
      Enumerate all vertices in the settings. (native member: mVertices)
      Returns:
      a new array of new JVM objects with pre-existing native objects assigned
    • optimize

      public void optimize()
      Optimize the settings without writing any results.
    • restoreBinaryState

      public void restoreBinaryState(StreamIn stream)
      Read the state of this object from the specified stream, excluding the shape and group filter.
      Parameters:
      stream - where to read objects from (not null)
    • sCreateCube

      public static SoftBodySharedSettingsRef sCreateCube(int gridSize, float gridSpacing)
      Create a cube with edge constraints, volume constraints, and faces.
      Parameters:
      gridSize - the desired number of points on each axis (≥1)
      gridSpacing - the distance between adjacent points
      Returns:
      a counted reference to new settings
    • setMaterials

      public void setMaterials(PhysicsMaterial material)
      Replace the materials. (native member: mMaterials)
      Parameters:
      material - the desired material, or null
    • sRestoreWithMaterials

      public static SettingsResult sRestoreWithMaterials(StreamIn stream, IdToSharedSettingsMap settingsMap, IdToMaterialMap materialMap)
      Read a settings object from the specified binary stream.
      Parameters:
      stream - where to read objects (not null)
      settingsMap - track multiple uses of shared settings (not null)
      materialMap - track multiple uses of physics materials (not null)
      Returns:
      a new object
    • countEdgeConstraints

      public int countEdgeConstraints()
      Count the edge constraints. The settings are unaffected. (native member: mEdgeConstraints)
      Specified by:
      countEdgeConstraints in interface ConstSoftBodySharedSettings
      Returns:
      the count (≥0)
    • countFaces

      public int countFaces()
      Count the faces. The settings are unaffected. (native member: mFaces)
      Specified by:
      countFaces in interface ConstSoftBodySharedSettings
      Returns:
      the count (≥0)
    • countPinnedVertices

      public int countPinnedVertices()
      Count the pinned vertices. The settings are unaffected.
      Specified by:
      countPinnedVertices in interface ConstSoftBodySharedSettings
      Returns:
      the count (≥0)
    • countRodBendTwistConstraints

      public int countRodBendTwistConstraints()
      Count the bend-twist constraints. The settings are unaffected. (native member: mRodBendTwistConstraint)
      Specified by:
      countRodBendTwistConstraints in interface ConstSoftBodySharedSettings
      Returns:
      the count (≥0)
    • countRodStretchShearConstraints

      public int countRodStretchShearConstraints()
      Count the discrete Cosserat rods. The settings are unaffected. (native member: mRodStretchShearConstraint)
      Specified by:
      countRodStretchShearConstraints in interface ConstSoftBodySharedSettings
      Returns:
      the count (≥0)
    • countVertices

      public int countVertices()
      Count the vertices. The settings are unaffected. (native member: mVertices)
      Specified by:
      countVertices in interface ConstSoftBodySharedSettings
      Returns:
      the count (≥0)
    • countVolumeConstraints

      public int countVolumeConstraints()
      Count the volume constraints. The settings are unaffected. (native member: mVolumeConstraints)
      Specified by:
      countVolumeConstraints in interface ConstSoftBodySharedSettings
      Returns:
      the count (≥0)
    • getRodStretchShearConstraints

      public RodStretchShear[] getRodStretchShearConstraints()
      Enumerate all Cosserat rods in the settings. (native member: mRodStretchShearConstraints)
      Specified by:
      getRodStretchShearConstraints in interface ConstSoftBodySharedSettings
      Returns:
      a new array of new JVM objects with the pre-existing native objects assigned
    • putEdgeIndices

      public void putEdgeIndices(IntBuffer storeIndices)
      Write the vertex indices of all edges to the specified buffer and advance the buffer's position. The settings are unaffected.
      Specified by:
      putEdgeIndices in interface ConstSoftBodySharedSettings
      Parameters:
      storeIndices - the destination buffer (not null, modified)
    • putFaceIndices

      public void putFaceIndices(IntBuffer storeIndices)
      Write the vertex indices of all faces to the specified buffer and advance the buffer's position. The settings are unaffected.
      Specified by:
      putFaceIndices in interface ConstSoftBodySharedSettings
      Parameters:
      storeIndices - the destination buffer (not null, modified)
    • saveBinaryState

      public void saveBinaryState(StreamOut stream)
      Write the state of this object to the specified stream, excluding the materials. The settings are unaffected.
      Specified by:
      saveBinaryState in interface ConstSoftBodySharedSettings
      Parameters:
      stream - where to write objects (not null)
    • saveWithMaterials

      public void saveWithMaterials(StreamOut stream, SharedSettingsToIdMap settingsMap, MaterialToIdMap materialMap)
      Write the state of this object to the specified stream. The settings are unaffected.
      Specified by:
      saveWithMaterials in interface ConstSoftBodySharedSettings
      Parameters:
      stream - where to write objects (not null)
      settingsMap - track multiple uses of shared settings (not null)
      materialMap - track multiple uses of physics materials (not null)
    • getRefCount

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

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

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