//
// 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 rotation along 1 axis
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:36
///
/// class AngleConstraintPart
///
///
///
///
/// 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):
///
/// \f[C = \theta(t) - \theta_{min}\f]
///
/// Jacobian (eq 109):
///
/// \f[J = \begin{bmatrix}0 & -a^T & 0 & a^T\end{bmatrix}\f]
///
/// Used terms (here and below, everything in world space):\n
/// a = axis around which rotation is constrained (normalized).\n
/// x1, x2 = center of mass for the bodies.\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
/// b = velocity bias.\n
/// \f$\beta\f$ = baumgarte constant.
///
///
[InteropHandle]
public readonly partial struct AngleConstraintPart : IDisposable
{
public static AngleConstraintPart Create() => Jolt.PInvoke.AngleConstraintPart_Create();
///
///
/// Calculate properties used during the functions below. Creates a constraint without spring.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:81
///
/// inline void CalculateConstraintProperties(const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias = 0.0f)
///
///
///
///
/// Calculate properties used during the functions below. Creates a constraint without spring.
/// @param inBody1 The first body that this constraint is attached to
/// @param inBody2 The second body that this constraint is attached to
/// @param 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:
/// @param inBias Bias term (b) for the constraint impulse: lambda = J v + b
///
///
public void CalculateConstraintProperties(Body body1, Body body2, float3 worldSpaceAxis, float bias = 0f) =>
Jolt.PInvoke.AngleConstraintPart_CalculateConstraintProperties(this, body1, body2, worldSpaceAxis, bias);
///
///
/// Calculate properties used during the functions below. Set inFrequency to zero if you don't want to drive
/// using a spring.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:103
///
/// inline void CalculateConstraintPropertiesWithFrequencyAndDamping(float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inFrequency, float inDamping)
///
///
///
///
/// Calculate properties used during the functions below. Set inFrequency to zero if you don't want to drive using a spring.
/// @param inDeltaTime Time step
/// @param inBody1 The first body that this constraint is attached to
/// @param inBody2 The second body that this constraint is attached to
/// @param inWorldSpaceAxis The axis of rotation along which the constraint acts (normalized)
/// @param inBias Bias term (b) for the constraint impulse: lambda = J v + b
/// @param inC Value of the constraint equation (C)
/// @param inFrequency Oscillation frequency (Hz)
/// @param inDamping Damping factor (0 = no damping, 1 = critical damping)
///
///
public void CalculateConstraintPropertiesWithFrequencyAndDamping(
float deltaTime,
Body body1,
Body body2,
float3 worldSpaceAxis,
float bias,
float c,
float frequency,
float damping
) =>
Jolt.PInvoke.AngleConstraintPart_CalculateConstraintPropertiesWithFrequencyAndDamping(
this,
deltaTime,
body1,
body2,
worldSpaceAxis,
bias,
c,
frequency,
damping
);
///
///
/// Calculate properties used during the functions below. Set inStiffness and inDamping to zero if you don't
/// want to drive using a spring.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:127
///
/// inline void CalculateConstraintPropertiesWithStiffnessAndDamping(float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inStiffness, float inDamping)
///
///
///
///
/// Calculate properties used during the functions below. Set inStiffness and inDamping to zero if you don't want to drive using a spring.
/// @param inDeltaTime Time step
/// @param inBody1 The first body that this constraint is attached to
/// @param inBody2 The second body that this constraint is attached to
/// @param inWorldSpaceAxis The axis of rotation along which the constraint acts (normalized)
/// @param inBias Bias term (b) for the constraint impulse: lambda = J v + b
/// @param inC Value of the constraint equation (C)
/// @param inStiffness Spring stiffness k.
/// @param inDamping Spring damping coefficient c.
///
///
public void CalculateConstraintPropertiesWithStiffnessAndDamping(
float deltaTime,
Body body1,
Body body2,
float3 worldSpaceAxis,
float bias,
float c,
float stiffness,
float damping
) =>
Jolt.PInvoke.AngleConstraintPart_CalculateConstraintPropertiesWithStiffnessAndDamping(
this,
deltaTime,
body1,
body2,
worldSpaceAxis,
bias,
c,
stiffness,
damping
);
///
///
/// Calculate properties used during the functions below based on inSpringSettings. Turns to a hard limit
/// when inSpringSettings has stiffness / frequency = 0
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:144
///
/// inline void CalculateConstraintPropertiesWithSettingsForLimit(float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, const SpringSettings &inSpringSettings)
///
///
public void CalculateConstraintPropertiesWithSettingsForLimit(
float deltaTime,
Body body1,
Body body2,
float3 worldSpaceAxis,
float bias,
float c,
SpringSettings springSettings
) =>
Jolt.PInvoke.AngleConstraintPart_CalculateConstraintPropertiesWithSettingsForLimit(
this,
deltaTime,
body1,
body2,
worldSpaceAxis,
bias,
c,
springSettings
);
///
///
/// Calculate properties used during the functions below based on inSpringSettings. Assumes the spring has
/// either stiffness or damping.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:161
///
/// inline void CalculateConstraintPropertiesWithSettingsForMotor(float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, const SpringSettings &inSpringSettings)
///
///
public void CalculateConstraintPropertiesWithSettingsForMotor(
float deltaTime,
Body body1,
Body body2,
float3 worldSpaceAxis,
float bias,
float c,
SpringSettings springSettings
) =>
Jolt.PInvoke.AngleConstraintPart_CalculateConstraintPropertiesWithSettingsForMotor(
this,
deltaTime,
body1,
body2,
worldSpaceAxis,
bias,
c,
springSettings
);
///
///
/// Deactivate this constraint
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:174
///
/// inline void Deactivate()
///
///
public void Deactivate() => Jolt.PInvoke.AngleConstraintPart_Deactivate(this);
///
///
/// Check if constraint is active
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:181
///
/// inline bool IsActive() const
///
///
public bool IsActive() => Jolt.PInvoke.AngleConstraintPart_IsActive(this);
///
///
/// Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:190
///
/// 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.AngleConstraintPart_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/AngleConstraintPart.h:202
///
/// inline bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda)
///
///
///
///
/// 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 inWorldSpaceAxis The axis of rotation along which the constraint acts (normalized)
/// @param inMinLambda Minimum angular impulse to apply (N m s)
/// @param inMaxLambda Maximum angular impulse to apply (N m s)
///
///
public bool SolveVelocityConstraint(
Body body1,
Body body2,
float3 worldSpaceAxis,
float minLambda,
float maxLambda
) =>
Jolt.PInvoke.AngleConstraintPart_SolveVelocityConstraint(
this,
body1,
body2,
worldSpaceAxis,
minLambda,
maxLambda
);
///
///
/// Return lagrange multiplier
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:216
///
/// float GetTotalLambda() const
///
///
public float GetTotalLambda() => Jolt.PInvoke.AngleConstraintPart_GetTotalLambda(this);
///
///
/// Iteratively update the position constraint. Makes sure C(...) == 0.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h:226
///
/// 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.AngleConstraintPart_SolvePositionConstraint(this, body1, body2, c, baumgarte);
public void Dispose() => Jolt.PInvoke.AngleConstraintPart_Destroy(this);
}
}