Jolt Physics
A multi core friendly Game Physics Engine
|
#include <SoftBodySharedSettings.h>
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) | |
void | CalculateLRALengths (float inMaxDistanceMultiplier=1.0f) |
void | CalculateBendConstraintConstants () |
Calculate the constants for the bend constraints (if you use CreateConstraints, this is already done) | |
void | CalculateVolumeConstraintVolumes () |
Calculates the initial volume of all tetrahedra of this soft body. | |
void | CalculateSkinnedConstraintNormals () |
Calculate information needed to be able to calculate the skinned constraint normals at run-time. | |
void | Optimize (OptimizationResults &outResults) |
Optimize the soft body settings for simulation. This will reorder constraints so they can be executed in parallel. | |
void | Optimize () |
Optimize the soft body settings without results. | |
Ref< SoftBodySharedSettings > | Clone () const |
Clone this object. | |
void | SaveBinaryState (StreamOut &inStream) const |
Saves the state of this object in binary form to inStream. Doesn't store the material list. | |
void | RestoreBinaryState (StreamIn &inStream) |
Restore the state of this object from inStream. Doesn't restore the material list. | |
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. | |
void | AddFace (const Face &inFace) |
Add a face to this soft body. | |
Public Member Functions inherited from RefTarget< SoftBodySharedSettings > | |
RefTarget ()=default | |
Constructor. | |
RefTarget (const RefTarget &) | |
~RefTarget () | |
assert no one is referencing us | |
void | SetEmbedded () const |
RefTarget & | operator= (const RefTarget &) |
Assignment operator. | |
uint32 | GetRefCount () const |
Get current refcount of this object. | |
void | AddRef () const |
Add or release a reference to this object. | |
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. | |
Static Public Member Functions inherited from RefTarget< SoftBodySharedSettings > | |
static int | sInternalGetRefCountOffset () |
INTERNAL HELPER FUNCTION USED BY SERIALIZATION. | |
Public Attributes | |
Array< Vertex > | mVertices |
The list of vertices or particles of the body. | |
Array< Face > | mFaces |
The list of faces of the body. | |
Array< Edge > | mEdgeConstraints |
The list of edges or springs of the body. | |
Array< DihedralBend > | mDihedralBendConstraints |
The list of dihedral bend constraints of the body. | |
Array< Volume > | mVolumeConstraints |
The list of volume constraints of the body that keep the volume of tetrahedra in the soft body constant. | |
Array< Skinned > | mSkinnedConstraints |
The list of vertices that are constrained to a skinned vertex. | |
Array< InvBind > | mInvBindMatrices |
The list of inverse bind matrices for skinning vertices. | |
Array< LRA > | mLRAConstraints |
The list of long range attachment constraints. | |
PhysicsMaterialList | mMaterials { PhysicsMaterial::sDefault } |
The materials of the faces of the body, referenced by Face::mMaterialIndex. | |
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. | |
Friends | |
class | SoftBodyMotionProperties |
Additional Inherited Members | |
Protected Attributes inherited from RefTarget< SoftBodySharedSettings > | |
atomic< uint32 > | mRefCount |
Current reference count. | |
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. | |
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.
using SoftBodySharedSettings::IDToSharedSettingsMap = StreamUtils::IDToObjectMap<SoftBodySharedSettings> |
using SoftBodySharedSettings::SharedSettingsToIDMap = StreamUtils::ObjectToIDMap<SoftBodySharedSettings> |
|
strong |
|
strong |
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) |
|
inline |
Add a face to this soft body.
void SoftBodySharedSettings::CalculateBendConstraintConstants | ( | ) |
Calculate the constants for the bend constraints (if you use CreateConstraints, this is already done)
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)
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)
inMaxDistanceMultiplier | Multiplier 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. |
void SoftBodySharedSettings::CalculateSkinnedConstraintNormals | ( | ) |
Calculate information needed to be able to calculate the skinned constraint normals at run-time.
void SoftBodySharedSettings::CalculateVolumeConstraintVolumes | ( | ) |
Calculates the initial volume of all tetrahedra of this soft body.
Ref< SoftBodySharedSettings > SoftBodySharedSettings::Clone | ( | ) | const |
Clone this object.
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
inVertexAttributes | A 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. |
inVertexAttributesLength | The length of inVertexAttributes |
inBendType | The type of bend constraint to create |
inAngleTolerance | Shear 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). |
|
inline |
Optimize the soft body settings without results.
void SoftBodySharedSettings::Optimize | ( | OptimizationResults & | outResults | ) |
Optimize the soft body settings for simulation. This will reorder constraints so they can be executed in parallel.
void SoftBodySharedSettings::RestoreBinaryState | ( | StreamIn & | inStream | ) |
Restore the state of this object from inStream. Doesn't restore the material list.
void SoftBodySharedSettings::SaveBinaryState | ( | StreamOut & | inStream | ) | const |
Saves the state of this object in binary form to inStream. Doesn't store the material list.
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.
|
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.
|
friend |
Array<DihedralBend> SoftBodySharedSettings::mDihedralBendConstraints |
The list of dihedral bend constraints of the body.
The list of inverse bind matrices for skinning vertices.
PhysicsMaterialList SoftBodySharedSettings::mMaterials { PhysicsMaterial::sDefault } |
The materials of the faces of the body, referenced by Face::mMaterialIndex.
The list of vertices that are constrained to a skinned vertex.
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.
The list of volume constraints of the body that keep the volume of tetrahedra in the soft body constant.