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

Path constraint, used to constrain the degrees of freedom between two bodies to a path. More...

#include <PathConstraint.h>

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

Public Member Functions

JPH_OVERRIDE_NEW_DELETE PathConstraint (Body &inBody1, Body &inBody2, const PathConstraintSettings &inSettings)
 Construct point constraint. More...
 
virtual EConstraintSubType GetSubType () const override
 Get the sub type of a constraint. More...
 
virtual void NotifyShapeChanged (const BodyID &inBodyID, Vec3Arg inDeltaCOM) override
 
virtual void SetupVelocityConstraint (float inDeltaTime) 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 SaveState (StateRecorder &inStream) const override
 Saving state for replay. More...
 
virtual void RestoreState (StateRecorder &inStream) override
 Restoring state for replay. More...
 
virtual bool IsActive () const override
 Solver interface. More...
 
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. More...
 
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. More...
 
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. More...
 
void SetPath (const PathConstraintPath *inPath, float inPathFraction)
 Update the path for this constraint. More...
 
const PathConstraintPathGetPath () const
 Access to the current path. More...
 
float GetPathFraction () const
 Access to the current fraction along the path e [0, GetPath()->GetMaxPathFraction()]. More...
 
void SetMaxFrictionForce (float inFrictionForce)
 Friction control. More...
 
float GetMaxFrictionForce () const
 
MotorSettingsGetPositionMotorSettings ()
 Position motor settings. More...
 
const MotorSettingsGetPositionMotorSettings () const
 
void SetPositionMotorState (EMotorState inState)
 
EMotorState GetPositionMotorState () const
 
void SetTargetVelocity (float inVelocity)
 
float GetTargetVelocity () const
 
void SetTargetPathFraction (float inFraction)
 
float GetTargetPathFraction () const
 
- Public Member Functions inherited from TwoBodyConstraint
JPH_OVERRIDE_NEW_DELETE TwoBodyConstraint (Body &inBody1, Body &inBody2, const TwoBodyConstraintSettings &inSettings)
 Constructor. More...
 
virtual EConstraintType GetType () const override
 Get the type of a constraint. More...
 
virtual bool IsActive () const override
 Solver interface. More...
 
virtual void DrawConstraintReferenceFrame (DebugRenderer *inRenderer) const override
 
BodyGetBody1 () const
 Access to the connected bodies. More...
 
BodyGetBody2 () const
 
virtual Mat44 GetConstraintToBody1Matrix () const =0
 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. More...
 
virtual Mat44 GetConstraintToBody2Matrix () const =0
 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. More...
 
virtual void BuildIslands (uint32 inConstraintIndex, IslandBuilder &ioBuilder, BodyManager &inBodyManager) override
 Link bodies that are connected by this constraint in the island builder. More...
 
virtual uint BuildIslandSplits (LargeIslandSplitter &ioSplitter) const override
 Link bodies that are connected by this constraint in the same split. Returns the split index. More...
 
- Public Member Functions inherited from Constraint
JPH_OVERRIDE_NEW_DELETE Constraint (const ConstraintSettings &inSettings)
 Constructor. More...
 
virtual ~Constraint ()=default
 Virtual destructor. More...
 
virtual EConstraintType GetType () const
 Get the type of a constraint. More...
 
virtual EConstraintSubType GetSubType () const =0
 Get the sub type of a constraint. More...
 
uint32 GetConstraintPriority () const
 
void SetConstraintPriority (uint32 inPriority)
 
void SetNumVelocityStepsOverride (int inN)
 Override for the number of solver velocity iterations to run, the total amount of iterations is the max of PhysicsSettings::mNumVelocitySteps and this for all constraints in the island. More...
 
int GetNumVelocityStepsOverride () const
 
void SetNumPositionStepsOverride (int inN)
 Override for the number of position velocity iterations to run, the total amount of iterations is the max of PhysicsSettings::mNumPositionSteps and this for all constraints in the island. More...
 
int GetNumPositionStepsOverride () const
 
void SetEnabled (bool inEnabled)
 
bool GetEnabled () const
 Test if a constraint is enabled. More...
 
uint64 GetUserData () const
 Access to the user data, can be used for anything by the application. More...
 
void SetUserData (uint64 inUserData)
 
virtual void NotifyShapeChanged (const BodyID &inBodyID, Vec3Arg inDeltaCOM)=0
 
virtual void BuildIslands (uint32 inConstraintIndex, IslandBuilder &ioBuilder, BodyManager &inBodyManager)=0
 Link bodies that are connected by this constraint in the island builder. More...
 
virtual uint BuildIslandSplits (LargeIslandSplitter &ioSplitter) const =0
 Link bodies that are connected by this constraint in the same split. Returns the split index. More...
 
virtual void DrawConstraint (DebugRenderer *inRenderer) const =0
 
virtual void DrawConstraintLimits (DebugRenderer *inRenderer) const
 
virtual void DrawConstraintReferenceFrame (DebugRenderer *inRenderer) const
 
float GetDrawConstraintSize () const
 Size of constraint when drawing it through the debug renderer. More...
 
void SetDrawConstraintSize (float inSize)
 
virtual void SaveState (StateRecorder &inStream) const
 Saving state for replay. More...
 
virtual void RestoreState (StateRecorder &inStream)
 Restoring state for replay. More...
 
virtual Ref< ConstraintSettingsGetConstraintSettings () const =0
 Debug function to convert a constraint to its settings, note that this will not save to which bodies the constraint is connected to. More...
 
