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

This class contains the runtime information of a soft body. More...

#include <SoftBodyMotionProperties.h>

Inheritance diagram for SoftBodyMotionProperties:
MotionProperties

Public Types

enum class  EStatus { NoWork = 1 << 0 , DidWork = 1 << 1 , Done = 1 << 2 }
 Return code for ParallelUpdate. More...
 
using Vertex = SoftBodyVertex
 
using Edge = SoftBodySharedSettings::Edge
 
using Face = SoftBodySharedSettings::Face
 
using DihedralBend = SoftBodySharedSettings::DihedralBend
 
using Volume = SoftBodySharedSettings::Volume
 
using InvBind = SoftBodySharedSettings::InvBind
 
using SkinWeight = SoftBodySharedSettings::SkinWeight
 
using Skinned = SoftBodySharedSettings::Skinned
 
using LRA = SoftBodySharedSettings::LRA
 

Public Member Functions

void Initialize (const SoftBodyCreationSettings &inSettings)
 Initialize the soft body motion properties.
 
const SoftBodySharedSettingsGetSettings () const
 Get the shared settings of the soft body.
 
const Array< Vertex > & GetVertices () const
 Get the vertices of the soft body.
 
Array< Vertex > & GetVertices ()
 
const VertexGetVertex (uint inIndex) const
 Access an individual vertex.
 
VertexGetVertex (uint inIndex)
 
const PhysicsMaterialListGetMaterials () const
 Get the materials of the soft body.
 
const Array< Face > & GetFaces () const
 Get the faces of the soft body.
 
const FaceGetFace (uint inIndex) const
 Access to an individual face.
 
uint32 GetNumIterations () const
 Get the number of solver iterations.
 
void SetNumIterations (uint32 inNumIterations)
 
float GetPressure () const
 Get the pressure of the soft body.
 
void SetPressure (float inPressure)
 
bool GetUpdatePosition () const
 Update the position of the body while simulating (set to false for something that is attached to the static world)
 
void SetUpdatePosition (bool inUpdatePosition)
 
bool GetEnableSkinConstraints () const
 Global setting to turn on/off skin constraints.
 
void SetEnableSkinConstraints (bool inEnableSkinConstraints)
 
float GetSkinnedMaxDistanceMultiplier () const
 Multiplier applied to Skinned::mMaxDistance to allow tightening or loosening of the skin constraints. 0 to hard skin all vertices.
 
void SetSkinnedMaxDistanceMultiplier (float inSkinnedMaxDistanceMultiplier)
 
const AABoxGetLocalBounds () const
 Get local bounding box.
 
float GetVolume () const
 Get the volume of the soft body. Note can become negative if the shape is inside out!
 
void CalculateMassAndInertia ()
 Calculate the total mass and inertia of this body based on the current state of the vertices.
 
void DrawVertices (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform) const
 Draw the state of a soft body.
 
void DrawVertexVelocities (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform) const
 
void DrawEdgeConstraints (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, ESoftBodyConstraintColor inConstraintColor) const
 
void DrawBendConstraints (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, ESoftBodyConstraintColor inConstraintColor) const
 
void DrawVolumeConstraints (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, ESoftBodyConstraintColor inConstraintColor) const
 
void DrawSkinConstraints (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, ESoftBodyConstraintColor inConstraintColor) const
 
void DrawLRAConstraints (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, ESoftBodyConstraintColor inConstraintColor) const
 
void DrawPredictedBounds (DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform) const
 
void SaveState (StateRecorder &inStream) const
 Saving state for replay.
 
void RestoreState (StateRecorder &inStream)
 Restoring state for replay.
 
void SkinVertices (RMat44Arg inCenterOfMassTransform, const Mat44 *inJointMatrices, uint inNumJoints, bool inHardSkinAll, TempAllocator &ioTempAllocator)
 
void CustomUpdate (float inDeltaTime, Body &ioSoftBody, PhysicsSystem &inSystem)
 
void InitializeUpdateContext (float inDeltaTime, Body &inSoftBody, const PhysicsSystem &inSystem, SoftBodyUpdateContext &ioContext)
 Initialize the update context. Not part of the public API.
 
void DetermineCollidingShapes (const SoftBodyUpdateContext &inContext, const PhysicsSystem &inSystem, const BodyLockInterface &inBodyLockInterface)
 Do a broad phase check and collect all bodies that can possibly collide with this soft body. Not part of the public API.
 
