Jolt Physics
A multi core friendly Game Physics Engine
|
#include <DualAxisConstraintPart.h>
Public Types | |
using | Vec2 = Vector<2> |
using | Mat22 = Matrix<2, 2> |
Public Member Functions | |
void | CalculateConstraintProperties (const Body &inBody1, Mat44Arg inRotation1, Vec3Arg inR1PlusU, const Body &inBody2, Mat44Arg inRotation2, Vec3Arg inR2, Vec3Arg inN1, Vec3Arg inN2) |
void | Deactivate () |
Deactivate this constraint. | |
bool | IsActive () const |
Check if constraint is active. | |
void | WarmStart (Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inWarmStartImpulseRatio) |
bool | SolveVelocityConstraint (Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2) |
bool | SolvePositionConstraint (Body &ioBody1, Body &ioBody2, Vec3Arg inU, Vec3Arg inN1, Vec3Arg inN2, float inBaumgarte) const |
void | SetTotalLambda (const Vec2 &inLambda) |
Override total lagrange multiplier, can be used to set the initial value for warm starting. | |
const Vec2 & | 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. | |
Constrains movement on 2 axis
Constraint equation (eq 51):
\[C = \begin{bmatrix} (p_2 - p_1) \cdot n_1 \\ (p_2 - p_1) \cdot n_2\end{bmatrix}\]
Jacobian (transposed) (eq 55):
\[J^T = \begin{bmatrix} -n_1 & -n_2 \\ -(r_1 + u) \times n_1 & -(r_1 + u) \times n_2 \\ n_1 & n_2 \\ r_2 \times n_1 & r_2 \times n_2 \end{bmatrix}\]
Used terms (here and below, everything in world space):
n1, n2 = 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.
using DualAxisConstraintPart::Mat22 = Matrix<2, 2> |
|
inline |
Calculate properties used during the functions below All input vectors are in world space
|
inline |
Deactivate this constraint.
|
inline |
Check if constraint is active.
|
inline |
Restore state of this constraint part.
|
inline |
Save state of this constraint part.
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. All input vectors are in world space
|
inline |
Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation. All input vectors are in world space
|
inline |
Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses All input vectors are in world space