FarseerPhysics.Dynamics.Joints.FixedDistanceJoint.SolvePositionConstraints C# (CSharp) Method

SolvePositionConstraints() private method

private SolvePositionConstraints ( ) : bool
return bool
        internal override bool SolvePositionConstraints()
        {
            if (Frequency > 0.0f)
            {
                // There is no position correction for soft distance constraints.
                return true;
            }

            Body b1 = BodyA;

            Transform xf1;
            b1.GetTransform(out xf1);

            Vector2 r1 = MathUtils.Multiply(ref xf1.R, LocalAnchorA - b1.LocalCenter);
            Vector2 r2 = LocalAnchorB;

            Vector2 d = r2 - b1.Sweep.c - r1;

            float length = d.Length();

            if (length == 0.0f)
                return true;

            d /= length;
            float C = length - Length;
            C = MathUtils.Clamp(C, -Settings.MaxLinearCorrection, Settings.MaxLinearCorrection);

            float impulse = -_mass * C;
            _u = d;
            Vector2 P = impulse * _u;

            b1.Sweep.c -= b1.InvMass * P;
            b1.Sweep.a -= b1.InvI * MathUtils.Cross(r1, P);

            b1.SynchronizeTransform();

            return Math.Abs(C) < Settings.LinearSlop;
        }