private void CreateTwoVerticesAndEdge(Vector2 v1, Vector2 v2)
 {
     m_SpriteMeshDataController.CreateVertex(v1);
     m_SpriteMeshDataController.CreateVertex(v2);
     m_SpriteMeshDataController.CreateEdge(m_SpriteMeshData.vertices.Count - 2, m_SpriteMeshData.vertices.Count - 1);
 }
        public void CreateVertex_SetsAverageWeightsFromNeighboursToNewVertex()
        {
            m_SpriteMeshDataController.CreateVertex(Vector2.zero);
            m_SpriteMeshDataController.CreateVertex(Vector2.right);
            m_SpriteMeshDataController.CreateVertex(Vector2.one);
            m_SpriteMeshDataController.CreateVertex(Vector2.up);

            m_SpriteMeshData.vertices[0].editableBoneWeight.SetFromBoneWeight(new BoneWeight()
            {
                boneIndex0 = 0, weight0 = 1f
            });
            m_SpriteMeshData.vertices[1].editableBoneWeight.SetFromBoneWeight(new BoneWeight()
            {
                boneIndex0 = 1, weight0 = 1f
            });
            m_SpriteMeshData.vertices[2].editableBoneWeight.SetFromBoneWeight(new BoneWeight()
            {
                boneIndex0 = 2, weight0 = 1f
            });
            m_SpriteMeshData.vertices[3].editableBoneWeight.SetFromBoneWeight(new BoneWeight()
            {
                boneIndex0 = 3, weight0 = 1f
            });

            m_SpriteMeshDataController.CreateEdge(0, 1);
            m_SpriteMeshDataController.CreateEdge(1, 2);
            m_SpriteMeshDataController.CreateEdge(2, 3);
            m_SpriteMeshDataController.CreateEdge(3, 0);

            m_SpriteMeshData.indices.AddRange(new int[] { 0, 1, 2, 0, 2, 3 });

            m_SpriteMeshData.bones.Add(new SpriteBoneData());
            m_SpriteMeshData.bones.Add(new SpriteBoneData());
            m_SpriteMeshData.bones.Add(new SpriteBoneData());
            m_SpriteMeshData.bones.Add(new SpriteBoneData());

            m_MousePosition = new Vector2(0.25f, 0.75f);

            m_View.DoCreateVertex().Returns(true);

            m_SpriteMeshController.OnGUI();

            Assert.AreEqual(5, m_SpriteMeshData.vertices.Count, "Incorrect number of vertices");

            var expected = new BoneWeight()
            {
                boneIndex0 = 3,
                boneIndex1 = 0,
                boneIndex2 = 2,
                boneIndex3 = 0,
                weight0    = 0.5f,
                weight1    = 0.25f,
                weight2    = 0.25f,
                weight3    = 0f
            };

            AssertBoneWeightContainsChannels(expected, m_SpriteMeshData.vertices[4].editableBoneWeight.ToBoneWeight(false));
        }