Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SoftBodySharedSettings Class Reference

#include <SoftBodySharedSettings.h>

Inheritance diagram for SoftBodySharedSettings:
RefTarget< SoftBodySharedSettings >

Classes

struct  DihedralBend
 
struct  Edge
 An edge keeps two vertices at a constant distance using a spring: |x1 - x2| = rest length. More...
 
struct  Face
 A face defines the surface of the body. More...
 
class  InvBind
 An inverse bind matrix take a skinned vertex from its bind pose into joint local space. More...
 
class  LRA
 
class  OptimizationResults
 Information about the optimization of the soft body, the indices of certain elements may have changed. More...
 
class  Skinned
 A constraint that skins a vertex to joints and limits the distance that the simulated vertex can travel from this vertex. More...
 
class  SkinWeight
 A joint and its skin weight. More...
 
struct  Vertex
 A vertex is a particle, the data in this structure is only used during creation of the soft body and not during simulation. More...
 
struct  VertexAttributes
 
struct  Volume
 Volume constraint, keeps the volume of a tetrahedron constant. More...
 

Public Types

enum class  EBendType { None , Distance , Dihedral }
 Which type of bend constraint should be created. More...
 
enum class  ELRAType { None , EuclideanDistance , GeodesicDistance }
 The type of long range attachment constraint to create. More...
 
using SharedSettingsToIDMap = StreamUtils::ObjectToIDMap< SoftBodySharedSettings >
 
using IDToSharedSettingsMap = StreamUtils::IDToObjectMap< SoftBodySharedSettings >
 
using MaterialToIDMap = StreamUtils::ObjectToIDMap< PhysicsMaterial >
 
using IDToMaterialMap = StreamUtils::IDToObjectMap< PhysicsMaterial >
 
using SettingsResult = Result< Ref< SoftBodySharedSettings > >
 

Public Member Functions

void CreateConstraints (const VertexAttributes *inVertexAttributes, uint inVertexAttributesLength, EBendType inBendType=EBendType::Distance, float inAngleTolerance=DegreesToRadians(8.0f))
 
void CalculateEdgeLengths ()
 Calculate the initial lengths of all springs of the edges of this soft body (if you use CreateConstraint, this is already done) More...
 
void CalculateLRALengths (float inMaxDistanceMultiplier=1.0f)
 
void CalculateBendConstraintConstants ()
 Calculate the constants for the bend constraints (if you use CreateConstraints, this is already done) More...
 
void CalculateVolumeConstraintVolumes ()
 Calculates the initial volume of all tetrahedra of this soft body. More...
 
void CalculateSkinnedConstraintNormals ()
 Calculate information needed to be able to calculate the skinned constraint normals at run-time. More...
 
void Optimize (OptimizationResults &outResults)
 Optimize the soft body settings for simulation. This will reorder constraints so they can be executed in parallel. More...
 
void Optimize ()
 Optimize the soft body settings without results. More...
 
Ref< SoftBodySharedSettingsClone () const
 Clone this object. More...
 
void SaveBinaryState (StreamOut &inStream) const
 Saves the state of this object in binary form to inStream. Doesn't store the material list. More...
 
void RestoreBinaryState (StreamIn &inStream)
 Restore the state of this object from inStream. Doesn't restore the material list. More...
 
void SaveWithMaterials (StreamOut &inStream, SharedSettingsToIDMap &ioSettingsMap, MaterialToIDMap &ioMaterialMap) const
 Save this shared settings and its materials. Pass in an empty map ioSettingsMap / ioMaterialMap or reuse the same map while saving multiple settings objects to the same stream in order to avoid writing duplicates. More...
 
void AddFace (const Face &inFace)
 Add a face to this soft body. More...
 
- Public Member Functions inherited from RefTarget< SoftBodySharedSettings >
 RefTarget ()=default
 Constructor. More...
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us More...
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator. More...
 
uint32 GetRefCount () const
 Get current refcount of this object. More...
 
void AddRef () const
 Add or release a reference to this object. More...
 
void Release () const
 

Static Public Member Functions