EStatus ParallelUpdate (SoftBodyUpdateContext &ioContext, const PhysicsSettings &inPhysicsSettings)
 Update the soft body, will process a batch of work. Not part of the public API.
 
void UpdateRigidBodyVelocities (const SoftBodyUpdateContext &inContext, BodyInterface &inBodyInterface)
 Update the velocities of all rigid bodies that we collided with. Not part of the public API.
 
- Public Member Functions inherited from MotionProperties
JPH_OVERRIDE_NEW_DELETE EMotionQuality GetMotionQuality () const
 Motion quality, or how well it detects collisions when it has a high velocity.
 
EAllowedDOFs GetAllowedDOFs () const
 Get the allowed degrees of freedom that this body has (this can be changed by calling SetMassProperties)
 
bool GetAllowSleeping () const
 If this body can go to sleep.
 
Vec3 GetLinearVelocity () const
 Get world space linear velocity of the center of mass.
 
void SetLinearVelocity (Vec3Arg inLinearVelocity)
 Set world space linear velocity of the center of mass.
 
void SetLinearVelocityClamped (Vec3Arg inLinearVelocity)
 Set world space linear velocity of the center of mass, will make sure the value is clamped against the maximum linear velocity.
 
Vec3 GetAngularVelocity () const
 Get world space angular velocity of the center of mass.
 
void SetAngularVelocity (Vec3Arg inAngularVelocity)
 Set world space angular velocity of the center of mass.
 
void SetAngularVelocityClamped (Vec3Arg inAngularVelocity)
 Set world space angular velocity of the center of mass, will make sure the value is clamped against the maximum angular velocity.
 
void MoveKinematic (Vec3Arg inDeltaPosition, QuatArg inDeltaRotation, float inDeltaTime)
 Set velocity of body such that it will be rotate/translate by inDeltaPosition/Rotation in inDeltaTime seconds.
 
void ClampLinearVelocity ()
 Clamp velocity according to limit.
 
void ClampAngularVelocity ()
 
float GetLinearDamping () const
 Get linear damping: dv/dt = -c * v. c must be between 0 and 1 but is usually close to 0.
 
void SetLinearDamping (float inLinearDamping)
 
float GetAngularDamping () const
 Get angular damping: dw/dt = -c * w. c must be between 0 and 1 but is usually close to 0.
 
void SetAngularDamping (float inAngularDamping)
 
float GetGravityFactor () const
 Get gravity factor (1 = normal gravity, 0 = no gravity)
 
void SetGravityFactor (float inGravityFactor)
 
void SetMassProperties (EAllowedDOFs inAllowedDOFs, const MassProperties &inMassProperties)
 Set the mass and inertia tensor.
 
float GetInverseMass () const
 Get inverse mass (1 / mass). Should only be called on a dynamic object (static or kinematic bodies have infinite mass so should be treated as 1 / mass = 0)
 
float GetInverseMassUnchecked () const
 
void SetInverseMass (float inInverseMass)
 
Vec3 GetInverseInertiaDiagonal () const
 Diagonal of inverse inertia matrix: D. Should only be called on a dynamic object (static or kinematic bodies have infinite mass so should be treated as D = 0)
 
Quat GetInertiaRotation () const
 Rotation (R) that takes inverse inertia diagonal to local space: \(I_{body}^{-1} = R \: D \: R^{-1}\).
 
void SetInverseInertia (Vec3Arg inDiagonal, QuatArg inRot)
 
void ScaleToMass (float inMass)
 
Mat44 GetLocalSpaceInverseInertia () const
 Get inverse inertia matrix ( \(I_{body}^{-1}\)). Will be a matrix of zeros for a static or kinematic object.
 
Mat44 GetLocalSpaceInverseInertiaUnchecked () const
 Same as GetLocalSpaceInverseInertia() but doesn't check if the body is dynamic.
 
Mat44 GetInverseInertiaForRotation (Mat44Arg inRotation) const
 Get inverse inertia matrix ( \(I^{-1}\)) for a given object rotation (translation will be ignored). Zero if object is static or kinematic.
 
