BEPUphysics.Constraints.SpringSettings.ComputeErrorReductionAndSoftness C# (CSharp) Method

ComputeErrorReductionAndSoftness() public method

Computes the error reduction parameter and softness of a constraint based on its constants. Automatically called by constraint presteps to compute their per-frame values.
public ComputeErrorReductionAndSoftness ( float dt, float &errorReduction, float &softness ) : void
dt float Simulation timestep.
errorReduction float Error reduction factor to use this frame.
softness float Adjusted softness of the constraint for this frame.
return void
        public void ComputeErrorReductionAndSoftness(float dt, out float errorReduction, out float softness)
        {
            if (advanced.useAdvancedSettings)
            {
                errorReduction = advanced.errorReductionFactor / dt;
                softness = advanced.softness / dt;
            }
            else
            {
                if (stiffnessConstant == 0 && dampingConstant == 0)
                    throw new InvalidOperationException("Constraints cannot have both 0 stiffness and 0 damping.");
                errorReduction = stiffnessConstant / (dt * stiffnessConstant + dampingConstant);
                softness = 1 / (dt * (dt * stiffnessConstant + dampingConstant));
            }
        }
    }