Table of Contents

Class TwistServo

Namespace
Jitter2.Dynamics.Constraints
Assembly
Jitter2.dll

Drives relative twist toward a target angle using limited torque. Controls one angular degree of freedom; translation and swing remain free.

public class TwistServo : Constraint<TwistServo.TwistServoData>, IDebugDrawable
Inheritance
TwistServo
Implements
Inherited Members

Remarks

Uses signed joint angles in [-pi, pi], without tracking revolutions. Combine with mechanical limits that keep motion inside this angular interval.

Properties

Angle

Gets the current relative twist angle in [-pi, pi]. Revolutions are not tracked.

public JAngle Angle { get; }

Property Value

JAngle

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 signed angular impulse in the last solved substep.

public float Impulse { get; }

Property Value

float

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.

TargetAngle

Gets or sets the desired twist angle relative to the initial zero-twist pose.

public JAngle TargetAngle { get; set; }

Property Value

JAngle

Remarks

The target must be in [-pi, pi]. The signed angle error is not wrapped: moving from -170 to +170 degrees travels through zero. Revolution counts are not supported.

Exceptions

ArgumentOutOfRangeException

The value is not finite or is outside [-pi, pi].

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(JVector, JAngle)

Initializes both twist axes from the same world-space direction.

public void Initialize(JVector axis, JAngle targetAngle = default)

Parameters

axis JVector
targetAngle JAngle

Initialize(JVector, JVector, JAngle)

Initializes separate world-space twist axes and a target relative to the initial pose.

public void Initialize(JVector axis1, JVector axis2, JAngle targetAngle = default)

Parameters

axis1 JVector
axis2 JVector
targetAngle JAngle

Remarks

The shortest rotation aligning the two axes defines zero twist. Maximum torque defaults to zero. A nonzero target angle starts the servo outside its target configuration.

Exceptions

ArgumentOutOfRangeException

The target angle is not finite or is outside [-pi, pi].

IterateTwistServo(ref ConstraintData, in TimeStep)

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

Parameters

constraint ConstraintData
timeStep TimeStep

PrepareForIterationTwistServo(ref ConstraintData, in TimeStep)

public static void PrepareForIterationTwistServo(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.