Class LinearAxisServo
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Drives the signed separation of two anchors along an axis attached to body 1 using limited force. Controls one translational degree of freedom; perpendicular movement and rotation remain free.
public class LinearAxisServo : Constraint<LinearAxisServo.LinearAxisServoData>, IDebugDrawable
- Inheritance
-
LinearAxisServo
- 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
Anchor2
Gets or sets the world-space anchor attached to body 2.
[ReferenceFrame(ReferenceFrame.World)]
public JVector Anchor2 { get; set; }
Property Value
Axis
Gets or sets the world-space direction attached to body 1, normalized internally.
[ReferenceFrame(ReferenceFrame.World)]
public JVector Axis { get; set; }
Property Value
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 signed impulse applied along the axis to body 2 in the last solved substep.
public float Impulse { get; }
Property Value
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.
Position
Gets the current signed separation of the anchors along the axis.
public float Position { get; }
Property Value
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 signed separation along the axis. Default is zero.
public float TargetPosition { get; set; }
Property Value
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
drawerIDebugDrawerThe 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
drawerIDebugDrawersettingsDebugDrawSettings
Initialize(JVector, JVector, JVector, float)
Initializes world-space anchors and an axis attached to body 1.
public void Initialize(JVector axis, JVector anchor1, JVector anchor2, float targetPosition = 0)
Parameters
axisJVectorThe direction along which the servo acts, normalized internally.
anchor1JVectorThe origin attached to body 1.
anchor2JVectorThe anchor attached to body 2.
targetPositionfloatThe desired signed separation along the axis.
Remarks
Maximum force defaults to zero. The current separation may differ from the target.
IterateLinearAxisServo(ref ConstraintData, in TimeStep)
public static void IterateLinearAxisServo(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
PrepareForIterationLinearAxisServo(ref ConstraintData, in TimeStep)
public static void PrepareForIterationLinearAxisServo(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
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.