Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SixDOFConstraint Class Referencefinal

6 Degree Of Freedom Constraint. Allows control over each of the 6 degrees of freedom. More...

#include <SixDOFConstraint.h>

Inheritance diagram for SixDOFConstraint:
TwoBodyConstraint Constraint RefTarget< Constraint > NonCopyable

Public Types

using EAxis = SixDOFConstraintSettings::EAxis
 Get Axis from settings class.
 

Public Member Functions

 SixDOFConstraint (Body &inBody1, Body &inBody2, const SixDOFConstraintSettings &inSettings)
 Construct six DOF constraint.
 
virtual EConstraintSubType GetSubType () const override
 Generic interface of a constraint.
 
virtual void NotifyShapeChanged (const BodyID &inBodyID, Vec3Arg inDeltaCOM) override
 
virtual void SetupVelocityConstraint (float inDeltaTime) override
 
virtual void ResetWarmStart () override
 
virtual void WarmStartVelocityConstraint (float inWarmStartImpulseRatio) override
 
virtual bool SolveVelocityConstraint (float inDeltaTime) override
 
virtual bool SolvePositionConstraint (float inDeltaTime, float inBaumgarte) override
 
virtual void DrawConstraint (DebugRenderer *inRenderer) const override
 
virtual void DrawConstraintLimits (DebugRenderer *inRenderer) const override
 
virtual void SaveState (StateRecorder &inStream) const override
 Saving state for replay.
 
virtual void RestoreState (StateRecorder &inStream) override
 Restoring state for replay.
 
virtual Ref< ConstraintSettingsGetConstraintSettings () const override
 Debug function to convert a constraint to its settings, note that this will not save to which bodies the constraint is connected to.
 
virtual Mat44 GetConstraintToBody1Matrix () const override
 Calculates the transform that transforms from constraint space to body 1 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.
 
virtual Mat44 GetConstraintToBody2Matrix () const override
 Calculates the transform that transforms from constraint space to body 2 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.
 
void SetTranslationLimits (Vec3Arg inLimitMin, Vec3Arg inLimitMax)
 Update the translation limits for this constraint.
 
void SetRotationLimits (Vec3Arg inLimitMin, Vec3Arg inLimitMax)
 Update the rotational limits for this constraint.
 
float GetLimitsMin (EAxis inAxis) const
 Get constraint Limits.
 
float GetLimitsMax (EAxis inAxis) const
 
Vec3 GetTranslationLimitsMin () const
 
Vec3 GetTranslationLimitsMax () const
 
Vec3 GetRotationLimitsMin () const
 
Vec3 GetRotationLimitsMax () const
 
bool IsFixedAxis (EAxis inAxis) const
 Check which axis are fixed/free.
 
bool IsFreeAxis (EAxis inAxis) const
 
const SpringSettingsGetLimitsSpringSettings (EAxis inAxis) const
 Update the limits spring settings.
 
void SetLimitsSpringSettings (EAxis inAxis, const SpringSettings &inLimitsSpringSettings)
 
void SetMaxFriction (EAxis inAxis, float inFriction)
 Set the max friction for each axis.
 
float GetMaxFriction (EAxis inAxis) const
 
Quat GetRotationInConstraintSpace () const
 Get rotation of constraint in constraint space.
 
MotorSettingsGetMotorSettings (EAxis inAxis)
 Motor settings.
 
const MotorSettingsGetMotorSettings (EAxis inAxis) const
 
void SetMotorState (EAxis inAxis, EMotorState inState)
 
EMotorState GetMotorState (EAxis inAxis) const
 
Vec3 GetTargetVelocityCS () const
 Set the target velocity in body 1 constraint space.
 
void SetTargetVelocityCS (Vec3Arg inVelocity)
 
void SetTargetAngularVelocityCS (Vec3Arg inAngularVelocity)
 Set the target angular velocity in body 2 constraint space (!)
 
Vec3 GetTargetAngularVelocityCS () const
 
Vec3 GetTargetPositionCS () const
 Set the target position in body 1 constraint space.
 
void SetTargetPositionCS (Vec3Arg inPosition)
 
void SetTargetOrientationCS (QuatArg inOrientation)
 Set the target orientation in body 1 constraint space.
 
