Class DistanceLimit
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Constrains the distance between a fixed point in the reference frame of one body and a fixed point in the reference frame of another body. This constraint removes one translational degree of freedom. For a distance of zero, use the BallSocket constraint.
public class DistanceLimit : Constraint<DistanceLimit.DistanceLimitData>, IDebugDrawable
- Inheritance
-
DistanceLimit
- Implements
- Inherited Members
Properties
Anchor1
Gets or sets the anchor point on the first rigid body in world space. The anchor point is fixed in the local reference frame of the first body.
[ReferenceFrame(ReferenceFrame.World)]
public JVector Anchor1 { get; set; }
Property Value
Anchor2
Gets or sets the anchor point on the second rigid body in world space. The anchor point is fixed in the local reference frame of the second body.
[ReferenceFrame(ReferenceFrame.World)]
public JVector Anchor2 { get; set; }
Property Value
Bias
Gets or sets the bias factor controlling how aggressively distance error is corrected.
public float Bias { get; set; }
Property Value
- float
Default is 0.2. Range [0, 1]. Higher values correct errors faster but may cause instability.
Distance
Gets the current distance between anchor points in world space.
public float Distance { get; }
Property Value
Impulse
Gets the accumulated impulse applied by this constraint during the last step.
public float Impulse { get; }
Property Value
Softness
Gets or sets the softness (compliance) of the constraint.
public float Softness { get; set; }
Property Value
- float
Default is 0.001. Higher values allow more distance error but improve stability.
TargetDistance
Gets or sets the target distance between anchor points.
public float TargetDistance { get; set; }
Property Value
- float
Set during initialization from the initial anchor separation.
Methods
Create()
Sets the Iterate and PrepareForIteration function pointer fields on this instance. Override this in derived classes to assign the correct solver methods. The pointers are later written into ConstraintData 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 constraint with a fixed distance between anchor points.
public void Initialize(JVector anchor1, JVector anchor2)
Parameters
anchor1JVectorAnchor point on the first body in world space.
anchor2JVectorAnchor point on the second body in world space.
Initialize(JVector, JVector, LinearLimit)
Initializes the constraint with distance limits between anchor points.
public void Initialize(JVector anchor1, JVector anchor2, LinearLimit limit)
Parameters
anchor1JVectorAnchor point on the first body in world space.
anchor2JVectorAnchor point on the second body in world space.
limitLinearLimitThe allowed distance range between anchor points.
Remarks
Computes local anchor points and the initial distance from current poses. Default values: Softness = DefaultLinearSoftness, Bias = DefaultLinearBias.
IterateFixedAngle(ref ConstraintData, float)
public static void IterateFixedAngle(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat
PrepareForIterationFixedAngle(ref ConstraintData, float)
public static void PrepareForIterationFixedAngle(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat