Table of Contents

Class AngularServo

Namespace
Jitter2.Dynamics.Constraints
Assembly
Jitter2.dll

Drives body 2 toward a target orientation relative to body 1 using limited torque. Controls three angular degrees of freedom; translation remains free.

public class AngularServo : Constraint<AngularServo.AngularServoData>, IDebugDrawable
Inheritance
AngularServo
Implements
Inherited Members

Properties

Bias

Gets or sets how aggressively the servo corrects its position error.

public float Bias { get; set; }

Property Value

float

Default is DefaultAngularBias.

Impulse

Gets the world-space angular impulse applied to body 1 in the last solved substep.

public JVector Impulse { get; }

Property Value

JVector

MaximumTorque

Gets or sets the maximum total torque the servo can apply.

public float MaximumTorque { get; set; }

Property Value

float

Default is zero. Positive infinity allows unlimited torque.

Softness

Gets or sets the softness (compliance) of the servo.

public float Softness { get; set; }

Property Value

float

Default is DefaultAngularSoftness.

TargetRelativeOrientation

Gets or sets body 2's target orientation relative to body 1. Identity aligns their local frames. The value must be normalized. Changing it does not move either body.

public JQuaternion TargetRelativeOrientation { get; set; }

Property Value

JQuaternion

Remarks

The servo uses the shortest rotation to the target orientation. Revolution counts are not supported.

Methods

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 override void Create()

DebugDraw(IDebugDrawer)

Draws a debug visualization of this constraint.

public override 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.

DebugDraw(IDebugDrawer, in DebugDrawSettings)

Draws this constraint using the supplied visualization settings. Custom constraints that only override DebugDraw(IDebugDrawer) use their default visualization.

public override void DebugDraw(IDebugDrawer drawer, in DebugDrawSettings settings)

Parameters

drawer IDebugDrawer
settings DebugDrawSettings

Initialize()

Initializes the servo with the current relative orientation as its target.

public void Initialize()

Initialize(JQuaternion)

Initializes a target orientation for body 2 relative to body 1.

public void Initialize(JQuaternion targetRelativeOrientation)

Parameters

targetRelativeOrientation JQuaternion

A normalized orientation in body 1's frame.

Remarks

The bodies may start outside the target pose. Maximum torque defaults to zero.

IterateAngularServo(ref ConstraintData, in TimeStep)

public static void IterateAngularServo(ref ConstraintData constraint, in TimeStep timeStep)

Parameters

constraint ConstraintData
timeStep TimeStep

PrepareForIterationAngularServo(ref ConstraintData, in TimeStep)

public static void PrepareForIterationAngularServo(ref ConstraintData constraint, in TimeStep timeStep)

Parameters

constraint ConstraintData
timeStep TimeStep

ResetWarmStart()

Resets the cached warm-start state used by the solver for this constraint.

public override 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.