Jolt Physics
A multi core friendly Game Physics Engine
|
Contains the structure of a ragdoll. More...
#include <Ragdoll.h>
Classes | |
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> |
List of ragdoll parts. | |
Public Member Functions | |
bool | Stabilize () |
void | DisableParentChildCollisions (const Mat44 *inJointMatrices=nullptr, float inMinSeparationDistance=0.0f) |
void | SaveBinaryState (StreamOut &inStream, bool inSaveShapes, bool inSaveGroupFilter) const |
Ragdoll * | CreateRagdoll (CollisionGroup::GroupID inCollisionGroup, uint64 inUserData, PhysicsSystem *inSystem) const |
const Skeleton * | GetSkeleton () const |
Access to the skeleton of this ragdoll. | |
Skeleton * | GetSkeleton () |
void | CalculateBodyIndexToConstraintIndex () |
Calculate the map needed for GetBodyIndexToConstraintIndex() | |
const Array< int > & | GetBodyIndexToConstraintIndex () const |
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. | |
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 |
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 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< Skeleton > | mSkeleton |
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()) | |
Additional Inherited Members | |
Protected Attributes inherited from RefTarget< RagdollSettings > | |
atomic< uint32 > | mRefCount |
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. | |
Contains the structure of a ragdoll.
using RagdollSettings::BodyIdxPair = pair<int, int> |
using RagdollSettings::PartVector = Array<Part> |
List of ragdoll parts.
The constraint that connects this part to its parent part (should be null for the root)
void RagdollSettings::CalculateBodyIndexToConstraintIndex | ( | ) |
Calculate the map needed for GetBodyIndexToConstraintIndex()
void RagdollSettings::CalculateConstraintIndexToBodyIdxPair | ( | ) |
Calculate the map needed for GetConstraintIndexToBodyIdxPair()
Ragdoll * RagdollSettings::CreateRagdoll | ( | CollisionGroup::GroupID | inCollisionGroup, |
uint64 | inUserData, | ||
PhysicsSystem * | inSystem ) const |
Create ragdoll instance from these settings
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:
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.
|
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.
|
inline |
Map a single constraint index (index in mConstraints) to the indices of the bodies that the constraint is connected to (index in mBodyIDs)
|
inline |
Map a single body index to a constraint index.
|
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)
|
inline |
|
inline |
Access to the skeleton of this ragdoll.
void RagdollSettings::SaveBinaryState | ( | StreamOut & | inStream, |
bool | inSaveShapes, | ||
bool | inSaveGroupFilter ) const |
Saves the state of this object in binary form to inStream.
inStream | The stream to save the state to |
inSaveShapes | If 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) |
inSaveGroupFilter | If the group filter should be saved as well (these could be shared) |
|
static |
Restore a saved ragdoll from inStream.
bool RagdollSettings::Stabilize | ( | ) |
Stabilize the constraints of the ragdoll
PartVector RagdollSettings::mParts |
For each of the joints, the body and constraint attaching it to its parent body (1-on-1 with mSkeleton.GetJoints())