Quat GetTargetOrientationCS () const
 
void SetTargetOrientationBS (QuatArg inOrientation)
 
- Public Member Functions inherited from TwoBodyConstraint
JPH_OVERRIDE_NEW_DELETE TwoBodyConstraint (Body &inBody1, Body &inBody2, const TwoBodyConstraintSettings &inSettings)
 Constructor.
 
virtual EConstraintType GetType () const override
 Get the type of a constraint.
 
virtual bool IsActive () const override
 Solver interface.
 
virtual void DrawConstraintReferenceFrame (DebugRenderer *inRenderer) const override
 
BodyGetBody1 () const
 Access to the connected bodies.
 
BodyGetBody2 () const
 
virtual void BuildIslands (uint32 inConstraintIndex, IslandBuilder &ioBuilder, BodyManager &inBodyManager) override
 Link bodies that are connected by this constraint in the island builder.
 
virtual uint BuildIslandSplits (LargeIslandSplitter &ioSplitter) const override
 Link bodies that are connected by this constraint in the same split. Returns the split index.
 
- Public Member Functions inherited from Constraint
JPH_OVERRIDE_NEW_DELETE Constraint (const ConstraintSettings &inSettings)
 Constructor.
 
virtual ~Constraint ()=default
 Virtual destructor.
 
uint32 GetConstraintPriority () const
 
void SetConstraintPriority (uint32 inPriority)
 
void SetNumVelocityStepsOverride (uint inN)
 Used only when the constraint is active. 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 the constraint is active. 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 SetEnabled (bool inEnabled)
 
bool GetEnabled () const
 Test if a constraint is enabled.
 
uint64 GetUserData () const
 Access to the user data, can be used for anything by the application.
 
void SetUserData (uint64 inUserData)
 
float GetDrawConstraintSize () const
 Size of constraint when drawing it through the debug renderer.
 
void SetDrawConstraintSize (float inSize)
 
- Public Member Functions inherited from RefTarget< Constraint >
 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
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Get Lagrange multiplier from last physics update (the linear/angular impulse applied to satisfy the constraint)

Vec3 GetTotalLambdaPosition () const
 
Vec3 GetTotalLambdaRotation () const
 
Vec3 GetTotalLambdaMotorTranslation () const
 
Vec3 GetTotalLambdaMotorRotation () const
 

Additional Inherited Members

- Static Public Member Functions inherited from RefTarget< Constraint >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 
- Protected Member Functions inherited from Constraint
void ToConstraintSettings (ConstraintSettings &outSettings) const
 Helper function to copy settings back to constraint settings for this base class.
 
- Protected Attributes inherited from TwoBodyConstraint
BodymBody1
 The two bodies involved.
 
BodymBody2
 
- Protected Attributes inherited from Constraint
float mDrawConstraintSize
 Size of constraint when drawing it through the debug renderer.
 
- Protected Attributes inherited from RefTarget< Constraint >
atomic< uint32mRefCount
 Current reference count.
 
- Static Protected Attributes inherited from RefTarget< Constraint >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

6 Degree Of Freedom Constraint. Allows control over each of the 6 degrees of freedom.

Member Typedef Documentation

◆ EAxis

Get Axis from settings class.

Constructor & Destructor Documentation

◆ SixDOFConstraint()

SixDOFConstraint::SixDOFConstraint ( Body inBody1,
Body inBody2,
const SixDOFConstraintSettings inSettings 
)

Construct six DOF constraint.

Member Function Documentation

◆ DrawConstraint()

void SixDOFConstraint::DrawConstraint ( DebugRenderer inRenderer) const
overridevirtual

Implements Constraint.

◆ DrawConstraintLimits()

void SixDOFConstraint::DrawConstraintLimits ( DebugRenderer inRenderer) const
overridevirtual

Reimplemented from Constraint.

◆ GetConstraintSettings()

Ref< ConstraintSettings > SixDOFConstraint::GetConstraintSettings ( ) const
overridevirtual

Debug function to convert a constraint to its settings, note that this will not save to which bodies the constraint is connected to.

Implements Constraint.

◆ GetConstraintToBody1Matrix()

