mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
402 lines
19 KiB
C#
402 lines
19 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 that constrains motion along 1 axis
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L41">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:41</see>
|
|
/// <br/>
|
|
/// <c>class AxisConstraintPart</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// Constraint that constrains motion along 1 axis
|
|
///
|
|
/// @see "Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.1.1
|
|
/// (we're not using the approximation of eq 27 but instead add the U term as in eq 55)
|
|
///
|
|
/// Constraint equation (eq 25):
|
|
///
|
|
/// \f[C = (p_2 - p_1) \cdot n\f]
|
|
///
|
|
/// Jacobian (eq 28):
|
|
///
|
|
/// \f[J = \begin{bmatrix} -n^T & (-(r_1 + u) \times n)^T & n^T & (r_2 \times n)^T \end{bmatrix}\f]
|
|
///
|
|
/// Used terms (here and below, everything in world space):\n
|
|
/// n = constraint axis (normalized).\n
|
|
/// p1, p2 = constraint points.\n
|
|
/// r1 = p1 - x1.\n
|
|
/// r2 = p2 - x2.\n
|
|
/// u = x2 + r2 - x1 - r1 = p2 - p1.\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 AxisConstraintPart : IDisposable
|
|
{
|
|
public static AxisConstraintPart Create() => Jolt.PInvoke.AxisConstraintPart_Create();
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Calculate properties used during the functions below. Creates a constraint without spring.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L145">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:145</see>
|
|
/// <br/>
|
|
/// <c>inline void CalculateConstraintProperties(const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias = 0.0f)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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 inR1PlusU See equations above (r1 + u)
|
|
/// @param inR2 See equations above (r2)
|
|
/// @param inWorldSpaceAxis Axis along which the constraint acts (normalized, pointing from body 1 to 2)
|
|
/// @param inBias Bias term (b) for the constraint impulse: lambda = J v + b
|
|
/// </code>
|
|
/// </remarks>
|
|
public void CalculateConstraintProperties(
|
|
Body body1,
|
|
float3 r1PlusU,
|
|
Body body2,
|
|
float3 r2,
|
|
float3 worldSpaceAxis,
|
|
float bias = 0f
|
|
) =>
|
|
Jolt.PInvoke.AxisConstraintPart_CalculateConstraintProperties(
|
|
this,
|
|
body1,
|
|
r1PlusU,
|
|
body2,
|
|
r2,
|
|
worldSpaceAxis,
|
|
bias
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Calculate properties used during the functions below. Set inFrequency to zero if you don't want to drive
|
|
/// using a spring.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L169">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:169</see>
|
|
/// <br/>
|
|
/// <c>inline void CalculateConstraintPropertiesWithFrequencyAndDamping(float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inFrequency, float inDamping)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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 inR1PlusU See equations above (r1 + u)
|
|
/// @param inR2 See equations above (r2)
|
|
/// @param inWorldSpaceAxis Axis along which the constraint acts (normalized, pointing from body 1 to 2)
|
|
/// @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).
|
|
/// </code>
|
|
/// </remarks>
|
|
public void CalculateConstraintPropertiesWithFrequencyAndDamping(
|
|
float deltaTime,
|
|
Body body1,
|
|
float3 r1PlusU,
|
|
Body body2,
|
|
float3 r2,
|
|
float3 worldSpaceAxis,
|
|
float bias,
|
|
float c,
|
|
float frequency,
|
|
float damping
|
|
) =>
|
|
Jolt.PInvoke.AxisConstraintPart_CalculateConstraintPropertiesWithFrequencyAndDamping(
|
|
this,
|
|
deltaTime,
|
|
body1,
|
|
r1PlusU,
|
|
body2,
|
|
r2,
|
|
worldSpaceAxis,
|
|
bias,
|
|
c,
|
|
frequency,
|
|
damping
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Calculate properties used during the functions below. Set inFrequency and inDamping to zero if you don't
|
|
/// want to drive using a spring.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L195">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:195</see>
|
|
/// <br/>
|
|
/// <c>inline void CalculateConstraintPropertiesWithStiffnessAndDamping(float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inStiffness, float inDamping)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// Calculate properties used during the functions below. Set inFrequency 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 inR1PlusU See equations above (r1 + u)
|
|
/// @param inR2 See equations above (r2)
|
|
/// @param inWorldSpaceAxis Axis along which the constraint acts (normalized, pointing from body 1 to 2)
|
|
/// @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.
|
|
/// </code>
|
|
/// </remarks>
|
|
public void CalculateConstraintPropertiesWithStiffnessAndDamping(
|
|
float deltaTime,
|
|
Body body1,
|
|
float3 r1PlusU,
|
|
Body body2,
|
|
float3 r2,
|
|
float3 worldSpaceAxis,
|
|
float bias,
|
|
float c,
|
|
float stiffness,
|
|
float damping
|
|
) =>
|
|
Jolt.PInvoke.AxisConstraintPart_CalculateConstraintPropertiesWithStiffnessAndDamping(
|
|
this,
|
|
deltaTime,
|
|
body1,
|
|
r1PlusU,
|
|
body2,
|
|
r2,
|
|
worldSpaceAxis,
|
|
bias,
|
|
c,
|
|
stiffness,
|
|
damping
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Calculate properties used during the functions below based on inSpringSettings. Turns to a hard limit
|
|
/// when inSpringSettings has stiffness / frequency = 0
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L212">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:212</see>
|
|
/// <br/>
|
|
/// <c>inline void CalculateConstraintPropertiesWithSettingsForLimit(float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, const SpringSettings &inSpringSettings)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public void CalculateConstraintPropertiesWithSettingsForLimit(
|
|
float deltaTime,
|
|
Body body1,
|
|
float3 r1PlusU,
|
|
Body body2,
|
|
float3 r2,
|
|
float3 worldSpaceAxis,
|
|
float bias,
|
|
float c,
|
|
SpringSettings springSettings
|
|
) =>
|
|
Jolt.PInvoke.AxisConstraintPart_CalculateConstraintPropertiesWithSettingsForLimit(
|
|
this,
|
|
deltaTime,
|
|
body1,
|
|
r1PlusU,
|
|
body2,
|
|
r2,
|
|
worldSpaceAxis,
|
|
bias,
|
|
c,
|
|
springSettings
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Calculate properties used during the functions below based on inSpringSettings. Assumes the spring has
|
|
/// either stiffness or damping.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L229">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:229</see>
|
|
/// <br/>
|
|
/// <c>inline void CalculateConstraintPropertiesWithSettingsForMotor(float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, const SpringSettings &inSpringSettings)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public void CalculateConstraintPropertiesWithSettingsForMotor(
|
|
float deltaTime,
|
|
Body body1,
|
|
float3 r1PlusU,
|
|
Body body2,
|
|
float3 r2,
|
|
float3 worldSpaceAxis,
|
|
float bias,
|
|
float c,
|
|
SpringSettings springSettings
|
|
) =>
|
|
Jolt.PInvoke.AxisConstraintPart_CalculateConstraintPropertiesWithSettingsForMotor(
|
|
this,
|
|
deltaTime,
|
|
body1,
|
|
r1PlusU,
|
|
body2,
|
|
r2,
|
|
worldSpaceAxis,
|
|
bias,
|
|
c,
|
|
springSettings
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Deactivate this constraint
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L242">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:242</see>
|
|
/// <br/>
|
|
/// <c>inline void Deactivate()</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public void Deactivate() => Jolt.PInvoke.AxisConstraintPart_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/AxisConstraintPart.h#L249">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:249</see>
|
|
/// <br/>
|
|
/// <c>inline bool IsActive() const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public bool IsActive() => Jolt.PInvoke.AxisConstraintPart_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/AxisConstraintPart.h#L259">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:259</see>
|
|
/// <br/>
|
|
/// <c>inline void WarmStart(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, 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 inWorldSpaceAxis Axis along which the constraint acts (normalized)
|
|
/// @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 worldSpaceAxis, float warmStartImpulseRatio) =>
|
|
Jolt.PInvoke.AxisConstraintPart_WarmStart(this, body1, body2, worldSpaceAxis, 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/AxisConstraintPart.h#L272">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:272</see>
|
|
/// <br/>
|
|
/// <c>inline bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, 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 inWorldSpaceAxis Axis along which the constraint acts (normalized)
|
|
/// @param inMinLambda Minimum value of constraint impulse to apply (N s)
|
|
/// @param inMaxLambda Maximum value of constraint impulse to apply (N s)
|
|
/// </code>
|
|
/// </remarks>
|
|
public bool SolveVelocityConstraint(
|
|
Body body1,
|
|
Body body2,
|
|
float3 worldSpaceAxis,
|
|
float minLambda,
|
|
float maxLambda
|
|
) =>
|
|
Jolt.PInvoke.AxisConstraintPart_SolveVelocityConstraint(
|
|
this,
|
|
body1,
|
|
body2,
|
|
worldSpaceAxis,
|
|
minLambda,
|
|
maxLambda
|
|
);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Return lagrange multiplier
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h#L310">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:310</see>
|
|
/// <br/>
|
|
/// <c>float GetTotalLambda() const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public float GetTotalLambda() => Jolt.PInvoke.AxisConstraintPart_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/AxisConstraintPart.h#L321">Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h:321</see>
|
|
/// <br/>
|
|
/// <c>inline bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, 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 inWorldSpaceAxis Axis along which the constraint acts (normalized)
|
|
/// @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 worldSpaceAxis, float c, float baumgarte) =>
|
|
Jolt.PInvoke.AxisConstraintPart_SolvePositionConstraint(this, body1, body2, worldSpaceAxis, c, baumgarte);
|
|
|
|
public void Dispose() => Jolt.PInvoke.AxisConstraintPart_Destroy(this);
|
|
}
|
|
}
|