Jolt Physics
A multi core friendly Game Physics Engine
|
#include <AxisConstraintPart.h>
Public Member Functions | |
template<EMotionType Type1, EMotionType Type2> | |
JPH_INLINE void | TemplatedCalculateConstraintProperties (float inInvMass1, Mat44Arg inInvI1, Vec3Arg inR1PlusU, float inInvMass2, Mat44Arg inInvI2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f) |
Templated form of CalculateConstraintProperties with the motion types baked in. | |
void | CalculateConstraintProperties (const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f) |
void | CalculateConstraintPropertiesWithMassOverride (const Body &inBody1, float inInvMass1, float inInvInertiaScale1, Vec3Arg inR1PlusU, const Body &inBody2, float inInvMass2, float inInvInertiaScale2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f) |
void | CalculateConstraintPropertiesWithFrequencyAndDamping (float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inFrequency, float inDamping) |
void | CalculateConstraintPropertiesWithStiffnessAndDamping (float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inStiffness, float inDamping) |
void | CalculateConstraintPropertiesWithSettings (float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, 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. | |
template<EMotionType Type1, EMotionType Type2> | |
void | TemplatedWarmStart (MotionProperties *ioMotionProperties1, float inInvMass1, MotionProperties *ioMotionProperties2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inWarmStartImpulseRatio) |
Templated form of WarmStart with the motion types baked in. | |
void | WarmStart (Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inWarmStartImpulseRatio) |
template<EMotionType Type1, EMotionType Type2> | |
JPH_INLINE float | TemplatedSolveVelocityConstraintGetTotalLambda (const MotionProperties *ioMotionProperties1, const MotionProperties *ioMotionProperties2, Vec3Arg inWorldSpaceAxis) const |
Templated form of SolveVelocityConstraint with the motion types baked in, part 1: get the total lambda. | |
template<EMotionType Type1, EMotionType Type2> | |
JPH_INLINE bool | TemplatedSolveVelocityConstraintApplyLambda (MotionProperties *ioMotionProperties1, float inInvMass1, MotionProperties *ioMotionProperties2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inTotalLambda) |
Templated form of SolveVelocityConstraint with the motion types baked in, part 2: apply new lambda. | |
template<EMotionType Type1, EMotionType Type2> | |
bool | TemplatedSolveVelocityConstraint (MotionProperties *ioMotionProperties1, float inInvMass1, MotionProperties *ioMotionProperties2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda) |
Templated form of SolveVelocityConstraint with the motion types baked in. | |
bool | SolveVelocityConstraint (Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda) |
bool | SolveVelocityConstraintWithMassOverride (Body &ioBody1, float inInvMass1, Body &ioBody2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda) |
bool | SolvePositionConstraint (Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inC, float inBaumgarte) const |
bool | SolvePositionConstraintWithMassOverride (Body &ioBody1, float inInvMass1, Body &ioBody2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inC, float inBaumgarte) const |
void | SetTotalLambda (float inLambda) |
Override total lagrange multiplier, can be used to set the initial value for warm starting. | |
float | GetTotalLambda () const |
Return lagrange multiplier. | |
void | SaveState (StateRecorder &inStream) const |
Save state of this constraint part. | |
void | RestoreState (StateRecorder &inStream) |
Restore state of this constraint part. | |
Constraint that constrains motion along 1 axis
Constraint equation (eq 25):
\[C = (p_2 - p_1) \cdot n\]
Jacobian (eq 28):
\[J = \begin{bmatrix} -n^T & (-(r_1 + u) \times n)^T & n^T & (r_2 \times n)^T \end{bmatrix}\]
Used terms (here and below, everything in world space):
n = constraint axis (normalized).
p1, p2 = constraint points.
r1 = p1 - x1.
r2 = p2 - x2.
u = x2 + r2 - x1 - r1 = p2 - p1.
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 |
inR1PlusU | See equations above (r1 + u) |
inR2 | See equations above (r2) |
inWorldSpaceAxis | Axis along which the constraint acts (normalized, pointing from body 1 to 2) |
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 |
inR1PlusU | See equations above (r1 + u) |
inR2 | See equations above (r2) |
inWorldSpaceAxis | Axis along which the constraint acts (normalized, pointing from body 1 to 2) |
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 |
Calculate properties used during the functions below, version that supports mass scaling
inBody1 | The first body that this constraint is attached to |
inBody2 | The second body that this constraint is attached to |
inInvMass1 | The inverse mass of body 1 (only used when body 1 is dynamic) |
inInvMass2 | The inverse mass of body 2 (only used when body 2 is dynamic) |
inInvInertiaScale1 | Scale factor for the inverse inertia of body 1 |
inInvInertiaScale2 | Scale factor for the inverse inertia of body 2 |
inR1PlusU | See equations above (r1 + u) |
inR2 | See equations above (r2) |
inWorldSpaceAxis | Axis along which the constraint acts (normalized, pointing from body 1 to 2) |
inBias | Bias term (b) for the constraint impulse: lambda = J v + b |
|
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 |
inR1PlusU | See equations above (r1 + u) |
inR2 | See equations above (r2) |
inWorldSpaceAxis | Axis along which the constraint acts (normalized, pointing from body 1 to 2) |
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 |
Override total lagrange multiplier, can be used to set the initial value for warm starting.
|
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 |
inWorldSpaceAxis | Axis along which the constraint acts (normalized) |
inC | Value of the constraint equation (C) |
inBaumgarte | Baumgarte constant (fraction of the error to correct) |
|
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 |
inInvMass1 | The inverse mass of body 1 (only used when body 1 is dynamic) |
inInvMass2 | The inverse mass of body 2 (only used when body 2 is dynamic) |
inWorldSpaceAxis | Axis along which the constraint acts (normalized) |
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 | Axis along which the constraint acts (normalized) |
inMinLambda | Minimum value of constraint impulse to apply (N s) |
inMaxLambda | Maximum value of constraint impulse to apply (N s) |
|
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 |
inInvMass1 | The inverse mass of body 1 (only used when body 1 is dynamic) |
inInvMass2 | The inverse mass of body 2 (only used when body 2 is dynamic) |
inWorldSpaceAxis | Axis along which the constraint acts (normalized) |
inMinLambda | Minimum value of constraint impulse to apply (N s) |
inMaxLambda | Maximum value of constraint impulse to apply (N s) |
|
inline |
Templated form of CalculateConstraintProperties with the motion types baked in.
|
inline |
Templated form of SolveVelocityConstraint with the motion types baked in.
|
inline |
Templated form of SolveVelocityConstraint with the motion types baked in, part 2: apply new lambda.
|
inline |
Templated form of SolveVelocityConstraint with the motion types baked in, part 1: get the total lambda.
|
inline |
Templated form of WarmStart with the motion types baked in.
|
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 |
inWorldSpaceAxis | Axis along which the constraint acts (normalized) |
inWarmStartImpulseRatio | Ratio of new step to old time step (dt_new / dt_old) for scaling the lagrange multiplier of the previous frame |