Exemple #1
0
        public void TangentDrag_MovesTangent()
        {
            MakeSpline();

            var pointPosition = m_EditablePath.GetPoint(0).position;

            m_EditablePath.SetTangentMode(0, TangentMode.Broken);

            Assert.AreNotEqual(Vector3.zero, m_EditablePath.GetPoint(0).localLeftTangent, "Incorrect left tangent");
            Assert.AreNotEqual(Vector3.zero, m_EditablePath.GetPoint(0).localRightTangent, "Incorrect right tangent");

            SendPointClick(0, 0);

            Assert.AreEqual(1, m_EditablePath.selection.Count, "Incorrect selection state");

            SendLeftTangentDrag(0, Vector3.zero);
            SendRightTangentDrag(0, Vector3.zero);

            Assert.AreEqual(pointPosition, m_EditablePath.GetPoint(0).position, "Incorrect point position");
            Assert.AreEqual(Vector3.zero, m_EditablePath.GetPoint(0).leftTangent, "Incorrect left tangent position");
            Assert.AreEqual(Vector3.zero, m_EditablePath.GetPoint(0).rightTangent, "Incorrect right tangent position");
        }
        public void CreatePoint_InSplineCurve_ProducesContinuousPoint()
        {
            MakeClosedSpline();

            m_EditablePath.SetTangentMode(1, TangentMode.Continuous);
            m_EditablePath.SetTangentMode(2, TangentMode.Continuous);
            m_Controller.CreatePoint(1, new Vector2(150f, 250f));
            Assert.AreEqual(5, m_EditablePath.pointCount, "Incorrect point count");

            Assert.That(m_EditablePath.GetPoint(2).position, Is.EqualTo(new Vector3(150f, 217.6777f, 0f)).Using(vec3Compare));
            Assert.AreEqual(TangentMode.Continuous, m_EditablePath.GetPoint(2).tangentMode, "Incorrect tangent mode");
            Assert.AreEqual(TangentMode.Continuous, m_EditablePath.GetPoint(1).tangentMode, "Incorrect tangent mode");
            Assert.AreEqual(TangentMode.Continuous, m_EditablePath.GetPoint(3).tangentMode, "Incorrect tangent mode");
            Assert.That(m_EditablePath.GetPoint(2).localLeftTangent, Is.EqualTo(new Vector3(-19.10745f, 0f, 0f)).Using(vec3Compare));
            Assert.That(m_EditablePath.GetPoint(2).localRightTangent, Is.EqualTo(new Vector3(19.10745f, 0f, 0f)).Using(vec3Compare));
            Assert.That(m_EditablePath.GetPoint(1).localRightTangent, Is.EqualTo(new Vector3(11.78511f, 11.78511f, 0f)).Using(vec3Compare));
            Assert.That(m_EditablePath.GetPoint(3).localLeftTangent, Is.EqualTo(new Vector3(-11.78511f, 11.78511f, 0f)).Using(vec3Compare));
        }