Table of Contents

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

float

DefaultAngularLimitBias

Default bias factor for angular limit correction.

public const float DefaultAngularLimitBias = 0.1

Field Value

float

DefaultAngularLimitSoftness

Default softness for angular limit enforcement.

public const float DefaultAngularLimitSoftness = 0.001

Field Value

float

DefaultAngularSoftness

Default softness (compliance) for angular constraints.

public const float DefaultAngularSoftness = 0.001

Field Value

float

DefaultLinearBias

Default bias factor for linear error correction.

public const float DefaultLinearBias = 0.2

Field Value

float

DefaultLinearLimitBias

Default bias factor for linear limit correction.

public const float DefaultLinearLimitBias = 0.2

Field Value

float

DefaultLinearLimitSoftness

Default softness for linear limit enforcement.

public const float DefaultLinearLimitSoftness = 0.0001

Field Value

float

DefaultLinearSoftness

Default softness (compliance) for linear constraints.

public const float DefaultLinearSoftness = 1E-05

Field Value

float

Properties

Body1

Gets the first rigid body connected by this constraint.

public RigidBody Body1 { get; }

Property Value

RigidBody

Body2

Gets the second rigid body connected by this constraint.

public RigidBody Body2 { get; }

Property Value

RigidBody

DispatchId

protected uint DispatchId { get; set; }

Property Value

uint

Handle

A handle for accessing the raw constraint data.

public JHandle<ConstraintData> Handle { get; }

Property Value

JHandle<ConstraintData>

IsEnabled

Gets or sets whether this constraint is enabled.

public bool IsEnabled { get; set; }

Property Value

bool

Remarks

Use Remove(Constraint) for permanent removal.

IsSmallConstraint

Gets whether this constraint uses the smaller data layout.

public virtual bool IsSmallConstraint { get; }

Property Value

bool

SmallHandle

Gets a handle to the constraint data reinterpreted as SmallConstraintData.

public JHandle<SmallConstraintData> SmallHandle { get; }

Property Value

JHandle<SmallConstraintData>

Methods

CheckDataSize<T>()

Checks that the constraint data type fits within ConstraintData.

protected static void CheckDataSize<T>() where T : unmanaged

Type Parameters

T

The 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

drawer IDebugDrawer

The 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

prepare delegate*<ref ConstraintData, float, void>
iterate delegate*<ref ConstraintData, float, void>

Returns

uint

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

prepare delegate*<ref SmallConstraintData, float, void>
iterate delegate*<ref SmallConstraintData, float, void>

Returns

uint

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).