All Implemented Interfaces:
ConstConstraint, ConstJoltPhysicsObject, RefTarget, AutoCloseable, Comparable<JoltPhysicsObject>
Direct Known Subclasses:
TwoBodyConstraint, VehicleConstraint

public abstract class Constraint extends NonCopyable implements ConstConstraint, RefTarget
The abstract base class for physics constraints.
  • Method Details

    • notifyShapeChanged

      public void notifyShapeChanged(int bodyId, Vec3Arg deltaCom)
      Notify the constraint that the shape of the specified body has changed and its center of mass has shifted by deltaCom.
      Parameters:
      bodyId - the ID of the body that changed
      deltaCom - the offset of the shift (not null, unaffected)
    • setConstraintPriority

      public void setConstraintPriority(int level)
      Alter the constraint's priority when solving.
      Parameters:
      level - the desired priority level
    • setEnabled

      public void setEnabled(boolean setting)
      Enable or disable the constraint.
      Parameters:
      setting - true to enable or false to disable
    • setNumPositionStepsOverride

      public void setNumPositionStepsOverride(int setting)
      Alter the override for the number of position iterations used in the solver.
      Parameters:
      setting - the number of iterations, or 0 to use the default in PhysicsSettings
    • setNumVelocityStepsOverride

      public void setNumVelocityStepsOverride(int setting)
      Alter the override for the number of velocity iterations used in the solver.
      Parameters:
      setting - the number of iterations, or 0 to use the default in PhysicsSettings
    • getConstraintPriority

      public int getConstraintPriority()
      Return the constraint's priority when solving. The constraint is unaffected.
      Specified by:
      getConstraintPriority in interface ConstConstraint
      Returns:
      the priority level
    • getConstraintSettings

      public ConstraintSettingsRef getConstraintSettings()
      Convert the constraint to a ConstraintSettings object. The constraint is unaffected.
      Specified by:
      getConstraintSettings in interface ConstConstraint
      Returns:
      a new reference to a new settings object
    • getEnabled

      public boolean getEnabled()
      Test whether the constraint is enabled. The constraint is unaffected.
      Specified by:
      getEnabled in interface ConstConstraint
      Returns:
      true if enabled, otherwise false
    • getNumPositionStepsOverride

      public int getNumPositionStepsOverride()
      Return the override for the number of position iterations used in the solver. The constraint is unaffected.
      Specified by:
      getNumPositionStepsOverride in interface ConstConstraint
      Returns:
      the number of iterations, or 0 to use the default in PhysicsSettings
    • getNumVelocityStepsOverride

      public int getNumVelocityStepsOverride()
      Return the override for the number of velocity iterations used in the solver. The constraint is unaffected.
      Specified by:
      getNumVelocityStepsOverride in interface ConstConstraint
      Returns:
      the number of iterations, or 0 to use the default in PhysicsSettings
    • getSubType

      public EConstraintSubType getSubType()
      Return the constraint's subtype. The constraint is unaffected.
      Specified by:
      getSubType in interface ConstConstraint
      Returns:
      an enum value (not null)
    • getType

      public EConstraintType getType()
      Return the constraint's type. The constraint is unaffected.
      Specified by:
      getType in interface ConstConstraint
      Returns:
      an enum value (not null)
    • getRefCount

      public int getRefCount()
      Count the active references to the native Constraint. The constraint is unaffected.
      Specified by:
      getRefCount in interface RefTarget
      Returns:
      the count (≥0)
    • setEmbedded

      public void setEmbedded()
      Mark the native Constraint as embedded.
      Specified by:
      setEmbedded in interface RefTarget
    • toRef

      public Ref toRef()
      Create a counted reference to the native Constraint.
      Specified by:
      toRef in interface RefTarget
      Returns:
      a new JVM object with a new native object assigned