mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
271 lines
13 KiB
C#
271 lines
13 KiB
C#
// <auto-generated/>
|
|
// 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
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Constraint part to an AxisConstraintPart but both bodies have an independent axis on which the force is
|
|
/// applied.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L47">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:47</see>
|
|
/// <br/>
|
|
/// <c>class IndependentAxisConstraintPart</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// Constraint part to an AxisConstraintPart but both bodies have an independent axis on which the force is applied.
|
|
///
|
|
/// Constraint equation:
|
|
///
|
|
/// \f[C = (x_1 + r_1 - f_1) . n_1 + r (x_2 + r_2 - f_2) \cdot n_2\f]
|
|
///
|
|
/// Calculating the Jacobian:
|
|
///
|
|
/// \f[dC/dt = (v_1 + w_1 \times r_1) \cdot n_1 + (x_1 + r_1 - f_1) \cdot d n_1/dt + r (v_2 + w_2 \times r_2) \cdot n_2 + r (x_2 + r_2 - f_2) \cdot d n_2/dt\f]
|
|
///
|
|
/// Assuming that d n1/dt and d n2/dt are small this becomes:
|
|
///
|
|
/// \f[(v_1 + w_1 \times r_1) \cdot n_1 + r (v_2 + w_2 \times r_2) \cdot n_2\f]
|
|
/// \f[= v_1 \cdot n_1 + r_1 \times n_1 \cdot w_1 + r v_2 \cdot n_2 + r r_2 \times n_2 \cdot w_2\f]
|
|
///
|
|
/// Jacobian:
|
|
///
|
|
/// \f[J = \begin{bmatrix}n_1 & r_1 \times n_1 & r n_2 & r r_2 \times n_2\end{bmatrix}\f]
|
|
///
|
|
/// Effective mass:
|
|
///
|
|
/// \f[K = m_1^{-1} + r_1 \times n_1 I_1^{-1} r_1 \times n_1 + r^2 m_2^{-1} + r^2 r_2 \times n_2 I_2^{-1} r_2 \times n_2\f]
|
|
///
|
|
/// Used terms (here and below, everything in world space):\n
|
|
/// n1 = (x1 + r1 - f1) / |x1 + r1 - f1|, axis along which the force is applied for body 1\n
|
|
/// n2 = (x2 + r2 - f2) / |x2 + r2 - f2|, axis along which the force is applied for body 2\n
|
|
/// r = ratio how forces are applied between bodies.\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.
|
|
/// </code>
|
|
/// </remarks>
|
|
[InteropHandle]
|
|
public readonly partial struct IndependentAxisConstraintPart : IDisposable
|
|
{
|
|
public static IndependentAxisConstraintPart Create() => Jolt.PInvoke.IndependentAxisConstraintPart_Create();
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Calculate properties used during the functions below
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L89">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:89</see>
|
|
/// <br/>
|
|
/// <c>inline void CalculateConstraintProperties(const Body &inBody1, const Body &inBody2, Vec3Arg inR1, Vec3Arg inN1, Vec3Arg inR2, Vec3Arg inN2, float inRatio)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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 inR1 The position on which the constraint operates on body 1 relative to COM
|
|
/// @param inN1 The world space normal in which the constraint operates for body 1
|
|
/// @param inR2 The position on which the constraint operates on body 1 relative to COM
|
|
/// @param inN2 The world space normal in which the constraint operates for body 2
|
|
/// @param inRatio The ratio how forces are applied between bodies
|
|
/// </code>
|
|
/// </remarks>
|
|
public void CalculateConstraintProperties(
|
|
Body body1,
|
|
Body body2,
|
|
float3 r1,
|
|
float3 n1,
|
|
float3 r2,
|
|
float3 n2,
|
|
float ratio
|
|
) =>
|
|
Jolt.PInvoke.IndependentAxisConstraintPart_CalculateConstraintProperties(
|
|
this,
|
|
body1,
|
|
body2,
|
|
r1,
|
|
n1,
|
|
r2,
|
|
n2,
|
|
ratio
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Deactivate this constraint
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L123">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:123</see>
|
|
/// <br/>
|
|
/// <c>inline void Deactivate()</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public void Deactivate() => Jolt.PInvoke.IndependentAxisConstraintPart_Deactivate(this);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Check if constraint is active
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L130">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:130</see>
|
|
/// <br/>
|
|
/// <c>inline bool IsActive() const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public bool IsActive() => Jolt.PInvoke.IndependentAxisConstraintPart_IsActive(this);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L142">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:142</see>
|
|
/// <br/>
|
|
/// <c>inline void WarmStart(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inWarmStartImpulseRatio)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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 inN1 The world space normal in which the constraint operates for body 1
|
|
/// @param inN2 The world space normal in which the constraint operates for body 2
|
|
/// @param inRatio The ratio how forces are applied between bodies
|
|
/// @param inWarmStartImpulseRatio Ratio of new step to old time step (dt_new / dt_old) for scaling the lagrange multiplier of the previous frame
|
|
/// </code>
|
|
/// </remarks>
|
|
public void WarmStart(Body body1, Body body2, float3 n1, float3 n2, float ratio, float warmStartImpulseRatio) =>
|
|
Jolt.PInvoke.IndependentAxisConstraintPart_WarmStart(
|
|
this,
|
|
body1,
|
|
body2,
|
|
n1,
|
|
n2,
|
|
ratio,
|
|
warmStartImpulseRatio
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint
|
|
/// equation.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L156">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:156</see>
|
|
/// <br/>
|
|
/// <c>inline bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inMinLambda, float inMaxLambda)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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 inN1 The world space normal in which the constraint operates for body 1
|
|
/// @param inN2 The world space normal in which the constraint operates for body 2
|
|
/// @param inRatio The ratio how forces are applied between bodies
|
|
/// @param inMinLambda Minimum angular impulse to apply (N m s)
|
|
/// @param inMaxLambda Maximum angular impulse to apply (N m s)
|
|
/// </code>
|
|
/// </remarks>
|
|
public bool SolveVelocityConstraint(
|
|
Body body1,
|
|
Body body2,
|
|
float3 n1,
|
|
float3 n2,
|
|
float ratio,
|
|
float minLambda,
|
|
float maxLambda
|
|
) =>
|
|
Jolt.PInvoke.IndependentAxisConstraintPart_SolveVelocityConstraint(
|
|
this,
|
|
body1,
|
|
body2,
|
|
n1,
|
|
n2,
|
|
ratio,
|
|
minLambda,
|
|
maxLambda
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Return lagrange multiplier
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L170">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:170</see>
|
|
/// <br/>
|
|
/// <c>float GetTotalLambda() const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public float GetTotalLambda() => Jolt.PInvoke.IndependentAxisConstraintPart_GetTotalLambda(this);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Iteratively update the position constraint. Makes sure C(...) == 0.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h#L183">Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h:183</see>
|
|
/// <br/>
|
|
/// <c>inline bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inC, float inBaumgarte) const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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 inN1 The world space normal in which the constraint operates for body 1
|
|
/// @param inN2 The world space normal in which the constraint operates for body 2
|
|
/// @param inRatio The ratio how forces are applied between bodies
|
|
/// @param inC Value of the constraint equation (C)
|
|
/// @param inBaumgarte Baumgarte constant (fraction of the error to correct)
|
|
/// </code>
|
|
/// </remarks>
|
|
public bool SolvePositionConstraint(
|
|
Body body1,
|
|
Body body2,
|
|
float3 n1,
|
|
float3 n2,
|
|
float ratio,
|
|
float c,
|
|
float baumgarte
|
|
) =>
|
|
Jolt.PInvoke.IndependentAxisConstraintPart_SolvePositionConstraint(
|
|
this,
|
|
body1,
|
|
body2,
|
|
n1,
|
|
n2,
|
|
ratio,
|
|
c,
|
|
baumgarte
|
|
);
|
|
|
|
public void Dispose() => Jolt.PInvoke.IndependentAxisConstraintPart_Destroy(this);
|
|
}
|
|
}
|