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

#include <PointConstraintPart.h>

Public Member Functions

void CalculateConstraintProperties (const Body &inBody1, Mat44Arg inRotation1, Vec3Arg inR1, const Body &inBody2, Mat44Arg inRotation2, Vec3Arg inR2)
 
void Deactivate ()
 Deactivate this constraint. More...
 
bool IsActive () const
 Check if constraint is active. More...
 
void WarmStart (Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
 
bool SolveVelocityConstraint (Body &ioBody1, Body &ioBody2)
 
bool SolvePositionConstraint (Body &ioBody1, Body &ioBody2, float inBaumgarte) const
 
Vec3 GetTotalLambda () const
 Return lagrange multiplier. More...
 
void SaveState (StateRecorder &inStream) const
 Save state of this constraint part. More...
 
void RestoreState (StateRecorder &inStream)
 Restore state of this constraint part. More...
 

Detailed Description

Constrains movement along 3 axis

See also
"Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.2.1

Constraint equation (eq 45):

\[C = p_2 - p_1\]

Jacobian (transposed) (eq 47):

\[J^T = \begin{bmatrix}-E & r1x & E & -r2x^T\end{bmatrix} = \begin{bmatrix}-E^T \\ r1x^T \\ E^T \\ -r2x^T\end{bmatrix} = \begin{bmatrix}-E \\ -r1x \\ E \\ r2x\end{bmatrix}\]

Used terms (here and below, everything in world space):
p1, p2 = constraint points.
r1 = p1 - x1.
r2 = p2 - x2.
r1x = 3x3 matrix for which r1x v = r1 x v (cross product).
x1, x2 = center of mass for the bodies.
v = [v1, w1, v2, w2].
v1, v2 = linear velocity of body 1 and 2.
w1, w2 = angular velocity of body 1 and 2.
M = mass matrix, a diagonal matrix of the mass and inertia with diagonal [m1, I1, m2, I2].
\(K^{-1} = \left( J M^{-1} J^T \right)^{-1}\) = effective mass.
b = velocity bias.
\(\beta\) = baumgarte constant.
E = identity matrix.

Member Function Documentation

◆ CalculateConstraintProperties()

void PointConstraintPart::CalculateConstraintProperties ( const Body inBody1,
Mat44Arg  inRotation1,
Vec3Arg  inR1,
const Body inBody2,
Mat44Arg  inRotation2,
Vec3Arg  inR2 
)
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
inRotation1The 3x3 rotation matrix for body 1 (translation part is ignored)
inRotation2The 3x3 rotation matrix for body 2 (translation part is ignored)
inR1Local space vector from center of mass to constraint point for body 1
inR2Local space vector from center of mass to constraint point for body 2

◆ Deactivate()

void PointConstraintPart::Deactivate ( )
inline

Deactivate this constraint.

◆ GetTotalLambda()

Vec3 PointConstraintPart::GetTotalLambda ( ) const
inline

Return lagrange multiplier.

◆ IsActive()

bool PointConstraintPart::IsActive ( ) const
inline

Check if constraint is active.

◆ RestoreState()

void PointConstraintPart::RestoreState ( StateRecorder inStream)
inline

Restore state of this constraint part.

◆ SaveState()

void PointConstraintPart::SaveState ( StateRecorder inStream) const
inline

Save state of this constraint part.

◆ SolvePositionConstraint()

bool PointConstraintPart::SolvePositionConstraint ( Body ioBody1,
Body ioBody2,
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
inBaumgarteBaumgarte constant (fraction of the error to correct)

◆ SolveVelocityConstraint()

bool PointConstraintPart::SolveVelocityConstraint ( Body ioBody1,
Body ioBody2 
)
inline

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

Parameters
ioBody1The first body that this constraint is attached to
ioBody2The second body that this constraint is attached to

◆ WarmStart()

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

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

Parameters
ioBody1The first body that this constraint is attached to
ioBody2The second body that this constraint is attached to
inWarmStartImpulseRatioRatio of new step to old time step (dt_new / dt_old) for scaling the lagrange multiplier of the previous frame

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