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.
IsSmallConstraint
Gets whether this constraint uses the smaller data layout.
public virtual bool IsSmallConstraint { get; }
Property Value
SmallHandle
Gets a handle to the constraint data reinterpreted as SmallConstraintData.
public JHandle<SmallConstraintData> SmallHandle { get; }
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()
Sets the solver dispatch id used by this instance. Override this in derived classes to assign the correct registered solver pair. The id is later written into the unmanaged header when the constraint is enabled.
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.
RegisterFullConstraint(delegate*<ref ConstraintData, float, void>, delegate*<ref ConstraintData, float, void>)
protected static uint RegisterFullConstraint(delegate*<ref ConstraintData, float, void> prepare, delegate*<ref ConstraintData, float, void> iterate)
Parameters
preparedelegate*<ref ConstraintData, float, void>iteratedelegate*<ref ConstraintData, float, void>
Returns
RegisterSmallConstraint(delegate*<ref SmallConstraintData, float, void>, delegate*<ref SmallConstraintData, float, void>)
protected static uint RegisterSmallConstraint(delegate*<ref SmallConstraintData, float, void> prepare, delegate*<ref SmallConstraintData, float, void> iterate)
Parameters
preparedelegate*<ref SmallConstraintData, float, void>iteratedelegate*<ref SmallConstraintData, float, void>
Returns
ResetWarmStart()
Resets the cached warm-start state used by the solver for this constraint.
public virtual void ResetWarmStart()
Remarks
This clears only persistent solver impulses. Constraint configuration remains unchanged. Useful after restoring snapshots or other discontinuous state changes where preserving warm-starting is undesirable.
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).