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

Contains the structure of a ragdoll. More...

#include <Ragdoll.h>

Inheritance diagram for RagdollSettings:
RefTarget< RagdollSettings >

Classes

class  AdditionalConstraint
 A constraint that connects two bodies in a ragdoll (for non parent child related constraints) More...
 
class  Part
 A single rigid body sub part of the ragdoll. More...
 

Public Types

using RagdollResult = Result< Ref< RagdollSettings > >
 
using BodyIdxPair = pair< int, int >
 
using PartVector = Array< Part >
 The constraint that connects this part to its parent part (should be null for the root)
 
using AdditionalConstraintVector = Array< AdditionalConstraint >
 List of additional constraints.
 

Public Member Functions

bool Stabilize ()
 
void DisableParentChildCollisions (const Mat44 *inJointMatrices=nullptr, float inMinSeparationDistance=0.0f)
 
void SaveBinaryState (StreamOut &inStream, bool inSaveShapes, bool inSaveGroupFilter) const
 
RagdollCreateRagdoll (CollisionGroup::GroupID inCollisionGroup, uint64 inUserData, PhysicsSystem *inSystem) const
 
const SkeletonGetSkeleton () const
 Access to the skeleton of this ragdoll.
 
SkeletonGetSkeleton ()
 
void CalculateBodyIndexToConstraintIndex ()
 Calculate the map needed for GetBodyIndexToConstraintIndex()
 
const Array< int > & GetBodyIndexToConstraintIndex () const
 
int GetConstraintIndexForBodyIndex (int inBodyIndex) const
 Map a single body index to a constraint index.
 
void CalculateConstraintIndexToBodyIdxPair ()
 Calculate the map needed for GetConstraintIndexToBodyIdxPair()
 
const Array< BodyIdxPair > & GetConstraintIndexToBodyIdxPair () const
 Table that maps a constraint index (index in mConstraints) to the indices of the bodies that the constraint is connected to (index in mBodyIDs)
 
BodyIdxPair GetBodyIndicesForConstraintIndex (int inConstraintIndex) const
 Map a single constraint index (index in mConstraints) to the indices of the bodies that the constraint is connected to (index in mBodyIDs)
 
- Public Member Functions inherited from RefTarget< RagdollSettings >
 RefTarget ()=default
 Constructor.
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us
 
void SetEmbedded () const
 