JPH_INLINE Vec3 MultiplyWorldSpaceInverseInertiaByVector (QuatArg inBodyRotation, Vec3Arg inV) const
 Multiply a vector with the inverse world space inertia tensor ( \(I_{world}^{-1}\)). Zero if object is static or kinematic.
 
JPH_INLINE Vec3 GetPointVelocityCOM (Vec3Arg inPointRelativeToCOM) const
 Velocity of point inPoint (in center of mass space, e.g. on the surface of the body) of the body (unit: m/s)
 
JPH_INLINE Vec3 GetAccumulatedForce () const
 
JPH_INLINE Vec3 GetAccumulatedTorque () const
 
JPH_INLINE void ResetForce ()
 
JPH_INLINE void ResetTorque ()
 
JPH_INLINE void ResetMotion ()
 
JPH_INLINE UVec4 GetLinearDOFsMask () const
 Returns a vector where the linear components that are not allowed by mAllowedDOFs are set to 0 and the rest to 0xffffffff.
 
JPH_INLINE Vec3 LockTranslation (Vec3Arg inV) const
 Takes a translation vector inV and returns a vector where the components that are not allowed by mAllowedDOFs are set to 0.
 
JPH_INLINE UVec4 GetAngularDOFsMask () const
 Returns a vector where the angular components that are not allowed by mAllowedDOFs are set to 0 and the rest to 0xffffffff.
 
JPH_INLINE Vec3 LockAngular (Vec3Arg inV) const
 Takes an angular velocity / torque vector inV and returns a vector where the components that are not allowed by mAllowedDOFs are set to 0.
 
void SetNumVelocityStepsOverride (uint inN)
 Used only when this body is dynamic and colliding. Override for the number of solver velocity iterations to run, 0 means use the default in PhysicsSettings::mNumVelocitySteps. The number of iterations to use is the max of all contacts and constraints in the island.
 
uint GetNumVelocityStepsOverride () const
 
void SetNumPositionStepsOverride (uint inN)
 Used only when this body is dynamic and colliding. Override for the number of solver position iterations to run, 0 means use the default in PhysicsSettings::mNumPositionSteps. The number of iterations to use is the max of all contacts and constraints in the island.
 
uint GetNumPositionStepsOverride () const
 
void ApplyGyroscopicForceInternal (QuatArg inBodyRotation, float inDeltaTime)
 Apply the gyroscopic force (aka Dzhanibekov effect, see https://en.wikipedia.org/wiki/Tennis_racket_theorem)
 
void ApplyForceTorqueAndDragInternal (QuatArg inBodyRotation, Vec3Arg inGravity, float inDeltaTime)
 Apply all accumulated forces, torques and drag (should only be called by the PhysicsSystem)
 
uint32 GetIslandIndexInternal () const
 Access to the island index.
 
void SetIslandIndexInternal (uint32 inIndex)
 
uint32 GetIndexInActiveBodiesInternal () const
 Access to the index in the active bodies array.
 
void ResetSleepTestSpheres (const RVec3 *inPoints)
 Reset spheres to center around inPoints with radius 0.
 
void ResetSleepTestTimer ()
 Reset the sleep test timer without resetting the sleep test spheres.
 
ECanSleep AccumulateSleepTime (float inDeltaTime, float inTimeBeforeSleep)
 Accumulate sleep time and return if a body can go to sleep.
 
void SaveState (StateRecorder &inStream) const
 Saving state for replay.
 
void RestoreState (StateRecorder &inStream)
 Restoring state for replay.
 
float GetMaxLinearVelocity () const
 Maximum linear velocity that a body can achieve. Used to prevent the system from exploding.
 
void SetMaxLinearVelocity (float inLinearVelocity)
 
float GetMaxAngularVelocity () const
 Maximum angular velocity that a body can achieve. Used to prevent the system from exploding.
 
void SetMaxAngularVelocity (float inAngularVelocity)
 
void AddLinearVelocityStep (Vec3Arg inLinearVelocityChange)
 
void SubLinearVelocityStep (Vec3Arg inLinearVelocityChange)
 
void AddAngularVelocityStep (Vec3Arg inAngularVelocityChange)
 
void SubAngularVelocityStep (Vec3Arg inAngularVelocityChange)
 

Friends

class SoftBodyManifold
 

Additional Inherited Members

- Static Public Attributes inherited from MotionProperties
static constexpr uint32 cInactiveIndex = uint32(-1)
 Constant indicating that body is not active.
 

Detailed Description

This class contains the runtime information of a soft body.

Member Typedef Documentation

◆ DihedralBend

◆ Edge

◆ Face

◆ InvBind

◆ LRA

◆ Skinned

◆ SkinWeight

◆ Vertex

◆ Volume

Member Enumeration Documentation

◆ EStatus

Return code for ParallelUpdate.

Enumerator
NoWork 

No work was done because other threads were still working on a batch that cannot run concurrently.

DidWork 

Work was done to progress the update.

Done 

All work is done.

Member Function Documentation

◆ CalculateMassAndInertia()

void SoftBodyMotionProperties::CalculateMassAndInertia ( )

Calculate the total mass and inertia of this body based on the current state of the vertices.

◆ CustomUpdate()

void SoftBodyMotionProperties::CustomUpdate ( float  inDeltaTime,
Body ioSoftBody,
PhysicsSystem inSystem 
)

This function allows you to update the soft body immediately without going through the PhysicsSystem. This is useful if the soft body is teleported and needs to 'settle' or it can be used if a the soft body is not added to the PhysicsSystem and needs to be updated manually. One reason for not adding it to the PhysicsSystem is that you might want to update a soft body immediately after updating an animated object that has the soft body attached to it. If the soft body is added to the PhysicsSystem it will be updated by it, so calling this function will effectively update it twice. Note that when you use this function, only the current thread will be used, whereas if you update through the PhysicsSystem, multiple threads may be used. Note that this will bypass any sleep checks. Since the dynamic objects that the soft body touches will not move during this call, there can be simulation artifacts if you call this function multiple times without running the physics simulation step.

◆ DetermineCollidingShapes()

void SoftBodyMotionProperties::DetermineCollidingShapes ( const SoftBodyUpdateContext inContext,
const PhysicsSystem inSystem,
const BodyLockInterface inBodyLockInterface 
)

Do a broad phase check and collect all bodies that can possibly collide with this soft body. Not part of the public API.

◆ DrawBendConstraints()

void SoftBodyMotionProperties::DrawBendConstraints ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform,
ESoftBodyConstraintColor  inConstraintColor 
) const

