Class LinearMotor
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
A motor constraint that drives relative translational velocity along an axis fixed in the reference frame of each body.
public class LinearMotor : Constraint<LinearMotor.LinearMotorData>, IDebugDrawable
- Inheritance
-
LinearMotor
- Implements
- Inherited Members
Properties
Impulse
Gets the accumulated impulse applied by this motor during the last step.
public float Impulse { get; }
Property Value
LocalAxis1
Gets or sets the motor axis on the first body in local space.
public JVector LocalAxis1 { get; set; }
Property Value
Exceptions
- ArgumentException
Thrown when the assigned value is not finite or normalized.
LocalAxis2
Gets or sets the motor axis on the second body in local space.
public JVector LocalAxis2 { get; set; }
Property Value
Exceptions
- ArgumentException
Thrown when the assigned value is not finite or normalized.
MaximumForce
Gets or sets the maximum force the motor can apply.
public float MaximumForce { get; set; }
Property Value
- float
Default is 0. Must be non-negative.
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis negative.
TargetVelocity
Gets or sets the target linear velocity in units per second.
public float TargetVelocity { get; set; }
Property Value
- float
Default is 0.
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.
Initialize(JVector, JVector)
Initializes the motor with axes for each body.
public void Initialize(JVector axis1, JVector axis2)
Parameters
axis1JVectorMotor axis on the first body in world space.
axis2JVectorMotor axis on the second body in world space.
Remarks
Stores the axes in local frames. Both axes are normalized internally. Default values: TargetVelocity = 0, MaximumForce = 0.
Exceptions
- ArgumentException
Thrown when
axis1oraxis2is zero or contains a non-finite value.
IterateLinearMotor(ref ConstraintData, float)
public static void IterateLinearMotor(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat
PrepareForIterationLinearMotor(ref ConstraintData, float)
public static void PrepareForIterationLinearMotor(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat
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.