Table of Contents

Class LinearServo

Namespace
Jitter2.Dynamics.Constraints
Assembly
Jitter2.dll

Drives an anchor on body 2 toward a target position attached to body 1 using limited force. Controls three translational degrees of freedom; relative orientation remains free.

public class LinearServo : Constraint<LinearServo.LinearServoData>, IDebugDrawable
Inheritance
LinearServo
Implements
Inherited Members

Properties

Anchor1

Gets or sets the world-space anchor attached to body 1.

[ReferenceFrame(ReferenceFrame.World)]
public JVector Anchor1 { get; set; }

Property Value

JVector

Anchor2

Gets or sets the world-space anchor attached to body 2.

[ReferenceFrame(ReferenceFrame.World)]
public JVector Anchor2 { get; set; }

Property Value

JVector

Bias

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

public float Bias { get; set; }

Property Value

float

Default is DefaultLinearBias.

Impulse

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

public JVector Impulse { get; }

Property Value

JVector

MaximumForce

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

public float MaximumForce { get; set; }

Property Value

float

Default is zero. Positive infinity allows unlimited force.

Softness

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

public float Softness { get; set; }

Property Value

float

Default is DefaultLinearSoftness.

TargetPosition

Gets or sets the desired offset from anchor 1 to anchor 2, expressed in body 1's local frame. Zero drives the anchors toward coincidence. Changing it does not move either body.

public JVector TargetPosition { get; set; }

Property Value

JVector

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)

Initializes both body anchors at the same world-space point.

public void Initialize(JVector anchor)

Parameters

anchor JVector

Initialize(JVector, JVector)

Initializes separate world-space anchors that the servo drives toward coincidence.

public void Initialize(JVector anchor1, JVector anchor2)

Parameters

anchor1 JVector
anchor2 JVector

Remarks

Target position and maximum force default to zero. The anchors may start apart.

IterateLinearServo(ref ConstraintData, in TimeStep)

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

Parameters

constraint ConstraintData
timeStep TimeStep

PrepareForIterationLinearServo(ref ConstraintData, in TimeStep)

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