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

#include <SwingTwistConstraintPart.h>

Public Member Functions

void SetLimits (float inTwistMinAngle, float inTwistMaxAngle, float inSwingYHalfAngle, float inSwingZHalfAngle)
 Set limits for this constraint (see description above for parameters)
 
void ClampSwingTwist (Quat &ioSwing, bool &outSwingYClamped, bool &outSwingZClamped, Quat &ioTwist, bool &outTwistClamped) const
 Clamp twist and swing against the constraint limits, returns which parts were clamped (everything assumed in constraint space)
 
void CalculateConstraintProperties (const Body &inBody1, const Body &inBody2, QuatArg inConstraintRotation, QuatArg inConstraintToWorld)
 
void Deactivate ()
 Deactivate this constraint.
 
bool IsActive () const
 Check if constraint is active.
 
void WarmStart (Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
 Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses.
 
bool SolveVelocityConstraint (Body &ioBody1, Body &ioBody2)
 Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation.
 
bool SolvePositionConstraint (Body &ioBody1, Body &ioBody2, QuatArg inConstraintRotation, QuatArg inConstraintToBody1, QuatArg inConstraintToBody2, float inBaumgarte) const
 
float GetTotalSwingYLambda () const
 Return lagrange multiplier for swing.
 
float GetTotalSwingZLambda () const
 
float GetTotalTwistLambda () const
 Return lagrange multiplier for twist.
 
void SaveState (StateRecorder &inStream) const
 Save state of this constraint part.
 
void RestoreState (StateRecorder &inStream)
 Restore state of this constraint part.
 

Detailed Description

Quaternion based constraint that decomposes the rotation in constraint space in swing and twist: q = q_swing * q_twist where q_swing.x = 0 and where q_twist.y = q_twist.z = 0

  • Rotation around the twist (x-axis) is within [inTwistMinAngle, inTwistMaxAngle].
  • Rotation around the swing axis (y and z axis) are limited to an ellipsoid in quaternion space formed by the equation:

(q_swing.y / sin(inSwingYHalfAngle / 2))^2 + (q_swing.z / sin(inSwingZHalfAngle / 2))^2 <= 1

Which roughly corresponds to an elliptic cone shape with major axis (inSwingYHalfAngle, inSwingZHalfAngle).

In case inSwingYHalfAngle = 0, the rotation around Y will be constrained to 0 and the rotation around Z will be constrained between [-inSwingZHalfAngle, inSwingZHalfAngle]. Vice versa if inSwingZHalfAngle = 0.

Member Function Documentation

◆ CalculateConstraintProperties()

void SwingTwistConstraintPart::CalculateConstraintProperties ( const Body & inBody1,
const Body & inBody2,
QuatArg inConstraintRotation,
QuatArg inConstraintToWorld )
inline

Calculate properties used during the functions below

Parameters
inBody1The first body that this constraint is attached to
inBody2The second body that this constraint is attached to
inConstraintRotationThe current rotation of the constraint in constraint space
inConstraintToWorldRotates from constraint space into world space

◆ ClampSwingTwist()

void SwingTwistConstraintPart::ClampSwingTwist ( Quat & ioSwing,
bool & outSwingYClamped,
bool & outSwingZClamped,
Quat & ioTwist,
bool & outTwistClamped ) const
inline

Clamp twist and swing against the constraint limits, returns which parts were clamped (everything assumed in constraint space)

◆ Deactivate()

void SwingTwistConstraintPart::Deactivate ( )
inline

Deactivate this constraint.

◆ GetTotalSwingYLambda()

float SwingTwistConstraintPart::GetTotalSwingYLambda ( ) const
inline

Return lagrange multiplier for swing.

◆ GetTotalSwingZLambda()

float SwingTwistConstraintPart::GetTotalSwingZLambda ( ) const
inline

◆ GetTotalTwistLambda()

float SwingTwistConstraintPart::GetTotalTwistLambda ( ) const
inline

Return lagrange multiplier for twist.

◆ IsActive()

bool SwingTwistConstraintPart::IsActive ( ) const
inline

Check if constraint is active.

◆ RestoreState()

void SwingTwistConstraintPart::RestoreState ( StateRecorder & inStream)
inline

Restore state of this constraint part.

◆ SaveState()

void SwingTwistConstraintPart::SaveState ( StateRecorder & inStream) const
inline

Save state of this constraint part.

◆ SetLimits()

void SwingTwistConstraintPart::SetLimits ( float inTwistMinAngle,
float inTwistMaxAngle,
float inSwingYHalfAngle,
float inSwingZHalfAngle )
inline

Set limits for this constraint (see description above for parameters)

◆ SolvePositionConstraint()

bool SwingTwistConstraintPart::SolvePositionConstraint ( Body & ioBody1,
Body & ioBody2,
QuatArg inConstraintRotation,
QuatArg inConstraintToBody1,
QuatArg inConstraintToBody2,
float inBaumgarte ) const
inline

Iteratively update the position constraint. Makes sure C(...) = 0.

Parameters
ioBody1The first body that this constraint is attached to
ioBody2The second body that this constraint is attached to
inConstraintRotationThe current rotation of the constraint in constraint space
inConstraintToBody1,inConstraintToBody2Rotates from constraint space to body 1/2 space
inBaumgarteBaumgarte constant (fraction of the error to correct)

◆ SolveVelocityConstraint()

bool SwingTwistConstraintPart::SolveVelocityConstraint ( Body & ioBody1,
Body & ioBody2 )
inline

Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation.

◆ WarmStart()

void SwingTwistConstraintPart::WarmStart ( Body & ioBody1,
Body & ioBody2,
float inWarmStartImpulseRatio )
inline

Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses.


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