- Public Member Functions inherited from RefTarget< Constraint >
 RefTarget ()=default
 Constructor. More...
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us More...
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator. More...
 
uint32 GetRefCount () const
 Get current refcount of this object. More...
 
void AddRef () const
 Add or release a reference to this object. More...
 
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)

Vector< 2 > GetTotalLambdaPosition () const
 
float GetTotalLambdaPositionLimits () const
 
float GetTotalLambdaMotor () const
 
Vector< 2 > GetTotalLambdaRotationHinge () const
 
Vec3 GetTotalLambdaRotation () const
 

Additional Inherited Members

- Static Public Member Functions inherited from RefTarget< Constraint >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION. More...
 
- Protected Member Functions inherited from Constraint
void ToConstraintSettings (ConstraintSettings &outSettings) const
 Helper function to copy settings back to constraint settings for this base class. More...
 
- Protected Attributes inherited from TwoBodyConstraint
BodymBody1
 The two bodies involved. More...
 
BodymBody2
 
- Protected Attributes inherited from Constraint
float mDrawConstraintSize
 Size of constraint when drawing it through the debug renderer. More...
 
- Protected Attributes inherited from RefTarget< Constraint >
atomic< uint32mRefCount
 Current reference count. More...
 
- 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. More...
 

Detailed Description

Path constraint, used to constrain the degrees of freedom between two bodies to a path.

Constructor & Destructor Documentation

◆ PathConstraint()

PathConstraint::PathConstraint ( Body inBody1,
Body inBody2,
const PathConstraintSettings inSettings 
)

Construct point constraint.

Member Function Documentation

◆ DrawConstraint()

void PathConstraint::DrawConstraint ( DebugRenderer inRenderer) const
overridevirtual

Implements Constraint.

◆ GetConstraintSettings()

Ref< ConstraintSettings > PathConstraint::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 PathConstraint::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 PathConstraint::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.

◆ GetMaxFrictionForce()

float PathConstraint::GetMaxFrictionForce ( ) const
inline

◆ GetPath()

const PathConstraintPath * PathConstraint::GetPath ( ) const
inline

Access to the current path.

◆ GetPathFraction()

float PathConstraint::GetPathFraction ( ) const
inline

Access to the current fraction along the path e [0, GetPath()->GetMaxPathFraction()].

◆ GetPositionMotorSettings() [1/2]

MotorSettings & PathConstraint::GetPositionMotorSettings ( )
inline

Position motor settings.

◆ GetPositionMotorSettings() [2/2]

const MotorSettings & PathConstraint::GetPositionMotorSettings ( ) const
inline

◆ GetPositionMotorState()

EMotorState PathConstraint::GetPositionMotorState ( ) const
inline

◆ GetSubType()

virtual EConstraintSubType PathConstraint::GetSubType ( ) const
inlineoverridevirtual

Get the sub type of a constraint.

Implements Constraint.

◆ GetTargetPathFraction()

float PathConstraint::GetTargetPathFraction ( ) const
inline

◆ GetTargetVelocity()

float PathConstraint::GetTargetVelocity ( ) const
inline

◆ GetTotalLambdaMotor()

float PathConstraint::GetTotalLambdaMotor ( ) const
inline

◆ GetTotalLambdaPosition()

Vector< 2 > PathConstraint::GetTotalLambdaPosition ( ) const
inline

◆ GetTotalLambdaPositionLimits()

float PathConstraint::GetTotalLambdaPositionLimits ( ) const
inline

◆ GetTotalLambdaRotation()

Vec3 PathConstraint::GetTotalLambdaRotation ( ) const
inline

◆ GetTotalLambdaRotationHinge()

Vector< 2 > PathConstraint::GetTotalLambdaRotationHinge ( ) const
inline

◆ IsActive()

virtual bool PathConstraint::IsActive ( ) const
inlineoverridevirtual

Solver interface.

Reimplemented from TwoBodyConstraint.

◆ NotifyShapeChanged()

void PathConstraint::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.

◆ RestoreState()

void PathConstraint::RestoreState ( StateRecorder inStream)
overridevirtual

Restoring state for replay.

Reimplemented from Constraint.

◆ SaveState()

void PathConstraint::SaveState ( StateRecorder inStream) const
overridevirtual

Saving state for replay.

Reimplemented from Constraint.

◆ SetMaxFrictionForce()

void PathConstraint::SetMaxFrictionForce ( float  inFrictionForce)
inline

Friction control.

◆ SetPath()

void PathConstraint::SetPath ( const PathConstraintPath inPath,
float  inPathFraction 
)

Update the path for this constraint.

◆ SetPositionMotorState()

void PathConstraint::SetPositionMotorState ( EMotorState  inState)
inline

◆ SetTargetPathFraction()

void PathConstraint::SetTargetPathFraction ( float  inFraction)
inline

◆ SetTargetVelocity()

void PathConstraint::SetTargetVelocity ( float  inVelocity)
inline

◆ SetupVelocityConstraint()

void PathConstraint::SetupVelocityConstraint ( float  inDeltaTime)
overridevirtual

Implements Constraint.

◆ SolvePositionConstraint()

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

Implements Constraint.

◆ SolveVelocityConstraint()

bool PathConstraint::SolveVelocityConstraint ( float  inDeltaTime)
overridevirtual

Implements Constraint.

◆ WarmStartVelocityConstraint()

void PathConstraint::WarmStartVelocityConstraint ( float  inWarmStartImpulseRatio)
overridevirtual

Implements Constraint.


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