Class Constraint
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Base class for constraints that connect two rigid bodies and restrict their relative motion.
public abstract class Constraint : IDebugDrawable
- Inheritance
-
Constraint
- Implements
- Derived
- Inherited Members
Fields
DefaultAngularBias
Default bias factor for angular error correction.
public const float DefaultAngularBias = 0.2
Field Value
DefaultAngularLimitBias
Default bias factor for angular limit correction.
public const float DefaultAngularLimitBias = 0.1
Field Value
DefaultAngularLimitSoftness
Default softness for angular limit enforcement.
public const float DefaultAngularLimitSoftness = 0.001
Field Value
DefaultAngularSoftness
Default softness (compliance) for angular constraints.
public const float DefaultAngularSoftness = 0.001
Field Value
DefaultLinearBias
Default bias factor for linear error correction.
public const float DefaultLinearBias = 0.2
Field Value
DefaultLinearLimitBias
Default bias factor for linear limit correction.
public const float DefaultLinearLimitBias = 0.2
Field Value
DefaultLinearLimitSoftness
Default softness for linear limit enforcement.
public const float DefaultLinearLimitSoftness = 0.0001
Field Value
DefaultLinearSoftness
Default softness (compliance) for linear constraints.
public const float DefaultLinearSoftness = 1E-05
Field Value
Properties
Body1
Gets the first rigid body connected by this constraint.
public RigidBody Body1 { get; }
Property Value
Body2
Gets the second rigid body connected by this constraint.
public RigidBody Body2 { get; }
Property Value
DispatchId
protected uint DispatchId { get; set; }
Property Value
Handle
A handle for accessing the raw constraint data.
public JHandle<ConstraintData> Handle { get; }
Property Value
IsEnabled
Gets or sets whether this constraint is enabled.
public bool IsEnabled { get; set; }
Property Value
Remarks
Use Remove(Constraint) for permanent removal. An enabled constraint is solved only while at least one connected body is dynamic and awake. Changing body motion types or activation states does not change this property.
IsSmallConstraint
Gets whether this constraint uses the smaller data layout.
public virtual bool IsSmallConstraint { get; }
Property Value
IsValid
Gets a value indicating whether the underlying constraint data is still valid.
public bool IsValid { get; }
Property Value
SmallHandle
Gets a handle to the constraint data reinterpreted as SmallConstraintData.
public JHandle<SmallConstraintData> SmallHandle { get; }
Property Value
Tag
Gets or sets application data associated with this constraint. The engine does not use this value.
public object? Tag { get; set; }
Property Value
Methods
CheckDataSize<T>()
Checks that the constraint data type fits within ConstraintData.
protected static void CheckDataSize<T>() where T : unmanaged
Type Parameters
TThe constraint-specific data type.
Exceptions
- InvalidOperationException
Thrown if the data type is too large.
Create()
Called when the world creates this constraint. Override to set DispatchId to the ID returned by registering the constraint's solver methods.
protected virtual void Create()
DebugDraw(IDebugDrawer)
Draws a debug visualization of this constraint.
public virtual void DebugDraw(IDebugDrawer drawer)
Parameters
drawerIDebugDrawerThe debug drawer to receive visualization primitives.
Exceptions
- NotImplementedException
Thrown if the derived class does not override this method.
DebugDraw(IDebugDrawer, in DebugDrawSettings)
Draws this constraint using the supplied visualization settings. Custom constraints that only override DebugDraw(IDebugDrawer) use their default visualization.
public virtual void DebugDraw(IDebugDrawer drawer, in DebugDrawSettings settings)
Parameters
drawerIDebugDrawersettingsDebugDrawSettings
FormatDescription(string)
Formats the constraint's ID, connected body IDs, and state using the supplied name.
protected string FormatDescription(string name)
Parameters
namestringThe constraint type name to display.
Returns
GetDebugDrawOrigin(in DebugDrawSettings)
Gets the display origin for an angular constraint, keeping world-relative guides near body 2.
protected JVector GetDebugDrawOrigin(in DebugDrawSettings settings)
Parameters
settingsDebugDrawSettings
Returns
RegisterFullConstraint(delegate*<ref ConstraintData, in TimeStep, void>, delegate*<ref ConstraintData, in TimeStep, void>)
protected static uint RegisterFullConstraint(delegate*<ref ConstraintData, in TimeStep, void> prepare, delegate*<ref ConstraintData, in TimeStep, void> iterate)
Parameters
preparedelegate*<ref ConstraintData, in TimeStep, void>iteratedelegate*<ref ConstraintData, in TimeStep, void>
Returns
RegisterSmallConstraint(delegate*<ref SmallConstraintData, in TimeStep, void>, delegate*<ref SmallConstraintData, in TimeStep, void>)
protected static uint RegisterSmallConstraint(delegate*<ref SmallConstraintData, in TimeStep, void> prepare, delegate*<ref SmallConstraintData, in TimeStep, void> iterate)
Parameters
preparedelegate*<ref SmallConstraintData, in TimeStep, void>iteratedelegate*<ref SmallConstraintData, in TimeStep, void>
Returns
ResetWarmStart()
Clears impulses saved from the previous solve, without changing constraint settings.
public virtual void ResetWarmStart()
Remarks
Use after restoring a saved state or making a sudden change to the bodies, when impulses from their previous state should no longer be reused.
ToString()
Returns a short description of the constraint's ID, connected bodies, and state.
public override string ToString()
Returns
VerifyNotZero()
Verifies that this constraint has been properly created via the World class.
protected void VerifyNotZero()
Exceptions
- InvalidOperationException
Thrown if the constraint was instantiated directly instead of through CreateConstraint<T>(RigidBody, RigidBody).