//
// 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
{
///
///
/// Quaternion based constraint that decomposes the rotation in constraint space in swing and twist: q = q_swing
/// * q_twist where q_swing.x = 0 and where q_twist.y = q_twist.z = 0
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:32
///
/// class SwingTwistConstraintPart
///
///
///
///
/// Quaternion based constraint that decomposes the rotation in constraint space in swing and twist: q = q_swing * q_twist
/// where q_swing.x = 0 and where q_twist.y = q_twist.z = 0
///
/// - Rotation around the twist (x-axis) is within [inTwistMinAngle, inTwistMaxAngle].
/// - Rotation around the swing axis (y and z axis) are limited to an ellipsoid in quaternion space formed by the equation:
///
/// (q_swing.y / sin(inSwingYHalfAngle / 2))^2 + (q_swing.z / sin(inSwingZHalfAngle / 2))^2 <= 1
///
/// Which roughly corresponds to an elliptic cone shape with major axis (inSwingYHalfAngle, inSwingZHalfAngle).
///
/// In case inSwingYHalfAngle = 0, the rotation around Y will be constrained to 0 and the rotation around Z
/// will be constrained between [-inSwingZHalfAngle, inSwingZHalfAngle]. Vice versa if inSwingZHalfAngle = 0.
///
///
[InteropHandle]
public readonly partial struct SwingTwistConstraintPart : IDisposable
{
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:549
///
/// enum ERotationFlags
///
///
[Flags]
public enum RotationFlags : int
{
///
///
/// Indicates that axis is completely locked (cannot rotate around this axis)
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:552
///
/// TwistXLocked = 1 << 0
///
///
TwistXLocked = 1,
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:553
///
/// SwingYLocked = 1 << 1
///
///
SwingYLocked = 2,
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:554
///
/// SwingZLocked = 1 << 2
///
///
SwingZLocked = 4,
///
///
/// Indicates that axis is completely free (can rotate around without limits)
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:557
///
/// TwistXFree = 1 << 3
///
///
TwistXFree = 8,
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:558
///
/// SwingYFree = 1 << 4
///
///
SwingYFree = 16,
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:559
///
/// SwingZFree = 1 << 5
///
///
SwingZFree = 32,
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:560
///
/// SwingYZFree = SwingYFree | SwingZFree
///
///
SwingYZFree = 48,
}
public static SwingTwistConstraintPart Create() => Jolt.PInvoke.SwingTwistConstraintPart_Create();
///
///
/// Override the swing type
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:36
///
/// void SetSwingType(ESwingType inSwingType)
///
///
public void SetSwingType(SwingType swingType) =>
Jolt.PInvoke.SwingTwistConstraintPart_SetSwingType(this, swingType);
///
///
/// Get the swing type for this part
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:42
///
/// ESwingType GetSwingType() const
///
///
public SwingType GetSwingType() => Jolt.PInvoke.SwingTwistConstraintPart_GetSwingType(this);
///
///
/// Set limits for this constraint (see description above for parameters)
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:48
///
/// void SetLimits(float inTwistMinAngle, float inTwistMaxAngle, float inSwingYMinAngle, float inSwingYMaxAngle, float inSwingZMinAngle, float inSwingZMaxAngle)
///
///
public void SetLimits(
float twistMinAngle,
float twistMaxAngle,
float swingYMinAngle,
float swingYMaxAngle,
float swingZMinAngle,
float swingZMaxAngle
) =>
Jolt.PInvoke.SwingTwistConstraintPart_SetLimits(
this,
twistMinAngle,
twistMaxAngle,
swingYMinAngle,
swingYMaxAngle,
swingZMinAngle,
swingZMaxAngle
);
///
///
/// Helper function to determine if we're clamped against the min or max limit
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:160
///
/// static bool sDistanceToMinShorter(float inDeltaMin, float inDeltaMax)
///
///
public static bool DistanceToMinShorter(float deltaMin, float deltaMax) =>
Jolt.PInvoke.SwingTwistConstraintPart_DistanceToMinShorter(deltaMin, deltaMax);
///
///
/// Clamp twist and swing against the constraint limits, returns which parts were clamped (everything
/// assumed in constraint space)
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:175
///
/// inline void ClampSwingTwist(Quat &ioSwing, Quat &ioTwist, uint &outClampedAxis) const
///
///
public void ClampSwingTwist(ref floatQuat swing, ref floatQuat twist, out uint clampedAxis) =>
Jolt.PInvoke.SwingTwistConstraintPart_ClampSwingTwist(this, ref swing, ref twist, out clampedAxis);
///
///
/// Calculate properties used during the functions below
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:337
///
/// inline void CalculateConstraintProperties(const Body &inBody1, const Body &inBody2, QuatArg inConstraintRotation, QuatArg inConstraintToWorld)
///
///
///
///
/// 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 inConstraintRotation The current rotation of the constraint in constraint space
/// @param inConstraintToWorld Rotates from constraint space into world space
///
///
public void CalculateConstraintProperties(
Body body1,
Body body2,
floatQuat constraintRotation,
floatQuat constraintToWorld
) =>
Jolt.PInvoke.SwingTwistConstraintPart_CalculateConstraintProperties(
this,
body1,
body2,
constraintRotation,
constraintToWorld
);
///
///
/// Deactivate this constraint
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:447
///
/// void Deactivate()
///
///
public void Deactivate() => Jolt.PInvoke.SwingTwistConstraintPart_Deactivate(this);
///
///
/// Check if constraint is active
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:455
///
/// inline bool IsActive() const
///
///
public bool IsActive() => Jolt.PInvoke.SwingTwistConstraintPart_IsActive(this);
///
///
/// Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:461
///
/// inline void WarmStart(Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
///
///
public void WarmStart(Body body1, Body body2, float warmStartImpulseRatio) =>
Jolt.PInvoke.SwingTwistConstraintPart_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/SwingTwistConstraintPart.h:469
///
/// inline bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2)
///
///
public bool SolveVelocityConstraint(Body body1, Body body2) =>
Jolt.PInvoke.SwingTwistConstraintPart_SolveVelocityConstraint(this, body1, body2);
///
///
/// Iteratively update the position constraint. Makes sure C(...) = 0.
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:493
///
/// inline bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, QuatArg inConstraintRotation, QuatArg inConstraintToBody1, QuatArg inConstraintToBody2, 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 inConstraintRotation The current rotation of the constraint in constraint space
/// @param inConstraintToBody1 , inConstraintToBody2 Rotates from constraint space to body 1/2 space
/// @param inBaumgarte Baumgarte constant (fraction of the error to correct)
///
///
public bool SolvePositionConstraint(
Body body1,
Body body2,
floatQuat constraintRotation,
floatQuat constraintToBody1,
floatQuat constraintToBody2,
float baumgarte
) =>
Jolt.PInvoke.SwingTwistConstraintPart_SolvePositionConstraint(
this,
body1,
body2,
constraintRotation,
constraintToBody1,
constraintToBody2,
baumgarte
);
///
///
/// Return lagrange multiplier for swing
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:514
///
/// inline float GetTotalSwingYLambda() const
///
///
public float GetTotalSwingYLambda() => Jolt.PInvoke.SwingTwistConstraintPart_GetTotalSwingYLambda(this);
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:519
///
/// inline float GetTotalSwingZLambda() const
///
///
public float GetTotalSwingZLambda() => Jolt.PInvoke.SwingTwistConstraintPart_GetTotalSwingZLambda(this);
///
///
/// Return lagrange multiplier for twist
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:525
///
/// inline float GetTotalTwistLambda() const
///
///
public float GetTotalTwistLambda() => Jolt.PInvoke.SwingTwistConstraintPart_GetTotalTwistLambda(this);
///
///
/// Flags to indicate which axis got clamped by ClampSwingTwist
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:152
///
/// static constexpr uint cClampedTwistMin = 1 << 0
///
///
public static uint GetClampedTwistMin() => Jolt.PInvoke.SwingTwistConstraintPart_GetClampedTwistMin();
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:153
///
/// static constexpr uint cClampedTwistMax = 1 << 1
///
///
public static uint GetClampedTwistMax() => Jolt.PInvoke.SwingTwistConstraintPart_GetClampedTwistMax();
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:154
///
/// static constexpr uint cClampedSwingYMin = 1 << 2
///
///
public static uint GetClampedSwingYMin() => Jolt.PInvoke.SwingTwistConstraintPart_GetClampedSwingYMin();
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:155
///
/// static constexpr uint cClampedSwingYMax = 1 << 3
///
///
public static uint GetClampedSwingYMax() => Jolt.PInvoke.SwingTwistConstraintPart_GetClampedSwingYMax();
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:156
///
/// static constexpr uint cClampedSwingZMin = 1 << 4
///
///
public static uint GetClampedSwingZMin() => Jolt.PInvoke.SwingTwistConstraintPart_GetClampedSwingZMin();
///
///
/// C++:
/// Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h:157
///
/// static constexpr uint cClampedSwingZMax = 1 << 5
///
///
public static uint GetClampedSwingZMax() => Jolt.PInvoke.SwingTwistConstraintPart_GetClampedSwingZMax();
public void Dispose() => Jolt.PInvoke.SwingTwistConstraintPart_Destroy(this);
}
}