RefTargetoperator= (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 RagdollResult sRestoreFromBinaryState (StreamIn &inStream)
 Restore a saved ragdoll from inStream.
 
- Static Public Member Functions inherited from RefTarget< RagdollSettings >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 

Public Attributes

Ref< SkeletonmSkeleton
 The skeleton for this ragdoll.
 
PartVector mParts
 For each of the joints, the body and constraint attaching it to its parent body (1-on-1 with mSkeleton.GetJoints())
 
AdditionalConstraintVector mAdditionalConstraints
 A list of constraints that connects two bodies in a ragdoll (for non parent child related constraints)
 

Additional Inherited Members

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

Detailed Description

Contains the structure of a ragdoll.

Member Typedef Documentation

◆ AdditionalConstraintVector

◆ BodyIdxPair

using RagdollSettings::BodyIdxPair = pair<int, int>

◆ PartVector

The constraint that connects this part to its parent part (should be null for the root)

◆ RagdollResult

Member Function Documentation

◆ CalculateBodyIndexToConstraintIndex()

void RagdollSettings::CalculateBodyIndexToConstraintIndex ( )

Calculate the map needed for GetBodyIndexToConstraintIndex()

◆ CalculateConstraintIndexToBodyIdxPair()

void RagdollSettings::CalculateConstraintIndexToBodyIdxPair ( )

Calculate the map needed for GetConstraintIndexToBodyIdxPair()

◆ CreateRagdoll()

Ragdoll * RagdollSettings::CreateRagdoll ( CollisionGroup::GroupID  inCollisionGroup,
uint64  inUserData,
PhysicsSystem inSystem 
) const

Create ragdoll instance from these settings

Returns
Newly created ragdoll or null when out of bodies

◆ DisableParentChildCollisions()

void RagdollSettings::DisableParentChildCollisions ( const Mat44 inJointMatrices = nullptr,
float  inMinSeparationDistance = 0.0f 
)

After the ragdoll has been fully configured, call this function to automatically create and add a GroupFilterTable collision filter to all bodies and configure them so that parent and children don't collide.

This will:

  • Create a GroupFilterTable and assign it to all of the bodies in a ragdoll.
  • Each body in your ragdoll will get a SubGroupID that is equal to the joint index in the Skeleton that it is attached to.
  • Loop over all joints in the Skeleton and call GroupFilterTable::DisableCollision(joint index, parent joint index).
  • When a pose is provided through inJointMatrices the function will detect collisions between joints (they must be separated by more than inMinSeparationDistance to be treated as not colliding) and automatically disable collisions.

When you create an instance using Ragdoll::CreateRagdoll pass in a unique GroupID for each ragdoll (e.g. a simple counter), note that this number should be unique throughout the PhysicsSystem, so if you have different types of ragdolls they should not share the same GroupID.

◆ GetBodyIndexToConstraintIndex()

const Array< int > & RagdollSettings::GetBodyIndexToConstraintIndex ( ) const
inline

Get table that maps a body index to the constraint index with which it is connected to its parent. -1 if there is no constraint associated with the body. Note that this will only tell you which constraint connects the body to its parent, it will not look in the additional constraint list.

◆ GetBodyIndicesForConstraintIndex()

BodyIdxPair RagdollSettings::GetBodyIndicesForConstraintIndex ( int  inConstraintIndex) const
inline

Map a single constraint index (index in mConstraints) to the indices of the bodies that the constraint is connected to (index in mBodyIDs)

◆ GetConstraintIndexForBodyIndex()

int RagdollSettings::GetConstraintIndexForBodyIndex ( int  inBodyIndex) const
inline

Map a single body index to a constraint index.

◆ GetConstraintIndexToBodyIdxPair()

const Array< BodyIdxPair > & RagdollSettings::GetConstraintIndexToBodyIdxPair ( ) const
inline

Table that maps a constraint index (index in mConstraints) to the indices of the bodies that the constraint is connected to (index in mBodyIDs)

◆ GetSkeleton() [1/2]

Skeleton * RagdollSettings::GetSkeleton ( )
inline

◆ GetSkeleton() [2/2]

const Skeleton * RagdollSettings::GetSkeleton ( ) const
inline

Access to the skeleton of this ragdoll.

◆ SaveBinaryState()

void RagdollSettings::SaveBinaryState ( StreamOut inStream,
bool  inSaveShapes,
bool  inSaveGroupFilter 
) const

Saves the state of this object in binary form to inStream.

Parameters
inStreamThe stream to save the state to
inSaveShapesIf the shapes should be saved as well (these could be shared between ragdolls, in which case the calling application may want to write custom code to restore them)
inSaveGroupFilterIf the group filter should be saved as well (these could be shared)

◆ sRestoreFromBinaryState()

RagdollSettings::RagdollResult RagdollSettings::sRestoreFromBinaryState ( StreamIn inStream)
static

Restore a saved ragdoll from inStream.

◆ Stabilize()

bool RagdollSettings::Stabilize ( )

Stabilize the constraints of the ragdoll

Returns
True on success, false on failure.

Member Data Documentation

◆ mAdditionalConstraints

AdditionalConstraintVector RagdollSettings::mAdditionalConstraints

A list of constraints that connects two bodies in a ragdoll (for non parent child related constraints)

◆ mParts

PartVector RagdollSettings::mParts

For each of the joints, the body and constraint attaching it to its parent body (1-on-1 with mSkeleton.GetJoints())

◆ mSkeleton

Ref<Skeleton> RagdollSettings::mSkeleton

The skeleton for this ragdoll.


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