virtual Mat44 SixDOFConstraint::GetConstraintToBody1Matrix ( ) const
inlineoverridevirtual

Calculates the transform that transforms from constraint space to body 1 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.

Implements TwoBodyConstraint.

◆ GetConstraintToBody2Matrix()

virtual Mat44 SixDOFConstraint::GetConstraintToBody2Matrix ( ) const
inlineoverridevirtual

Calculates the transform that transforms from constraint space to body 2 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.

Implements TwoBodyConstraint.

◆ GetLimitsMax()

float SixDOFConstraint::GetLimitsMax ( EAxis  inAxis) const
inline

◆ GetLimitsMin()

float SixDOFConstraint::GetLimitsMin ( EAxis  inAxis) const
inline

Get constraint Limits.

◆ GetLimitsSpringSettings()

const SpringSettings & SixDOFConstraint::GetLimitsSpringSettings ( EAxis  inAxis) const
inline

Update the limits spring settings.

◆ GetMaxFriction()

float SixDOFConstraint::GetMaxFriction ( EAxis  inAxis) const
inline

◆ GetMotorSettings() [1/2]

MotorSettings & SixDOFConstraint::GetMotorSettings ( EAxis  inAxis)
inline

Motor settings.

◆ GetMotorSettings() [2/2]

const MotorSettings & SixDOFConstraint::GetMotorSettings ( EAxis  inAxis) const
inline

◆ GetMotorState()

EMotorState SixDOFConstraint::GetMotorState ( EAxis  inAxis) const
inline

◆ GetRotationInConstraintSpace()

Quat SixDOFConstraint::GetRotationInConstraintSpace ( ) const

Get rotation of constraint in constraint space.

◆ GetRotationLimitsMax()

Vec3 SixDOFConstraint::GetRotationLimitsMax ( ) const
inline

◆ GetRotationLimitsMin()

Vec3 SixDOFConstraint::GetRotationLimitsMin ( ) const
inline

◆ GetSubType()

virtual EConstraintSubType SixDOFConstraint::GetSubType ( ) const
inlineoverridevirtual

Generic interface of a constraint.

Implements Constraint.

◆ GetTargetAngularVelocityCS()

Vec3 SixDOFConstraint::GetTargetAngularVelocityCS ( ) const
inline

◆ GetTargetOrientationCS()

Quat SixDOFConstraint::GetTargetOrientationCS ( ) const
inline

◆ GetTargetPositionCS()

Vec3 SixDOFConstraint::GetTargetPositionCS ( ) const
inline

Set the target position in body 1 constraint space.

◆ GetTargetVelocityCS()

Vec3 SixDOFConstraint::GetTargetVelocityCS ( ) const
inline

Set the target velocity in body 1 constraint space.

◆ GetTotalLambdaMotorRotation()

Vec3 SixDOFConstraint::GetTotalLambdaMotorRotation ( ) const
inline

◆ GetTotalLambdaMotorTranslation()

Vec3 SixDOFConstraint::GetTotalLambdaMotorTranslation ( ) const
inline

◆ GetTotalLambdaPosition()

Vec3 SixDOFConstraint::GetTotalLambdaPosition ( ) const
inline

◆ GetTotalLambdaRotation()

Vec3 SixDOFConstraint::GetTotalLambdaRotation ( ) const
inline

◆ GetTranslationLimitsMax()

Vec3 SixDOFConstraint::GetTranslationLimitsMax ( ) const
inline

◆ GetTranslationLimitsMin()

Vec3 SixDOFConstraint::GetTranslationLimitsMin ( ) const
inline

◆ IsFixedAxis()

bool SixDOFConstraint::IsFixedAxis ( EAxis  inAxis) const
inline

Check which axis are fixed/free.

◆ IsFreeAxis()

bool SixDOFConstraint::IsFreeAxis ( EAxis  inAxis) const
inline

◆ NotifyShapeChanged()

void SixDOFConstraint::NotifyShapeChanged ( const BodyID inBodyID,
Vec3Arg  inDeltaCOM 
)
overridevirtual

Notify the constraint that the shape of a body has changed and that its center of mass has moved by inDeltaCOM. Bodies don't know which constraints are connected to them so the user is responsible for notifying the relevant constraints when a body changes.