◆ DrawEdgeConstraints()

void SoftBodyMotionProperties::DrawEdgeConstraints ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform,
ESoftBodyConstraintColor  inConstraintColor 
) const

◆ DrawLRAConstraints()

void SoftBodyMotionProperties::DrawLRAConstraints ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform,
ESoftBodyConstraintColor  inConstraintColor 
) const

◆ DrawPredictedBounds()

void SoftBodyMotionProperties::DrawPredictedBounds ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform 
) const

◆ DrawSkinConstraints()

void SoftBodyMotionProperties::DrawSkinConstraints ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform,
ESoftBodyConstraintColor  inConstraintColor 
) const

◆ DrawVertexVelocities()

void SoftBodyMotionProperties::DrawVertexVelocities ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform 
) const

◆ DrawVertices()

void SoftBodyMotionProperties::DrawVertices ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform 
) const

Draw the state of a soft body.

◆ DrawVolumeConstraints()

void SoftBodyMotionProperties::DrawVolumeConstraints ( DebugRenderer inRenderer,
RMat44Arg  inCenterOfMassTransform,
ESoftBodyConstraintColor  inConstraintColor 
) const

◆ GetEnableSkinConstraints()

bool SoftBodyMotionProperties::GetEnableSkinConstraints ( ) const
inline

Global setting to turn on/off skin constraints.

◆ GetFace()

const Face & SoftBodyMotionProperties::GetFace ( uint  inIndex) const
inline

Access to an individual face.

◆ GetFaces()

const Array< Face > & SoftBodyMotionProperties::GetFaces ( ) const
inline

Get the faces of the soft body.

◆ GetLocalBounds()

const AABox & SoftBodyMotionProperties::GetLocalBounds ( ) const
inline

Get local bounding box.

◆ GetMaterials()

const PhysicsMaterialList & SoftBodyMotionProperties::GetMaterials ( ) const
inline

Get the materials of the soft body.

◆ GetNumIterations()

uint32 SoftBodyMotionProperties::GetNumIterations ( ) const
inline

Get the number of solver iterations.

◆ GetPressure()

float SoftBodyMotionProperties::GetPressure ( ) const
inline