static SettingsResult sRestoreWithMaterials (StreamIn &inStream, IDToSharedSettingsMap &ioSettingsMap, IDToMaterialMap &ioMaterialMap)
 Restore a shape and materials. Pass in an empty map in ioSettingsMap / ioMaterialMap or reuse the same map while reading multiple settings objects from the same stream in order to restore duplicates. More...
 
- Static Public Member Functions inherited from RefTarget< SoftBodySharedSettings >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION. More...
 

Public Attributes

Array< VertexmVertices
 The list of vertices or particles of the body. More...
 
Array< FacemFaces
 The list of faces of the body. More...
 
Array< EdgemEdgeConstraints
 The list of edges or springs of the body. More...
 
Array< DihedralBendmDihedralBendConstraints
 The list of dihedral bend constraints of the body. More...
 
Array< VolumemVolumeConstraints
 The list of volume constraints of the body that keep the volume of tetrahedra in the soft body constant. More...
 
Array< SkinnedmSkinnedConstraints
 The list of vertices that are constrained to a skinned vertex. More...
 
Array< InvBindmInvBindMatrices
 The list of inverse bind matrices for skinning vertices. More...
 
Array< LRAmLRAConstraints
 The list of long range attachment constraints. More...
 
PhysicsMaterialList mMaterials { PhysicsMaterial::sDefault }
 The materials of the faces of the body, referenced by Face::mMaterialIndex. More...
 
float mVertexRadius = 0.0f
 How big the particles are, can be used to push the vertices a little bit away from the surface of other bodies to prevent z-fighting. More...
 

Friends

class SoftBodyMotionProperties
 

Additional Inherited Members

- Protected Attributes inherited from RefTarget< SoftBodySharedSettings >
atomic< uint32mRefCount
 Current reference count. More...
 
- Static Protected Attributes inherited from RefTarget< SoftBodySharedSettings >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded. More...
 

Detailed Description

This class defines the setup of all particles and their constraints. It is used during the simulation and can be shared between multiple soft bodies.

Member Typedef Documentation

◆ IDToMaterialMap

◆ IDToSharedSettingsMap

◆ MaterialToIDMap

◆ SettingsResult

◆ SharedSettingsToIDMap

Member Enumeration Documentation

◆ EBendType

Which type of bend constraint should be created.

Enumerator
None 

No bend constraints will be created.

Distance 

A simple distance constraint.

Dihedral 

A dihedral bend constraint (most expensive, but also supports triangles that are initially not in the same plane)

◆ ELRAType

The type of long range attachment constraint to create.

Enumerator
None 

Don't create a LRA constraint.

EuclideanDistance 

Create a LRA constraint based on Euclidean distance between the closest kinematic vertex and this vertex.

GeodesicDistance 

Create a LRA constraint based on the geodesic distance between the closest kinematic vertex and this vertex (follows the edge constraints)

Member Function Documentation

◆ AddFace()

void SoftBodySharedSettings::AddFace ( const Face inFace)
inline

Add a face to this soft body.

◆ CalculateBendConstraintConstants()

void SoftBodySharedSettings::CalculateBendConstraintConstants ( )

Calculate the constants for the bend constraints (if you use CreateConstraints, this is already done)

◆ CalculateEdgeLengths()

void SoftBodySharedSettings::CalculateEdgeLengths ( )

Calculate the initial lengths of all springs of the edges of this soft body (if you use CreateConstraint, this is already done)

◆ CalculateLRALengths()

void SoftBodySharedSettings::CalculateLRALengths ( float  inMaxDistanceMultiplier = 1.0f)

Calculate the max lengths for the long range attachment constraints based on Euclidean distance (if you use CreateConstraints, this is already done)

Parameters
inMaxDistanceMultiplierMultiplier for the max distance of the LRA constraint, e.g. 1.01 means the max distance is 1% longer than the calculated distance in the rest pose.

◆ CalculateSkinnedConstraintNormals()

void SoftBodySharedSettings::CalculateSkinnedConstraintNormals ( )

Calculate information needed to be able to calculate the skinned constraint normals at run-time.

◆ CalculateVolumeConstraintVolumes()

void SoftBodySharedSettings::CalculateVolumeConstraintVolumes ( )

Calculates the initial volume of all tetrahedra of this soft body.

◆ Clone()

Ref< SoftBodySharedSettings > SoftBodySharedSettings::Clone ( ) const

