43 VertexAttributes(
float inCompliance,
float inShearCompliance,
float inBendCompliance,
ELRAType inLRAType = ELRAType::None,
float inLRAMaxDistanceMultiplier = 1.0f) : mCompliance(inCompliance), mShearCompliance(inShearCompliance), mBendCompliance(inBendCompliance), mLRAType(inLRAType), mLRAMaxDistanceMultiplier(inLRAMaxDistanceMultiplier) { }
45 float mCompliance = 0.0f;
46 float mShearCompliance = 0.0f;
47 float mBendCompliance = FLT_MAX;
49 float mLRAMaxDistanceMultiplier = 1.0f;
60 void CalculateEdgeLengths();
64 void CalculateRodProperties();
68 void CalculateLRALengths(
float inMaxDistanceMultiplier = 1.0f);
71 void CalculateBendConstraintConstants();
74 void CalculateVolumeConstraintVolumes();
77 void CalculateSkinnedConstraintNormals();
102 void SaveBinaryState(
StreamOut &inStream)
const;
105 void RestoreBinaryState(
StreamIn &inStream);
133 Vertex(const
Float3 &inPosition, const
Float3 &inVelocity =
Float3(0, 0, 0),
float inInvMass = 1.0f) : mPosition(inPosition), mVelocity(inVelocity), mInvMass(inInvMass) { }
137 float mInvMass = 1.0f;
147 Face(
uint32 inVertex1,
uint32 inVertex2,
uint32 inVertex3,
uint32 inMaterialIndex = 0) : mVertex { inVertex1, inVertex2, inVertex3 }, mMaterialIndex(inMaterialIndex) { }
150 bool IsDegenerate()
const {
return mVertex[0] == mVertex[1] || mVertex[0] == mVertex[2] || mVertex[1] == mVertex[2]; }
163 Edge(
uint32 inVertex1,
uint32 inVertex2,
float inCompliance = 0.0f) : mVertex { inVertex1, inVertex2 }, mCompliance(inCompliance) { }
169 float mRestLength = 1.0f;
170 float mCompliance = 0.0f;
197 DihedralBend(
uint32 inVertex1,
uint32 inVertex2,
uint32 inVertex3,
uint32 inVertex4,
float inCompliance = 0.0f) : mVertex { inVertex1, inVertex2, inVertex3, inVertex4 }, mCompliance(inCompliance) { }
203 float mCompliance = 0.0f;
204 float mInitialAngle = 0.0f;
214 Volume(
uint32 inVertex1,
uint32 inVertex2,
uint32 inVertex3,
uint32 inVertex4,
float inCompliance = 0.0f) : mVertex { inVertex1, inVertex2, inVertex3, inVertex4 }, mCompliance(inCompliance) { }
220 float mSixRestVolume = 1.0f;
221 float mCompliance = 0.0f;
246 SkinWeight(
uint32 inInvBindIndex,
float inWeight) : mInvBindIndex(inInvBindIndex), mWeight(inWeight) { }
249 float mWeight = 0.0f;
260 Skinned(
uint32 inVertex,
float inMaxDistance,
float inBackStopDistance,
float inBackStopRadius) : mVertex(inVertex), mMaxDistance(inMaxDistance), mBackStopDistance(inBackStopDistance), mBackStopRadius(inBackStopRadius) { }
277 static constexpr uint cMaxSkinWeights = 4;
281 float mMaxDistance = FLT_MAX;
282 float mBackStopDistance = FLT_MAX;
283 float mBackStopRadius = 40.0f;
296 LRA(
uint32 inVertex1,
uint32 inVertex2,
float inMaxDistance) : mVertex { inVertex1, inVertex2 }, mMaxDistance(inMaxDistance) { }
302 float mMaxDistance = 0.0f;
324 float mLength = 1.0f;
325 float mInvMass = 1.0f;
326 float mCompliance = 0.0f;
340 float mCompliance = 0.0f;
358 float mVertexRadius = 0.0f;
364 void CalculateClosestKinematic();
367 struct ClosestKinematic
369 uint32 mVertex = 0xffffffff;
370 float mDistance = FLT_MAX;
378 uint mRodStretchShearEndIndex;
379 uint mRodBendTwistEndIndex;
380 uint mDihedralBendEndIndex;
381 uint mVolumeEndIndex;
382 uint mSkinnedEndIndex;
@ None
No degrees of freedom are allowed. Note that this is not valid and will crash. Use a static body inst...
#define JPH_EXPORT
Definition Core.h:275
unsigned int uint
Definition Core.h:487
#define JPH_NAMESPACE_END
Definition Core.h:419
std::uint32_t uint32
Definition Core.h:490
#define JPH_NAMESPACE_BEGIN
Definition Core.h:413
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
JPH_INLINE constexpr float DegreesToRadians(float inV)
Convert a value from degrees to radians.
Definition Math.h:16
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:80
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition Float3.h:13
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
static JPH_INLINE Mat44 sIdentity()
Identity matrix.
Definition Mat44.inl:35
static RefConst< PhysicsMaterial > sDefault
Default material that is used when a shape has no materials defined.
Definition PhysicsMaterial.h:31
static JPH_INLINE Quat sZero()
Definition Quat.h:100
Definition Reference.h:107
Definition Reference.h:35
Helper class that either contains a valid result or an error.
Definition Result.h:12
This class contains the runtime information of a soft body.
Definition SoftBodyMotionProperties.h:35
An inverse bind matrix take a skinned vertex from its bind pose into joint local space.
Definition SoftBodySharedSettings.h:226
InvBind()=default
Constructor.
InvBind(uint32 inJointIndex, Mat44Arg inInvBind)
Definition SoftBodySharedSettings.h:232
Definition SoftBodySharedSettings.h:290
uint32 GetMinVertexIndex() const
Return the lowest vertex index of this constraint.
Definition SoftBodySharedSettings.h:299
LRA()=default
Constructor.
LRA(uint32 inVertex1, uint32 inVertex2, float inMaxDistance)
Definition SoftBodySharedSettings.h:296
Information about the optimization of the soft body, the indices of certain elements may have changed...
Definition SoftBodySharedSettings.h:81
Array< uint > mLRARemap
Maps old LRA index to new LRA index.
Definition SoftBodySharedSettings.h:84
Array< uint > mRodStretchShearConstraintRemap
Maps old rod stretch shear constraint index to new stretch shear rod constraint index.
Definition SoftBodySharedSettings.h:85
Array< uint > mVolumeRemap
Maps old volume constraint index to new volume constraint index.
Definition SoftBodySharedSettings.h:88
Array< uint > mDihedralBendRemap
Maps old dihedral bend index to new dihedral bend index.
Definition SoftBodySharedSettings.h:87
Array< uint > mSkinnedRemap
Maps old skinned constraint index to new skinned constraint index.
Definition SoftBodySharedSettings.h:89
Array< uint > mEdgeRemap
Maps old edge index to new edge index.
Definition SoftBodySharedSettings.h:83
Array< uint > mRodBendTwistConstraintRemap
Maps old rod bend twist constraint index to new bend twist rod constraint index.
Definition SoftBodySharedSettings.h:86
A joint and its skin weight.
Definition SoftBodySharedSettings.h:240
SkinWeight()=default
Constructor.
SkinWeight(uint32 inInvBindIndex, float inWeight)
Definition SoftBodySharedSettings.h:246
A constraint that skins a vertex to joints and limits the distance that the simulated vertex can trav...
Definition SoftBodySharedSettings.h:254
void NormalizeWeights()
Normalize the weights so that they add up to 1.
Definition SoftBodySharedSettings.h:263
Skinned()=default
Constructor.
Skinned(uint32 inVertex, float inMaxDistance, float inBackStopDistance, float inBackStopRadius)
Definition SoftBodySharedSettings.h:260
Definition SoftBodySharedSettings.h:16
Array< RodStretchShear > mRodStretchShearConstraints
The list of Cosserat rod constraints that connect two vertices and that limit stretch and shear.
Definition SoftBodySharedSettings.h:355
Array< Vertex > mVertices
The list of vertices or particles of the body.
Definition SoftBodySharedSettings.h:347
ELRAType
The type of long range attachment constraint to create.
Definition SoftBodySharedSettings.h:30
Array< LRA > mLRAConstraints
The list of long range attachment constraints.
Definition SoftBodySharedSettings.h:354
EBendType
Which type of bend constraint should be created.
Definition SoftBodySharedSettings.h:22
Array< RodBendTwist > mRodBendTwistConstraints
The list of Cosserat rod constraints that connect two rods and limit the bend and twist.
Definition SoftBodySharedSettings.h:356
Array< Skinned > mSkinnedConstraints
The list of vertices that are constrained to a skinned vertex.
Definition SoftBodySharedSettings.h:352
void Optimize()
Optimize the soft body settings without results.
Definition SoftBodySharedSettings.h:96
Array< Face > mFaces
The list of faces of the body.
Definition SoftBodySharedSettings.h:348
Array< DihedralBend > mDihedralBendConstraints
The list of dihedral bend constraints of the body.
Definition SoftBodySharedSettings.h:350
Array< Volume > mVolumeConstraints
The list of volume constraints of the body that keep the volume of tetrahedra in the soft body consta...
Definition SoftBodySharedSettings.h:351
Array< Edge > mEdgeConstraints
The list of edges or springs of the body.
Definition SoftBodySharedSettings.h:349
Array< InvBind > mInvBindMatrices
The list of inverse bind matrices for skinning vertices.
Definition SoftBodySharedSettings.h:353
void AddFace(const Face &inFace)
Add a face to this soft body.
Definition SoftBodySharedSettings.h:345
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
Definition UnorderedMap.h:30
Definition SoftBodySharedSettings.h:192
uint32 GetMinVertexIndex() const
Return the lowest vertex index of this constraint.
Definition SoftBodySharedSettings.h:200
An edge keeps two vertices at a constant distance using a spring: |x1 - x2| = rest length.
Definition SoftBodySharedSettings.h:158
uint32 GetMinVertexIndex() const
Return the lowest vertex index of this constraint.
Definition SoftBodySharedSettings.h:166
A face defines the surface of the body.
Definition SoftBodySharedSettings.h:142
bool IsDegenerate() const
Check if this is a degenerate face (a face which points to the same vertex twice)
Definition SoftBodySharedSettings.h:150
A constraint that connects two Cosserat rods and limits bend and twist between the rods.
Definition SoftBodySharedSettings.h:332
Definition SoftBodySharedSettings.h:313
uint32 GetMinVertexIndex() const
Return the lowest vertex index of this constraint.
Definition SoftBodySharedSettings.h:321
Definition SoftBodySharedSettings.h:40
VertexAttributes()=default
Constructor.
VertexAttributes(float inCompliance, float inShearCompliance, float inBendCompliance, ELRAType inLRAType=ELRAType::None, float inLRAMaxDistanceMultiplier=1.0f)
Definition SoftBodySharedSettings.h:43
A vertex is a particle, the data in this structure is only used during creation of the soft body and ...
Definition SoftBodySharedSettings.h:128
Volume constraint, keeps the volume of a tetrahedron constant.
Definition SoftBodySharedSettings.h:209
uint32 GetMinVertexIndex() const
Return the lowest vertex index of this constraint.
Definition SoftBodySharedSettings.h:217