Parameters
inBodyIDID of the body that has changed
inDeltaCOMThe delta of the center of mass of the body (shape->GetCenterOfMass() - shape_before_change->GetCenterOfMass())

Implements Constraint.

◆ ResetWarmStart()

void SixDOFConstraint::ResetWarmStart ( )
overridevirtual

Notify the system that the configuration of the bodies and/or constraint has changed enough so that the warm start impulses should not be applied the next frame. You can use this function for example when repositioning a ragdoll through Ragdoll::SetPose in such a way that the orientation of the bodies completely changes so that the previous frame impulses are no longer a good approximation of what the impulses will be in the next frame. Calling this function when there are no big changes will result in the constraints being much 'softer' than usual so they are more easily violated (e.g. a long chain of bodies might sag a bit if you call this every frame).

Implements Constraint.

◆ RestoreState()

void SixDOFConstraint::RestoreState ( StateRecorder inStream)
overridevirtual

Restoring state for replay.

Reimplemented from Constraint.

◆ SaveState()

void SixDOFConstraint::SaveState ( StateRecorder inStream) const
overridevirtual

Saving state for replay.

Reimplemented from Constraint.

◆ SetLimitsSpringSettings()

void SixDOFConstraint::SetLimitsSpringSettings ( EAxis  inAxis,
const SpringSettings inLimitsSpringSettings 
)
inline

◆ SetMaxFriction()

void SixDOFConstraint::SetMaxFriction ( EAxis  inAxis,
float  inFriction 
)

Set the max friction for each axis.

◆ SetMotorState()

void SixDOFConstraint::SetMotorState ( EAxis  inAxis,
EMotorState  inState 
)

Motor controls. Translation motors work in constraint space of body 1. Rotation motors work in constraint space of body 2 (!).

◆ SetRotationLimits()

void SixDOFConstraint::SetRotationLimits ( Vec3Arg  inLimitMin,
Vec3Arg  inLimitMax 
)

Update the rotational limits for this constraint.

◆ SetTargetAngularVelocityCS()

void SixDOFConstraint::SetTargetAngularVelocityCS ( Vec3Arg  inAngularVelocity)
inline

Set the target angular velocity in body 2 constraint space (!)

◆ SetTargetOrientationBS()

void SixDOFConstraint::SetTargetOrientationBS ( QuatArg  inOrientation)
inline

Set the target orientation in body space (R2 = R1 * inOrientation, where R1 and R2 are the world space rotations for body 1 and 2). Solve: R2 * ConstraintToBody2 = R1 * ConstraintToBody1 * q (see SwingTwistConstraint::GetSwingTwist) and R2 = R1 * inOrientation for q.

◆ SetTargetOrientationCS()

void SixDOFConstraint::SetTargetOrientationCS ( QuatArg  inOrientation)

Set the target orientation in body 1 constraint space.

◆ SetTargetPositionCS()

void SixDOFConstraint::SetTargetPositionCS ( Vec3Arg  inPosition)
inline

◆ SetTargetVelocityCS()

void SixDOFConstraint::SetTargetVelocityCS ( Vec3Arg  inVelocity)
inline

◆ SetTranslationLimits()

void SixDOFConstraint::SetTranslationLimits ( Vec3Arg  inLimitMin,
Vec3Arg  inLimitMax 
)

Update the translation limits for this constraint.

◆ SetupVelocityConstraint()

void SixDOFConstraint::SetupVelocityConstraint ( float  inDeltaTime)
overridevirtual

Implements Constraint.

◆ SolvePositionConstraint()

bool SixDOFConstraint::SolvePositionConstraint ( float  inDeltaTime,
float  inBaumgarte 
)
overridevirtual

Implements Constraint.

◆ SolveVelocityConstraint()

bool SixDOFConstraint::SolveVelocityConstraint ( float  inDeltaTime)
overridevirtual

Implements Constraint.

◆ WarmStartVelocityConstraint()

void SixDOFConstraint::WarmStartVelocityConstraint ( float  inWarmStartImpulseRatio)
overridevirtual

Implements Constraint.


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