示例#1
0
    //private void DoMirror(Stretch st, Node n, Vector3 previousPos, Vector3 newPos)
    //{
    //  Vector3 a = previousPos - n.transform.position;
    //  Vector3 b = newPos - n.transform.position;
    //  Vector3 axis = Vector3.Cross(a, b);
    //  float deltaAngle = Vector3.SignedAngle(a, b, axis);
    //  foreach (Stretch s in creator.GetStretches(n))
    //  {
    //    if (s != st)
    //    {
    //      switch (s.IsAnchorA(n))
    //      {
    //        //Is ControlA
    //        case true:
    //          s.ControlA = Vector3Extension.RotatePointAroundAxisPivot(s.ControlA, n.transform.position, axis, deltaAngle);
    //          break;
    //        //Is ControlB
    //        case false:
    //          s.ControlB = Vector3Extension.RotatePointAroundAxisPivot(s.ControlB, n.transform.position, axis, deltaAngle);
    //          break;
    //        default:
    //          Debug.Assert(true);
    //          break;
    //      }
    //      s.OnPathModified();
    //    }
    //  }
    //}

    private void DoMirrorPairs(Stretch st, Node n, Vector3 previousPos, Vector3 newPos)
    {
        Stretch[] stretches = creator.GetStretches(n);
        if (stretches.Length == 2)
        {
            //Vector3 a = previousPos - n.transform.position;
            //Vector3 b = newPos - n.transform.position;
            //Vector3 axis = Vector3.Cross(a, b);
            //float deltaAngle = Vector3.SignedAngle(a, b, axis);

            for (int i = 0; i < stretches.Length; i++)
            {
                Stretch s = stretches[i];

                if (s != st)
                {
                    if (s.IsAnchorA(n))
                    {
                        s.ControlA = Vector3Extension.ReflectWithPoint(newPos, n.Pos);
                    }
                    else
                    {
                        s.ControlB = Vector3Extension.ReflectWithPoint(newPos, n.Pos);
                    }
                }
            }
        }
    }