Class BallSocket
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Keeps an anchor point on each body together while allowing all relative rotation.
public class BallSocket : Constraint<BallSocket.BallSocketData>, IDebugDrawable
- Inheritance
-
BallSocket
- 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 positional 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 JVector Impulse { get; }
Property Value
Softness
Gets or sets the softness (compliance) of the constraint.
public float Softness { get; set; }
Property Value
- float
Default is DefaultLinearSoftness. Higher values allow more positional error but improve stability. Scaled by inverse timestep during solving.
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)
Initializes the constraint from a world-space anchor point.
public void Initialize(JVector anchor)
Parameters
anchorJVectorThe anchor point in world space, shared by both bodies.
Remarks
Default values: Bias = DefaultLinearBias, Softness = DefaultLinearSoftness.
Exceptions
- ArgumentException
Thrown when
anchorcontains a non-finite value.
IterateBallSocket(ref ConstraintData, in TimeStep)
public static void IterateBallSocket(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
PrepareForIterationBallSocket(ref ConstraintData, in TimeStep)
public static void PrepareForIterationBallSocket(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()