Exemple #1
0
    public void StepBack()
    {
        /// Stepback(Undo) only happens when:
        /// 1.There is no unfolding going on
        /// 2.This is the first time of folding back.
        /// 3.The Unfolding arry isn't empty.
        if (!unfolding && !HasFoldedBack && PreviousUnfoldingA.ToArray().Length != 0)
        {
            // If an unfolding happened before, we need to fold back.
            if (PreviousUnfoldingA[0] || PreviousUnfoldingB[0])
            {
                if (PreviousStartingPoint.ToArray().Length == 2)
                {
                    RecoverLineInfo(PreviousStartingPoint[0], PreviousEndingPoint[0]);
                    meshGenerator.ReCreateLine(PreviousStartingPoint[0], PreviousEndingPoint[0]);
                    logtool.LineRevert(PreviousStartingPoint[0], PreviousEndingPoint[0]);

                    RecoverLineInfo(PreviousStartingPoint[1], PreviousEndingPoint[1]);
                    if (PreviousUnfoldingA[0])
                    {
                        Vector3 ckMidPoint = (PreviousStartingPoint[0] + PreviousEndingPoint[0]) / 2;
                        // Vector3 rmMidPoint = (PreviousStartingPoint[1] + PreviousEndingPoint[1]) / 2;
                        FoldingBack(ckMidPoint, PreviousStartingPoint[1], PreviousEndingPoint[1], 0, PreviousStartingNormalA[0]);
                    }
                    if (PreviousUnfoldingB[0])
                    {
                        Vector3 ckMidPoint = (PreviousStartingPoint[0] + PreviousEndingPoint[0]) / 2;
                        // Vector3 rmMidPoint = (PreviousStartingPoint[1] + PreviousEndingPoint[1]) / 2;
                        FoldingBack(ckMidPoint, PreviousStartingPoint[1], PreviousEndingPoint[1], 1, PreviousStartingNormalB[0]);
                    }
                }
                else
                {
                    // TODO: We still need to consider the situation that unfolding happens sequentially.
                }
            }
            // If there is no unfolding happened before, then we only need to recreate the previous line.
            else
            {
                RecoverLineInfo(PreviousStartingPoint[0], PreviousEndingPoint[0]);
                meshGenerator.ReCreateLine(PreviousStartingPoint[0], PreviousEndingPoint[0]);
                logtool.LineRevert(PreviousStartingPoint[0], PreviousEndingPoint[0]);
            }
            HasFoldedBack = true;
        }
    }