Module org.dyn4j

Class Settings


  • public class Settings
    extends Object
    Responsible for housing all of the dynamics engine's settings.
    Since:
    1.0.0
    Version:
    4.0.0
    Author:
    William Bittle
    • Field Detail

      • DEFAULT_STEP_FREQUENCY

        public static final double DEFAULT_STEP_FREQUENCY
        The default step frequency of the dynamics engine; in seconds
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_TRANSLATION

        public static final double DEFAULT_MAXIMUM_TRANSLATION
        The default maximum translation a PhysicsBody can have in one time step; in meters
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_ROTATION

        public static final double DEFAULT_MAXIMUM_ROTATION
        The default maximum rotation a PhysicsBody can have in one time step; in radians
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_AT_REST_LINEAR_VELOCITY

        public static final double DEFAULT_MAXIMUM_AT_REST_LINEAR_VELOCITY
        The default maximum velocity for a PhysicsBody to be flagged as at-rest; in meters/second
        Since:
        4.0.0
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_AT_REST_ANGULAR_VELOCITY

        public static final double DEFAULT_MAXIMUM_AT_REST_ANGULAR_VELOCITY
        The default maximum angular velocity for a PhysicsBody to be flagged as at-rest; in radians/second
        Since:
        4.0.0
      • DEFAULT_MINIMUM_AT_REST_TIME

        public static final double DEFAULT_MINIMUM_AT_REST_TIME
        The default required time a PhysicsBody must maintain small motion to be flagged as at-rest; in seconds
        Since:
        4.0.0
        See Also:
        Constant Field Values
      • DEFAULT_SOLVER_ITERATIONS

        public static final int DEFAULT_SOLVER_ITERATIONS
        The default number of solver iterations
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_WARM_START_DISTANCE

        public static final double DEFAULT_MAXIMUM_WARM_START_DISTANCE
        The default warm starting distance; in meters2
        Since:
        4.0.0
        See Also:
        Constant Field Values
      • DEFAULT_RESTITUTION_VELOCITY

        public static final double DEFAULT_RESTITUTION_VELOCITY
        The default restitution velocity; in meters/second
        See Also:
        Constant Field Values
      • DEFAULT_LINEAR_TOLERANCE

        public static final double DEFAULT_LINEAR_TOLERANCE
        The default linear tolerance; in meters
        See Also:
        Constant Field Values
      • DEFAULT_ANGULAR_TOLERANCE

        public static final double DEFAULT_ANGULAR_TOLERANCE
        The default angular tolerance; in radians
      • DEFAULT_MAXIMUM_LINEAR_CORRECTION

        public static final double DEFAULT_MAXIMUM_LINEAR_CORRECTION
        The default maximum linear correction; in meters
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_ANGULAR_CORRECTION

        public static final double DEFAULT_MAXIMUM_ANGULAR_CORRECTION
        The default maximum angular correction; in radians
      • DEFAULT_BAUMGARTE

        public static final double DEFAULT_BAUMGARTE
        The default baumgarte
        See Also:
        Constant Field Values
    • Constructor Detail

      • Settings

        public Settings()
        Default constructor
    • Method Detail

      • reset

        public void reset()
        Resets the settings back to defaults.
      • copy

        public Settings copy()
        Creates a deep copy of this settings object.
        Returns:
        Settings
        Since:
        4.0.0
      • copy

        public void copy​(Settings settings)
        Copies all the settings from the given settings to this settings.
        Parameters:
        settings - the settings to copy
        Since:
        4.0.0
      • getStepFrequency

        public double getStepFrequency()
        Returns the step frequency of the dynamics engine in seconds.

        Returns:
        double the step frequency
        See Also:
        setStepFrequency(double)
      • setStepFrequency

        public void setStepFrequency​(double stepFrequency)
        Sets the step frequency of the dynamics engine. This value determines how often to update the dynamics engine in seconds (every 1/60th of a second for example).

        Valid values are in the range (0, ∞] seconds.

        Versions before 3.1.1 would convert the stepFrequency parameter from seconds-1 to seconds (60 to 1/60 for example) automatically. This automatic conversion has been removed in versions 3.1.1 and higher. Instead pass in the value in seconds (1/60 for example).

        Parameters:
        stepFrequency - the step frequency
        Throws:
        IllegalArgumentException - if stepFrequency is less than or equal to zero
      • getMaximumTranslation

        public double getMaximumTranslation()
        Returns the maximum translation a PhysicsBody can have in one time step.
        Returns:
        double the maximum translation in meters
        See Also:
        setMaximumTranslation(double)
      • setMaximumTranslation

        public void setMaximumTranslation​(double maximumTranslation)
        Sets the maximum translation a PhysicsBody can have in one time step.

        Valid values are in the range [0, ∞] meters

        Parameters:
        maximumTranslation - the maximum translation
        Throws:
        IllegalArgumentException - if maxTranslation is less than zero
      • getMaximumRotation

        public double getMaximumRotation()
        Returns the maximum rotation a PhysicsBody can have in one time step.
        Returns:
        double the maximum rotation in radians
        See Also:
        setMaximumRotation(double)
      • setMaximumRotation

        public void setMaximumRotation​(double maximumRotation)
        Sets the maximum rotation a PhysicsBody can have in one time step.

        Valid values are in the range [0, ∞] radians

        Parameters:
        maximumRotation - the maximum rotation
        Throws:
        IllegalArgumentException - if maxRotation is less than zero
      • isAtRestDetectionEnabled

        public boolean isAtRestDetectionEnabled()
        Returns true if the engine automatically flags PhysicsBodys as at-rest.
        Returns:
        boolean
        Since:
        4.0.0
      • setAtRestDetectionEnabled

        public void setAtRestDetectionEnabled​(boolean flag)
        Sets whether the engine automatically flags PhysicsBodys as at-rest.
        Parameters:
        flag - true if PhysicsBodys should be flagged as at-rest automatically
        Since:
        4.0.0
      • setSleepLinearVelocity

        @Deprecated
        public void setSleepLinearVelocity​(double sleepLinearVelocity)
        Deprecated.
        Deprecated in 4.0.0. Use setMaximumAtRestLinearVelocity(double) instead.
        Sets the sleep linear velocity.

        The sleep linear velocity is the maximum velocity a PhysicsBody can have to be put to sleep.

        Valid values are in the range [0, ∞] meters/second

        Parameters:
        sleepLinearVelocity - the sleep linear velocity
        Throws:
        IllegalArgumentException - if sleepLinearVelocity is less than zero
      • getMaximumAtRestLinearVelocity

        public double getMaximumAtRestLinearVelocity()
        Returns the maximum at-rest linear velocity.
        Returns:
        double the maximum at-rest velocity
        Since:
        4.0.0
        See Also:
        setSleepLinearVelocity(double)
      • setMaximumAtRestLinearVelocity

        public void setMaximumAtRestLinearVelocity​(double maximumAtRestLinearVelocity)
        Sets the maximum at-rest linear velocity.

        The maximum at-rest linear velocity is the maximum linear velocity a PhysicsBody can have to be flagged as at-rest.

        Valid values are in the range [0, ∞] meters/second

        Parameters:
        maximumAtRestLinearVelocity - the maximum at-rest linear velocity
        Throws:
        IllegalArgumentException - if maximumAtRestLinearVelocity is less than zero
        Since:
        4.0.0
      • setSleepAngularVelocity

        @Deprecated
        public void setSleepAngularVelocity​(double sleepAngularVelocity)
        Deprecated.
        Deprecated in 4.0.0. Use setMaximumAtRestAngularVelocity(double) instead.
        Sets the sleep angular velocity.

        The sleep angular velocity is the maximum angular velocity a PhysicsBody can have to be put to sleep.

        Valid values are in the range [0, ∞] radians/second

        Parameters:
        sleepAngularVelocity - the sleep angular velocity
        Throws:
        IllegalArgumentException - if sleepAngularVelocity is less than zero
      • getMaximumAtRestAngularVelocity

        public double getMaximumAtRestAngularVelocity()
        Returns the maximum at-rest angular velocity.
        Returns:
        double the maximum at-rest velocity
        Since:
        4.0.0
        See Also:
        setMaximumAtRestAngularVelocity(double)
      • setMaximumAtRestAngularVelocity

        public void setMaximumAtRestAngularVelocity​(double maximumAtRestAngularVelocity)
        Sets the maximum at-rest angular velocity.

        The maximum at-rest angular velocity is the maximum angular velocity a PhysicsBody can have to be flagged as at-rest.

        Valid values are in the range [0, ∞] meters/second

        Parameters:
        maximumAtRestAngularVelocity - the maximum at-rest angular velocity
        Throws:
        IllegalArgumentException - if maximumAtRestAngularVelocity is less than zero
        Since:
        4.0.0
      • setSleepTime

        @Deprecated
        public void setSleepTime​(double sleepTime)
        Deprecated.
        Deprecated in 4.0.0. Use setMinimumAtRestTime(double) instead.
        Sets the sleep time.

        The sleep time is the amount of time a body must be motionless before being put to sleep.

        Valid values are in the range [0, ∞] seconds

        Parameters:
        sleepTime - the sleep time
        Throws:
        IllegalArgumentException - if sleepTime is less than zero
      • getMinimumAtRestTime

        public double getMinimumAtRestTime()
        Returns the minimum time that a PhysicsBody is motionless before being flagged as at-rest.
        Returns:
        double the minimum at-rest time
        Since:
        4.0.0
        See Also:
        setMinimumAtRestTime(double)
      • setMinimumAtRestTime

        public void setMinimumAtRestTime​(double minimumAtRestTime)
        Sets the minimum at-rest time.

        This is the minimum time a body must be motionless before being flagged as at-rest.

        Valid values are in the range [0, ∞] seconds

        Parameters:
        minimumAtRestTime - the minimum at-rest time
        Throws:
        IllegalArgumentException - if minimumAtRestTime is less than zero
        Since:
        4.0.0
      • getVelocityConstraintSolverIterations

        public int getVelocityConstraintSolverIterations()
        Returns the number of iterations used to solve velocity constraints.
        Returns:
        int
      • setVelocityConstraintSolverIterations

        public void setVelocityConstraintSolverIterations​(int velocityConstraintSolverIterations)
        Sets the number of iterations used to solve velocity constraints.

        Increasing the number will increase accuracy but decrease performance.

        Valid values are in the range [1, ∞]

        Parameters:
        velocityConstraintSolverIterations - the number of iterations used to solve velocity constraints
        Throws:
        IllegalArgumentException - if velocityConstraintSolverIterations is less than 5
      • getPositionConstraintSolverIterations

        public int getPositionConstraintSolverIterations()
        Returns the number of iterations used to solve position constraints.
        Returns:
        int
      • setPositionConstraintSolverIterations

        public void setPositionConstraintSolverIterations​(int positionConstraintSolverIterations)
        Sets the number of iterations used to solve position constraints.

        Increasing the number will increase accuracy but decrease performance.

        Valid values are in the range [1, ∞]

        Parameters:
        positionConstraintSolverIterations - the number of iterations used to solve position constraints
        Throws:
        IllegalArgumentException - if positionConstraintSolverIterations is less than 5
      • setWarmStartDistance

        @Deprecated
        public void setWarmStartDistance​(double warmStartDistance)
        Deprecated.
        Deprecated in 4.0.0. Use setMaximumWarmStartDistance(double) instead.
        Sets the warm start distance.

        The maximum distance from one point to another to consider the points to be the same. This distance is used to determine if the points can carry over another point's accumulated impulses to be used for warm starting the constraint solver.

        Valid values are in the range [0, ∞] meters

        Parameters:
        warmStartDistance - the warm start distance
        Throws:
        IllegalArgumentException - if warmStartDistance is less than zero
      • getMaximumWarmStartDistance

        public double getMaximumWarmStartDistance()
        Returns the maximum warm start distance.
        Returns:
        double the warm start distance
        See Also:
        setMaximumWarmStartDistance(double)
      • setMaximumWarmStartDistance

        public void setMaximumWarmStartDistance​(double maximumWarmStartDistance)
        Sets the maximum warm start distance.

        The maximum distance from one point to another to consider the points to be the same. This distance is used to determine if the points can carry over another point's accumulated impulses to be used for warm starting the constraint solver.

        Valid values are in the range [0, ∞] meters

        Parameters:
        maximumWarmStartDistance - the maximum warm start distance
        Throws:
        IllegalArgumentException - if warmStartDistance is less than zero
      • isWarmStartingEnabled

        public boolean isWarmStartingEnabled()
        Returns true if warm starting of contacts is enabled.
        Returns:
        boolean
        Since:
        4.0.0
        See Also:
        setWarmStartingEnabled(boolean)
      • setWarmStartingEnabled

        public void setWarmStartingEnabled​(boolean flag)
        Sets the warm starting of contacts to enabled.

        Warm starting of contacts is used to increase performance of contact constraint solving. Warm starting is the process of using the last frame's solver information to jump start the next.

        Parameters:
        flag - true if warm starting should be enabled
        Since:
        4.0.0
      • getRestitutionVelocity

        public double getRestitutionVelocity()
        Returns the restitution velocity.
        Returns:
        double the restitution velocity
        See Also:
        setRestitutionVelocity(double)
      • setRestitutionVelocity

        public void setRestitutionVelocity​(double restitutionVelocity)
        Sets the restitution velocity.

        The relative velocity in the direction of the contact normal which determines whether to handle the collision as an inelastic or elastic collision.

        Valid values are in the range [0, ∞] meters/second

        Parameters:
        restitutionVelocity - the restitution velocity
        Throws:
        IllegalArgumentException - if restitutionVelocity is less than zero
      • getLinearTolerance

        public double getLinearTolerance()
        Returns the linear tolerance.
        Returns:
        double the allowed penetration
        See Also:
        setLinearTolerance(double)
      • setLinearTolerance

        public void setLinearTolerance​(double linearTolerance)
        Sets the linear tolerance.

        Used to avoid jitter and facilitate stacking.

        Valid values are in the range (0, ∞] meters

        Parameters:
        linearTolerance - the linear tolerance
        Throws:
        IllegalArgumentException - if linearTolerance is less than zero
      • getAngularTolerance

        public double getAngularTolerance()
        Returns the angular tolerance.
        Returns:
        double
        See Also:
        setAngularTolerance(double)
      • setAngularTolerance

        public void setAngularTolerance​(double angularTolerance)
        Sets the angular tolerance.

        Used to avoid jitter and facilitate stacking.

        Valid values are in the range (0, ∞] radians

        Parameters:
        angularTolerance - the angular tolerance
        Throws:
        IllegalArgumentException - if angularTolerance is less than zero
      • getMaximumLinearCorrection

        public double getMaximumLinearCorrection()
        Returns the maximum linear correction.
        Returns:
        double the maximum linear correction
        See Also:
        setMaximumLinearCorrection(double)
      • setMaximumLinearCorrection

        public void setMaximumLinearCorrection​(double maximumLinearCorrection)
        Sets the maximum linear correction.

        The maximum linear correction used when estimating the current penetration depth during the position constraint solving step.

        This is used to avoid large corrections.

        Valid values are in the range (0, ∞] meters

        Parameters:
        maximumLinearCorrection - the maximum linear correction
        Throws:
        IllegalArgumentException - if maxLinearCorrection is less than zero
      • getMaximumAngularCorrection

        public double getMaximumAngularCorrection()
        Returns the maximum angular correction.
        Returns:
        double
        See Also:
        setMaximumAngularCorrection(double)
      • setMaximumAngularCorrection

        public void setMaximumAngularCorrection​(double maximumAngularCorrection)
        Sets the maximum angular correction.

        This is used to prevent large angular corrections.

        Valid values are in the range [0, ∞] radians

        Parameters:
        maximumAngularCorrection - the maximum angular correction
        Throws:
        IllegalArgumentException - if maxAngularCorrection is less than zero
      • getBaumgarte

        public double getBaumgarte()
        Returns the baumgarte factor.
        Returns:
        double baumgarte
        See Also:
        setBaumgarte(double)
      • setBaumgarte

        public void setBaumgarte​(double baumgarte)
        Sets the baumgarte factor.

        The position correction bias factor that determines the rate at which the position constraints are solved.

        Valid values are in the range [0, ∞].

        Parameters:
        baumgarte - the baumgarte factor
        Throws:
        IllegalArgumentException - if baumgarte is less than zero
      • setContinuousDetectionMode

        public void setContinuousDetectionMode​(ContinuousDetectionMode mode)
        Sets the continuous collision detection mode.
        Parameters:
        mode - the CCD mode
        Throws:
        NullPointerException - if mode is null
        Since:
        2.2.3