Class ConeLimit
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Limits the angle between axes attached to two bodies, leaving twist and translation free.
public class ConeLimit : Constraint<ConeLimit.ConeLimitData>, IDebugDrawable
- Inheritance
-
ConeLimit
- Implements
- Inherited Members
Remarks
Fixed tilts must lie strictly between zero and pi. Use HingeAngle with Full to keep axes aligned while allowing rotation about them.
Properties
Angle
Gets the current angle between the two body axes.
public JAngle Angle { get; }
Property Value
AxisBody1
Gets or sets the reference axis of body 1 in world space.
public JVector AxisBody1 { get; set; }
Property Value
Exceptions
- ArgumentException
Thrown when the assigned value is zero or contains a non-finite value.
AxisBody2
Gets or sets the reference axis of body 2 in world space.
public JVector AxisBody2 { get; set; }
Property Value
Exceptions
- ArgumentException
Thrown when the assigned value is zero or contains a non-finite value.
Bias
Gets or sets the bias factor controlling how aggressively angular error is corrected.
public float Bias { get; set; }
Property Value
- float
Default is 0.2. Higher values correct errors faster but may cause instability.
Impulse
Gets the accumulated solver impulse from the last solved substep.
public float Impulse { get; }
Property Value
Limit
Gets or sets the angular limit of the cone.
public AngularLimit Limit { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Thrown when the assigned limit is outside the range [0, pi], or when its upper value is smaller than its lower value, or when the limit fixes the tilt at zero or pi.
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 angular error but improve stability.
Methods
Create()
Called when the world creates this constraint. Override to set DispatchId to the ID returned by registering the constraint's solver methods.
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, AngularLimit)
Initializes the cone limit using a world-space axis and an angular range.
public void Initialize(JVector axis, AngularLimit limit)
Parameters
axisJVectorThe reference axis in world space for the initial pose.
limitAngularLimitThe minimum and maximum allowed tilt angles.
Remarks
The axes start aligned and then rotate with their respective bodies. The angle between them is kept within the given range. Default values: Softness = DefaultAngularSoftness, Bias = DefaultAngularBias.
Exceptions
- ArgumentException
Thrown when
axisis zero or contains a non-finite value.- ArgumentOutOfRangeException
Thrown when
limitis outside the range [0, pi], or when its upper value is smaller than its lower value, or when the limit fixes the tilt at zero or pi.
Initialize(JVector, JVector, AngularLimit)
Initializes the cone limit using two world-space axes and an angular range.
public void Initialize(JVector axisBody1, JVector axisBody2, AngularLimit limit)
Parameters
axisBody1JVectorThe reference axis for body 1 in world space.
axisBody2JVectorThe reference axis for body 2 in world space.
limitAngularLimitThe minimum and maximum allowed tilt angles.
Remarks
Each axis rotates with its body. The angle between the axes is kept within the given range. Default values: Softness = DefaultAngularSoftness, Bias = DefaultAngularBias.
Exceptions
- ArgumentException
Thrown when
axisBody1oraxisBody2is zero or contains a non-finite value.- ArgumentOutOfRangeException
Thrown when
limitis outside the range [0, pi], or when its upper value is smaller than its lower value, or when the limit fixes the tilt at zero or pi.
IterateConeLimit(ref ConstraintData, in TimeStep)
public static void IterateConeLimit(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
PrepareForIterationConeLimit(ref ConstraintData, in TimeStep)
public static void PrepareForIterationConeLimit(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
ResetWarmStart()
Clears impulses saved from the previous solve, without changing constraint settings.
public override void ResetWarmStart()
Remarks
Use after restoring a saved state or making a sudden change to the bodies, when impulses from their previous state should no longer be reused.
ToString()
Returns a short description of the constraint's ID, connected bodies, and state.
public override string ToString()