Jolt Physics
A multi core friendly Game Physics Engine
|
#include <AngleConstraintPart.h>
Public Member Functions | |
void | CalculateConstraintProperties (const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f) |
void | CalculateConstraintPropertiesWithFrequencyAndDamping (float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inFrequency, float inDamping) |
void | CalculateConstraintPropertiesWithStiffnessAndDamping (float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inStiffness, float inDamping) |
void | CalculateConstraintPropertiesWithSettings (float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, const SpringSettings &inSpringSettings) |
Selects one of the above functions based on the spring settings. | |
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, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda) |
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 rotation along 1 axis
Based on: "Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, see section 2.4.5
Constraint equation (eq 108):
\[C = \theta(t) - \theta_{min}\]
Jacobian (eq 109):
\[J = \begin{bmatrix}0 & -a^T & 0 & a^T\end{bmatrix}\]
Used terms (here and below, everything in world space):
a = axis around which rotation is constrained (normalized).
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.
|
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 |
inWorldSpaceAxis | The axis of rotation along which the constraint acts (normalized) Set the following terms to zero if you don't want to drive the constraint to zero with a spring: |
inBias | Bias term (b) for the constraint impulse: lambda = J v + b |
|
inline |
Calculate properties used during the functions below
inDeltaTime | Time step |
inBody1 | The first body that this constraint is attached to |
inBody2 | The second body that this constraint is attached to |
inWorldSpaceAxis | The axis of rotation along which the constraint acts (normalized) Set the following terms to zero if you don't want to drive the constraint to zero with a spring: |
inBias | Bias term (b) for the constraint impulse: lambda = J v + b |
inC | Value of the constraint equation (C) |
inFrequency | Oscillation frequency (Hz) |
inDamping | Damping factor (0 = no damping, 1 = critical damping) |
|
inline |
Selects one of the above functions based on the spring settings.
|
inline |
Calculate properties used during the functions below
inDeltaTime | Time step |
inBody1 | The first body that this constraint is attached to |
inBody2 | The second body that this constraint is attached to |
inWorldSpaceAxis | The axis of rotation along which the constraint acts (normalized) Set the following terms to zero if you don't want to drive the constraint to zero with a spring: |
inBias | Bias term (b) for the constraint impulse: lambda = J v + b |
inC | Value of the constraint equation (C) |
inStiffness | Spring stiffness k. |
inDamping | Spring damping coefficient c. |
|
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 |
inWorldSpaceAxis | The axis of rotation along which the constraint acts (normalized) |
inMinLambda | Minimum angular impulse to apply (N m s) |
inMaxLambda | Maximum angular impulse to apply (N m s) |
|
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 |