//
// 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
{
///
///
/// Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rigid
/// body.
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:107
///
/// class Constraint : public RefTarget<Constraint>, public NonCopyable
///
///
[InteropHandle]
public readonly partial struct Constraint : IDisposable
{
///
///
/// Get the type of a constraint
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:131
///
/// virtual EConstraintType GetType() const
///
///
public ConstraintType GetConstraintType() => Jolt.PInvoke.Constraint_GetConstraintType(this);
///
///
/// Get the sub type of a constraint
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:134
///
/// virtual EConstraintSubType GetSubType() const = 0
///
///
public ConstraintSubType GetSubType() => Jolt.PInvoke.Constraint_GetSubType(this);
///
///
/// Priority of the constraint when solving. Higher numbers have are more likely to be solved correctly.
/// Note that if you want a deterministic simulation and you cannot guarantee the order in which constraints
/// are added/removed, you can make the priority for all constraints unique to get a deterministic ordering.
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:138
///
/// uint32 GetConstraintPriority() const
///
///
public uint GetConstraintPriority() => Jolt.PInvoke.Constraint_GetConstraintPriority(this);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:139
///
/// void SetConstraintPriority(uint32 inPriority)
///
///
public void SetConstraintPriority(uint priority) =>
Jolt.PInvoke.Constraint_SetConstraintPriority(this, priority);
///
///
/// Used only when the constraint is active. Override for the number of solver velocity iterations to run, 0
/// means use the default in PhysicsSettings::mNumVelocitySteps. The number of iterations to use is the max
/// of all contacts and constraints in the island.
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:142
///
/// void SetNumVelocityStepsOverride(uint inN)
///
///
public void SetNumVelocityStepsOverride(uint n) => Jolt.PInvoke.Constraint_SetNumVelocityStepsOverride(this, n);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:143
///
/// uint GetNumVelocityStepsOverride() const
///
///
public uint GetNumVelocityStepsOverride() => Jolt.PInvoke.Constraint_GetNumVelocityStepsOverride(this);
///
///
/// Used only when the constraint is active. Override for the number of solver position iterations to run, 0
/// means use the default in PhysicsSettings::mNumPositionSteps. The number of iterations to use is the max
/// of all contacts and constraints in the island.
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:146
///
/// void SetNumPositionStepsOverride(uint inN)
///
///
public void SetNumPositionStepsOverride(uint n) => Jolt.PInvoke.Constraint_SetNumPositionStepsOverride(this, n);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:147
///
/// uint GetNumPositionStepsOverride() const
///
///
public uint GetNumPositionStepsOverride() => Jolt.PInvoke.Constraint_GetNumPositionStepsOverride(this);
///
///
/// Enable / disable this constraint. This can e.g. be used to implement a breakable constraint by detecting
/// that the constraint impulse (see e.g. PointConstraint::GetTotalLambdaPosition) went over a certain limit
/// and then disabling the constraint. Note that although a disabled constraint will not affect the
/// simulation in any way anymore, it does incur some processing overhead. Alternatively you can remove a
/// constraint from the constraint manager (which may be more costly if you want to disable the constraint
/// for a short while).
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:153
///
/// void SetEnabled(bool inEnabled)
///
///
public void SetEnabled(bool enabled) => Jolt.PInvoke.Constraint_SetEnabled(this, enabled);
///
///
/// Test if a constraint is enabled.
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:156
///
/// bool GetEnabled() const
///
///
public bool GetEnabled() => Jolt.PInvoke.Constraint_GetEnabled(this);
///
///
/// Access to the user data, can be used for anything by the application
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:159
///
/// uint64 GetUserData() const
///
///
public ulong GetUserData() => Jolt.PInvoke.Constraint_GetUserData(this);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:160
///
/// void SetUserData(uint64 inUserData)
///
///
public void SetUserData(ulong userData) => Jolt.PInvoke.Constraint_SetUserData(this, userData);
///
///
/// Notify the constraint that the shape of a body has changed and that its center of mass has moved by
/// inDeltaCOM. Bodies don't know which constraints are connected to them so the user is responsible for
/// notifying the relevant constraints when a body changes.
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:166
///
/// virtual void NotifyShapeChanged(const BodyID &inBodyID, Vec3Arg inDeltaCOM) = 0
///
///
///
///
/// Notify the constraint that the shape of a body has changed and that its center of mass has moved by inDeltaCOM.
/// Bodies don't know which constraints are connected to them so the user is responsible for notifying the relevant constraints when a body changes.
/// @param inBodyID ID of the body that has changed
/// @param inDeltaCOM The delta of the center of mass of the body (shape->GetCenterOfMass() - shape_before_change->GetCenterOfMass())
///
///
public void NotifyShapeChanged(uint bodyID, float3 deltaCOM) =>
Jolt.PInvoke.Constraint_NotifyShapeChanged(this, bodyID, deltaCOM);
///
///
/// Notify the system that the configuration of the bodies and/or constraint has changed enough so that the
/// warm start impulses should not be applied the next frame. You can use this function for example when
/// repositioning a ragdoll through Ragdoll::SetPose in such a way that the orientation of the bodies
/// completely changes so that the previous frame impulses are no longer a good approximation of what the
/// impulses will be in the next frame. Calling this function when there are no big changes will result in
/// the constraints being much 'softer' than usual so they are more easily violated (e.g. a long chain of
/// bodies might sag a bit if you call this every frame).
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:172
///
/// virtual void ResetWarmStart() = 0
///
///
public void ResetWarmStart() => Jolt.PInvoke.Constraint_ResetWarmStart(this);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:176
///
/// virtual bool IsActive() const
///
///
///
///
/// @name Solver interface
/// @{
///
///
public bool IsActive() => Jolt.PInvoke.Constraint_IsActive(this);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:177
///
/// virtual void SetupVelocityConstraint(float inDeltaTime) = 0
///
///
public void SetupVelocityConstraint(float deltaTime) =>
Jolt.PInvoke.Constraint_SetupVelocityConstraint(this, deltaTime);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:178
///
/// virtual void WarmStartVelocityConstraint(float inWarmStartImpulseRatio) = 0
///
///
public void WarmStartVelocityConstraint(float warmStartImpulseRatio) =>
Jolt.PInvoke.Constraint_WarmStartVelocityConstraint(this, warmStartImpulseRatio);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:179
///
/// virtual bool SolveVelocityConstraint(float inDeltaTime) = 0
///
///
public bool SolveVelocityConstraint(float deltaTime) =>
Jolt.PInvoke.Constraint_SolveVelocityConstraint(this, deltaTime);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:180
///
/// virtual bool SolvePositionConstraint(float inDeltaTime, float inBaumgarte) = 0
///
///
public bool SolvePositionConstraint(float deltaTime, float baumgarte) =>
Jolt.PInvoke.Constraint_SolvePositionConstraint(this, deltaTime, baumgarte);
///
///
/// Link bodies that are connected by this constraint in the island builder
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:184
///
/// virtual void BuildIslands(uint32 inConstraintIndex, IslandBuilder &ioBuilder, BodyManager &inBodyManager) = 0
///
///
public void BuildIslands(uint constraintIndex, IslandBuilder builder, BodyManager bodyManager) =>
Jolt.PInvoke.Constraint_BuildIslands(this, constraintIndex, builder, bodyManager);
///
///
/// Link bodies that are connected by this constraint in the same split. Returns the split index.
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:187
///
/// virtual uint BuildIslandSplits(LargeIslandSplitter &ioSplitter) const = 0
///
///
public uint BuildIslandSplits(LargeIslandSplitter splitter) =>
Jolt.PInvoke.Constraint_BuildIslandSplits(this, splitter);
///
///
/// Drawing interface
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:191
///
/// virtual void DrawConstraint(DebugRenderer *inRenderer) const = 0
///
///
public void DrawConstraint(DebugRenderer renderer) => Jolt.PInvoke.Constraint_DrawConstraint(this, renderer);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:192
///
/// virtual void DrawConstraintLimits(DebugRenderer *inRenderer) const
///
///
public void DrawConstraintLimits(DebugRenderer renderer) =>
Jolt.PInvoke.Constraint_DrawConstraintLimits(this, renderer);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:193
///
/// virtual void DrawConstraintReferenceFrame(DebugRenderer *inRenderer) const
///
///
public void DrawConstraintReferenceFrame(DebugRenderer renderer) =>
Jolt.PInvoke.Constraint_DrawConstraintReferenceFrame(this, renderer);
///
///
/// Size of constraint when drawing it through the debug renderer
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:196
///
/// float GetDrawConstraintSize() const
///
///
public float GetDrawConstraintSize() => Jolt.PInvoke.Constraint_GetDrawConstraintSize(this);
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:197
///
/// void SetDrawConstraintSize(float inSize)
///
///
public void SetDrawConstraintSize(float size) => Jolt.PInvoke.Constraint_SetDrawConstraintSize(this, size);
///
///
/// Debug function to convert a constraint to its settings, note that this will not save to which bodies the
/// constraint is connected to
///
///
/// C++:
/// Jolt/Physics/Constraints/Constraint.h:207
///
/// virtual Ref<ConstraintSettings> GetConstraintSettings() const = 0
///
///
///
///
/// The returned handle carries its own reference; Dispose it once when you're done.
///
///
public ConstraintSettings GetConstraintSettings() => Jolt.PInvoke.Constraint_GetConstraintSettings(this);
///
///
/// Views this Constraint as the TwoBodyConstraint it is, or returns a null handle when it is a different
/// kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public TwoBodyConstraint AsTwoBodyConstraint() => Jolt.PInvoke.Constraint_AsTwoBodyConstraint(this);
///
///
/// Views this Constraint as the FixedConstraint it is, or returns a null handle when it is a different kind
/// - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public FixedConstraint AsFixedConstraint() => Jolt.PInvoke.Constraint_AsFixedConstraint(this);
///
///
/// Views this Constraint as the PointConstraint it is, or returns a null handle when it is a different kind
/// - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public PointConstraint AsPointConstraint() => Jolt.PInvoke.Constraint_AsPointConstraint(this);
///
///
/// Views this Constraint as the HingeConstraint it is, or returns a null handle when it is a different kind
/// - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public HingeConstraint AsHingeConstraint() => Jolt.PInvoke.Constraint_AsHingeConstraint(this);
///
///
/// Views this Constraint as the SliderConstraint it is, or returns a null handle when it is a different
/// kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public SliderConstraint AsSliderConstraint() => Jolt.PInvoke.Constraint_AsSliderConstraint(this);
///
///
/// Views this Constraint as the DistanceConstraint it is, or returns a null handle when it is a different
/// kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public DistanceConstraint AsDistanceConstraint() => Jolt.PInvoke.Constraint_AsDistanceConstraint(this);
///
///
/// Views this Constraint as the ConeConstraint it is, or returns a null handle when it is a different kind
/// - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public ConeConstraint AsConeConstraint() => Jolt.PInvoke.Constraint_AsConeConstraint(this);
///
///
/// Views this Constraint as the SwingTwistConstraint it is, or returns a null handle when it is a different
/// kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public SwingTwistConstraint AsSwingTwistConstraint() => Jolt.PInvoke.Constraint_AsSwingTwistConstraint(this);
///
///
/// Views this Constraint as the SixDOFConstraint it is, or returns a null handle when it is a different
/// kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public SixDOFConstraint AsSixDOFConstraint() => Jolt.PInvoke.Constraint_AsSixDOFConstraint(this);
///
///
/// Views this Constraint as the PathConstraint it is, or returns a null handle when it is a different kind
/// - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public PathConstraint AsPathConstraint() => Jolt.PInvoke.Constraint_AsPathConstraint(this);
///
///
/// Views this Constraint as the VehicleConstraint it is, or returns a null handle when it is a different
/// kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public VehicleConstraint AsVehicleConstraint() => Jolt.PInvoke.Constraint_AsVehicleConstraint(this);
///
///
/// Views this Constraint as the RackAndPinionConstraint it is, or returns a null handle when it is a
/// different kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public RackAndPinionConstraint AsRackAndPinionConstraint() =>
Jolt.PInvoke.Constraint_AsRackAndPinionConstraint(this);
///
///
/// Views this Constraint as the GearConstraint it is, or returns a null handle when it is a different kind
/// - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public GearConstraint AsGearConstraint() => Jolt.PInvoke.Constraint_AsGearConstraint(this);
///
///
/// Views this Constraint as the PulleyConstraint it is, or returns a null handle when it is a different
/// kind - check IsNull(). The same object, not a new reference: never Dispose the result.
///
///
public PulleyConstraint AsPulleyConstraint() => Jolt.PInvoke.Constraint_AsPulleyConstraint(this);
public void AddRef() => Jolt.PInvoke.Constraint_AddRef(this);
public void Release() => Jolt.PInvoke.Constraint_Release(this);
public uint GetRefCount() => Jolt.PInvoke.Constraint_GetRefCount(this);
public void Dispose()
{
if (IsNull())
return;
Release();
}
}
}