//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using System.Runtime.CompilerServices;
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// Constraint that constrains two rotations using a gear (rotating in opposite direction)
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:39
///
/// class GearConstraintPart
///
///
///
///
/// Constraint that constrains two rotations using a gear (rotating in opposite direction)
///
/// Constraint equation:
///
/// C = Rotation1(t) + r Rotation2(t)
///
/// Derivative:
///
/// d/dt C = 0
/// <=> w1 . a + r w2 . b = 0
///
/// Jacobian:
///
/// \f[J = \begin{bmatrix}0 & a^T & 0 & r b^T\end{bmatrix}\f]
///
/// Used terms (here and below, everything in world space):\n
/// a = axis around which body 1 rotates (normalized).\n
/// b = axis along which body 2 slides (normalized).\n
/// Rotation1(t) = rotation around a of body 1.\n
/// Rotation2(t) = rotation around b of body 2.\n
/// r = ratio between rotation for body 1 and 2.\n
/// v = [v1, w1, v2, w2].\n
/// v1, v2 = linear velocity of body 1 and 2.\n
/// w1, w2 = angular velocity of body 1 and 2.\n
/// M = mass matrix, a diagonal matrix of the mass and inertia with diagonal [m1, I1, m2, I2].\n
/// \f$K^{-1} = \left( J M^{-1} J^T \right)^{-1}\f$ = effective mass.\n
/// \f$\beta\f$ = baumgarte constant.
///
///
[InteropHandle]
public readonly partial struct GearConstraintPart : IDisposable
{
public static GearConstraintPart Create() => Jolt.PInvoke.GearConstraintPart_Create();
///
///
/// Calculate properties used during the functions below
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:69
///
/// inline void CalculateConstraintProperties(const Body &inBody1, Vec3Arg inWorldSpaceHingeAxis1, const Body &inBody2, Vec3Arg inWorldSpaceHingeAxis2, float inRatio)
///
///
///
///
/// Calculate properties used during the functions below
/// @param inBody1 The first body that this constraint is attached to
/// @param inBody2 The second body that this constraint is attached to
/// @param inWorldSpaceHingeAxis1 The axis around which body 1 rotates
/// @param inWorldSpaceHingeAxis2 The axis around which body 2 rotates
/// @param inRatio The ratio between rotation and translation
///
///
public void CalculateConstraintProperties(
Body body1,
float3 worldSpaceHingeAxis1,
Body body2,
float3 worldSpaceHingeAxis2,
float ratio
) =>
Jolt.PInvoke.GearConstraintPart_CalculateConstraintProperties(
this,
body1,
worldSpaceHingeAxis1,
body2,
worldSpaceHingeAxis2,
ratio
);
///
///
/// Deactivate this constraint
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:89
///
/// inline void Deactivate()
///
///
public void Deactivate() => Jolt.PInvoke.GearConstraintPart_Deactivate(this);
///
///
/// Check if constraint is active
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:96
///
/// inline bool IsActive() const
///
///
public bool IsActive() => Jolt.PInvoke.GearConstraintPart_IsActive(this);
///
///
/// Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:105
///
/// inline void WarmStart(Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
///
///
///
///
/// Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses
/// @param ioBody1 The first body that this constraint is attached to
/// @param ioBody2 The second body that this constraint is attached to
/// @param inWarmStartImpulseRatio Ratio of new step to old time step (dt_new / dt_old) for scaling the lagrange multiplier of the previous frame
///
///
public void WarmStart(Body body1, Body body2, float warmStartImpulseRatio) =>
Jolt.PInvoke.GearConstraintPart_WarmStart(this, body1, body2, warmStartImpulseRatio);
///
///
/// Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint
/// equation.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:117
///
/// inline bool SolveVelocityConstraint(Body &ioBody1, Vec3Arg inWorldSpaceHingeAxis1, Body &ioBody2, Vec3Arg inWorldSpaceHingeAxis2, float inRatio)
///
///
///
///
/// Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation.
/// @param ioBody1 The first body that this constraint is attached to
/// @param ioBody2 The second body that this constraint is attached to
/// @param inWorldSpaceHingeAxis1 The axis around which body 1 rotates
/// @param inWorldSpaceHingeAxis2 The axis around which body 2 rotates
/// @param inRatio The ratio between rotation and translation
///
///
public bool SolveVelocityConstraint(
Body body1,
float3 worldSpaceHingeAxis1,
Body body2,
float3 worldSpaceHingeAxis2,
float ratio
) =>
Jolt.PInvoke.GearConstraintPart_SolveVelocityConstraint(
this,
body1,
worldSpaceHingeAxis1,
body2,
worldSpaceHingeAxis2,
ratio
);
///
///
/// Return lagrange multiplier
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:129
///
/// float GetTotalLambda() const
///
///
public float GetTotalLambda() => Jolt.PInvoke.GearConstraintPart_GetTotalLambda(this);
///
///
/// Iteratively update the position constraint. Makes sure C(...) == 0.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h:139
///
/// inline bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, float inC, float inBaumgarte) const
///
///
///
///
/// Iteratively update the position constraint. Makes sure C(...) == 0.
/// @param ioBody1 The first body that this constraint is attached to
/// @param ioBody2 The second body that this constraint is attached to
/// @param inC Value of the constraint equation (C)
/// @param inBaumgarte Baumgarte constant (fraction of the error to correct)
///
///
public bool SolvePositionConstraint(Body body1, Body body2, float c, float baumgarte) =>
Jolt.PInvoke.GearConstraintPart_SolvePositionConstraint(this, body1, body2, c, baumgarte);
public void Dispose() => Jolt.PInvoke.GearConstraintPart_Destroy(this);
}
}