Exemple #1
0
        /// <summary>
        /// This method can be called when the flex move didn't reach the target yet, to continue to converge
        /// <returns>true if the flex move still need to be updated</returns>
        /// </summary>
        public bool update()
        {
            if (mCurrentUpdateStatus == IKSolver.CCDResult.Processing)
            {
                // a threshold tuning variable for reaching target
                const double REACH_TARGET_PRECISION_IN_STUD = 0.1;
                int          lastBone = mBoneList.Count;

                if (mUseTwoTargets)
                {
                    // if we use two targets, do the first pass on the second target
                    // reverse the Y because BlueBrick use an indirect coord sys, and the IKSolver a direct one
                    IKSolver.CalcIK_2D_CCD(ref mBoneList, mSecondaryTarget.X, -mSecondaryTarget.Y,
                                           REACH_TARGET_PRECISION_IN_STUD, lastBone - 1);
                    computeBrickPositionAndOrientation();
                }

                // do the normal pass on the final target
                // reverse the Y because BlueBrick use an indirect coord sys, and the IKSolver a direct one
                mCurrentUpdateStatus = IKSolver.CalcIK_2D_CCD(ref mBoneList, mPrimaryTarget.X, -mPrimaryTarget.Y,
                                                              REACH_TARGET_PRECISION_IN_STUD, lastBone);
                computeBrickPositionAndOrientation();
            }

            // return true if we still need to update
            return(mCurrentUpdateStatus == IKSolver.CCDResult.Processing);
        }