Get the pressure of the soft body.

◆ GetSettings()

const SoftBodySharedSettings * SoftBodyMotionProperties::GetSettings ( ) const
inline

Get the shared settings of the soft body.

◆ GetSkinnedMaxDistanceMultiplier()

float SoftBodyMotionProperties::GetSkinnedMaxDistanceMultiplier ( ) const
inline

Multiplier applied to Skinned::mMaxDistance to allow tightening or loosening of the skin constraints. 0 to hard skin all vertices.

◆ GetUpdatePosition()

bool SoftBodyMotionProperties::GetUpdatePosition ( ) const
inline

Update the position of the body while simulating (set to false for something that is attached to the static world)

◆ GetVertex() [1/2]

Vertex & SoftBodyMotionProperties::GetVertex ( uint  inIndex)
inline

◆ GetVertex() [2/2]

const Vertex & SoftBodyMotionProperties::GetVertex ( uint  inIndex) const
inline

Access an individual vertex.

◆ GetVertices() [1/2]

Array< Vertex > & SoftBodyMotionProperties::GetVertices ( )
inline

◆ GetVertices() [2/2]

const Array< Vertex > & SoftBodyMotionProperties::GetVertices ( ) const
inline

Get the vertices of the soft body.

◆ GetVolume()

float SoftBodyMotionProperties::GetVolume ( ) const
inline

Get the volume of the soft body. Note can become negative if the shape is inside out!

◆ Initialize()

void SoftBodyMotionProperties::Initialize ( const SoftBodyCreationSettings inSettings)

Initialize the soft body motion properties.

◆ InitializeUpdateContext()

void SoftBodyMotionProperties::InitializeUpdateContext ( float  inDeltaTime,
Body inSoftBody,
const PhysicsSystem inSystem,
SoftBodyUpdateContext ioContext 
)

Initialize the update context. Not part of the public API.

◆ ParallelUpdate()

SoftBodyMotionProperties::EStatus SoftBodyMotionProperties::ParallelUpdate ( SoftBodyUpdateContext ioContext,
const PhysicsSettings inPhysicsSettings 
)

Update the soft body, will process a batch of work. Not part of the public API.

◆ RestoreState()

void SoftBodyMotionProperties::RestoreState ( StateRecorder inStream)

Restoring state for replay.

◆ SaveState()

void SoftBodyMotionProperties::SaveState ( StateRecorder inStream) const

Saving state for replay.

◆ SetEnableSkinConstraints()

void SoftBodyMotionProperties::SetEnableSkinConstraints ( bool  inEnableSkinConstraints)
inline

◆ SetNumIterations()

void SoftBodyMotionProperties::SetNumIterations ( uint32  inNumIterations)
inline

◆ SetPressure()

void SoftBodyMotionProperties::SetPressure ( float  inPressure)
inline

◆ SetSkinnedMaxDistanceMultiplier()

void SoftBodyMotionProperties::SetSkinnedMaxDistanceMultiplier ( float  inSkinnedMaxDistanceMultiplier)
inline

◆ SetUpdatePosition()

void SoftBodyMotionProperties::SetUpdatePosition ( bool  inUpdatePosition)
inline

◆ SkinVertices()

void SoftBodyMotionProperties::SkinVertices ( RMat44Arg  inCenterOfMassTransform,
const Mat44 inJointMatrices,
uint  inNumJoints,
bool  inHardSkinAll,
TempAllocator ioTempAllocator 
)

Skin vertices to supplied joints, information is used by the skinned constraints.

Parameters
inCenterOfMassTransformValue of Body::GetCenterOfMassTransform().
inJointMatricesThe joint matrices must be expressed relative to inCenterOfMassTransform.
inNumJointsIndicates how large the inJointMatrices array is (used only for validating out of bounds).
inHardSkinAllCan be used to position all vertices on the skinned vertices and can be used to hard reset the soft body.
ioTempAllocatorAllocator.

◆ UpdateRigidBodyVelocities()

void SoftBodyMotionProperties::UpdateRigidBodyVelocities ( const SoftBodyUpdateContext inContext,
BodyInterface inBodyInterface 
)

Update the velocities of all rigid bodies that we collided with. Not part of the public API.

Friends And Related Symbol Documentation

◆ SoftBodyManifold

friend class SoftBodyManifold
friend

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