Jolt Physics
A multi core friendly Game Physics Engine
|
#include <RackAndPinionConstraintPart.h>
Public Member Functions | |
void | CalculateConstraintProperties (const Body &inBody1, Vec3Arg inWorldSpaceHingeAxis, const Body &inBody2, Vec3Arg inWorldSpaceSliderAxis, float inRatio) |
void | Deactivate () |
Deactivate this constraint. | |
bool | IsActive () const |
Check if constraint is active. | |
void | WarmStart (Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio) |
bool | SolveVelocityConstraint (Body &ioBody1, Vec3Arg inWorldSpaceHingeAxis, Body &ioBody2, Vec3Arg inWorldSpaceSliderAxis, float inRatio) |
float | GetTotalLambda () const |
Return lagrange multiplier. | |
bool | SolvePositionConstraint (Body &ioBody1, Body &ioBody2, float inC, float inBaumgarte) const |
void | SaveState (StateRecorder &inStream) const |
Save state of this constraint part. | |
void | RestoreState (StateRecorder &inStream) |
Restore state of this constraint part. | |
Constraint that constrains a rotation to a translation
Constraint equation:
C = Theta(t) - r d(t)
Derivative:
d/dt C = 0 <=> w1 . a - r v2 . b = 0
Jacobian:
\[J = \begin{bmatrix}0 & a^T & -r b^T & 0\end{bmatrix}\]
Used terms (here and below, everything in world space):
a = axis around which body 1 rotates (normalized).
b = axis along which body 2 slides (normalized).
Theta(t) = rotation around a of body 1.
d(t) = distance body 2 slides.
r = ratio between rotation and translation.
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.
\(\beta\) = baumgarte constant.
|
inline |
Calculate properties used during the functions below
inBody1 | The first body that this constraint is attached to |
inBody2 | The second body that this constraint is attached to |
inWorldSpaceHingeAxis | The axis around which body 1 rotates |
inWorldSpaceSliderAxis | The axis along which body 2 slides |
inRatio | The ratio between rotation and translation |
|
inline |
Deactivate this constraint.
|
inline |
Return lagrange multiplier.
|
inline |
Check if constraint is active.
|
inline |
Restore state of this constraint part.
|
inline |
Save state of this constraint part.
|
inline |
Iteratively update the position constraint. Makes sure C(...) == 0.
ioBody1 | The first body that this constraint is attached to |
ioBody2 | The second body that this constraint is attached to |
inC | Value of the constraint equation (C) |
inBaumgarte | Baumgarte constant (fraction of the error to correct) |
|
inline |
Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation.
ioBody1 | The first body that this constraint is attached to |
ioBody2 | The second body that this constraint is attached to |
inWorldSpaceHingeAxis | The axis around which body 1 rotates |
inWorldSpaceSliderAxis | The axis along which body 2 slides |
inRatio | The ratio between rotation and translation |
|
inline |
Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses
ioBody1 | The first body that this constraint is attached to |
ioBody2 | The second body that this constraint is attached to |
inWarmStartImpulseRatio | Ratio of new step to old time step (dt_new / dt_old) for scaling the lagrange multiplier of the previous frame |