Clone this object.

◆ CreateConstraints()

void SoftBodySharedSettings::CreateConstraints ( const VertexAttributes inVertexAttributes,
uint  inVertexAttributesLength,
EBendType  inBendType = EBendType::Distance,
float  inAngleTolerance = DegreesToRadians(8.0f) 
)

Automatically create constraints based on the faces of the soft body

Parameters
inVertexAttributesA list of attributes for each vertex (1-on-1 with mVertices, note that if the list is smaller than mVertices the last element will be repeated). This defines the properties of the constraints that are created.
inVertexAttributesLengthThe length of inVertexAttributes
inBendTypeThe type of bend constraint to create
inAngleToleranceShear edges are created when two connected triangles form a quad (are roughly in the same plane and form a square with roughly 90 degree angles). This defines the tolerance (in radians).

◆ Optimize() [1/2]

void SoftBodySharedSettings::Optimize ( )
inline

Optimize the soft body settings without results.

◆ Optimize() [2/2]

void SoftBodySharedSettings::Optimize ( OptimizationResults outResults)

Optimize the soft body settings for simulation. This will reorder constraints so they can be executed in parallel.

◆ RestoreBinaryState()

void SoftBodySharedSettings::RestoreBinaryState ( StreamIn inStream)

Restore the state of this object from inStream. Doesn't restore the material list.

◆ SaveBinaryState()

void SoftBodySharedSettings::SaveBinaryState ( StreamOut inStream) const

Saves the state of this object in binary form to inStream. Doesn't store the material list.

◆ SaveWithMaterials()

void SoftBodySharedSettings::SaveWithMaterials ( StreamOut inStream,
SharedSettingsToIDMap ioSettingsMap,
MaterialToIDMap ioMaterialMap 
) const

Save this shared settings and its materials. Pass in an empty map ioSettingsMap / ioMaterialMap or reuse the same map while saving multiple settings objects to the same stream in order to avoid writing duplicates.

◆ sRestoreWithMaterials()

SoftBodySharedSettings::SettingsResult SoftBodySharedSettings::sRestoreWithMaterials ( StreamIn inStream,
IDToSharedSettingsMap ioSettingsMap,
IDToMaterialMap ioMaterialMap 
)
static

Restore a shape and materials. Pass in an empty map in ioSettingsMap / ioMaterialMap or reuse the same map while reading multiple settings objects from the same stream in order to restore duplicates.

Friends And Related Function Documentation

◆ SoftBodyMotionProperties

friend class SoftBodyMotionProperties
friend

Member Data Documentation

◆ mDihedralBendConstraints

Array<DihedralBend> SoftBodySharedSettings::mDihedralBendConstraints

The list of dihedral bend constraints of the body.

◆ mEdgeConstraints

Array<Edge> SoftBodySharedSettings::mEdgeConstraints

The list of edges or springs of the body.

◆ mFaces

Array<Face> SoftBodySharedSettings::mFaces

The list of faces of the body.

◆ mInvBindMatrices

Array<InvBind> SoftBodySharedSettings::mInvBindMatrices

The list of inverse bind matrices for skinning vertices.

◆ mLRAConstraints

Array<LRA> SoftBodySharedSettings::mLRAConstraints

The list of long range attachment constraints.

◆ mMaterials

PhysicsMaterialList SoftBodySharedSettings::mMaterials { PhysicsMaterial::sDefault }

The materials of the faces of the body, referenced by Face::mMaterialIndex.

◆ mSkinnedConstraints

Array<Skinned> SoftBodySharedSettings::mSkinnedConstraints

The list of vertices that are constrained to a skinned vertex.

◆ mVertexRadius

float SoftBodySharedSettings::mVertexRadius = 0.0f

How big the particles are, can be used to push the vertices a little bit away from the surface of other bodies to prevent z-fighting.

◆ mVertices

Array<Vertex> SoftBodySharedSettings::mVertices

The list of vertices or particles of the body.

◆ mVolumeConstraints

Array<Volume> SoftBodySharedSettings::mVolumeConstraints

The list of volume constraints of the body that keep the volume of tetrahedra in the soft body constant.


The documentation for this class was generated from the following files: