public BonePresenter(IBoneModel model, IBoneHierarchyView view, IBoneToolView toolView, IBoneInfoView infoView)
        {
            m_Model    = model;
            m_View     = view;
            m_ToolView = toolView;
            m_InfoView = infoView;

            state = new BoneEditorState();

            Undo.undoRedoPerformed += UndoRedoPerformed;
        }
        public void NoBones_AllWeightInvalidated()
        {
            for (int i = 0; i < m_ExpectedVertices.Length; ++i)
            {
                m_ExpectedVertices[i].boneWeight = new BoneWeight();
            }

            m_BoneDPMock.GetBones(m_SpriteId).Returns(new List <SpriteBone>());
            m_CacheManager = new BoneCacheManager(m_BoneDPMock, m_MeshDPMock);

            m_CacheManager.GetSpriteBoneRawData(m_SpriteId);

            m_Model = new BoneModel(() => { });
            m_CacheManager.Apply();

            m_MeshDPMock.Received(1).SetVertices(m_SpriteId, Arg.Is <Vertex2DMetaData[]>(x => CompareVertices(m_ExpectedVertices, x)));
        }
        public void Setup()
        {
            m_SpriteId = GUID.Generate();

            m_BoneDPMock = Substitute.For <ISpriteBoneDataProvider>();
            m_MeshDPMock = Substitute.For <ISpriteMeshDataProvider>();

            m_CacheManager = new BoneCacheManager(m_BoneDPMock, m_MeshDPMock);

            m_OriginalVertices = new Vertex2DMetaData[10]
            {
                //0
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 0, weight0 = 1.0f
                    }
                },
                //1
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 0, weight0 = 0.5f,
                        boneIndex1 = 1, weight1 = 0.5f
                    }
                },
                //2
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 0, weight0 = 0.25f,
                        boneIndex1 = 2, weight1 = 0.25f,
                        boneIndex2 = 3, weight2 = 0.25f,
                        boneIndex3 = 4, weight3 = 0.25f
                    }
                },
                //3
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 2, weight0 = 0.3f,
                        boneIndex1 = 3, weight1 = 0.3f,
                        boneIndex2 = 4, weight2 = 0.3f
                    }
                },
                //4
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 1, weight0 = 0.5f,
                        boneIndex1 = 3, weight1 = 0.5f
                    }
                },
                //5
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 4, weight0 = 1.0f
                    }
                },
                //6
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 3, weight0 = 0.5f,
                        boneIndex1 = 4, weight1 = 0.5f
                    }
                },
                //7
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 0, weight0 = 0.3f,
                        boneIndex1 = 1, weight1 = 0.3f,
                        boneIndex2 = 5, weight2 = 0.3f
                    }
                },
                //8
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 3, weight0 = 0.5f,
                        boneIndex1 = 5, weight1 = 0.5f
                    }
                },
                //9
                new Vertex2DMetaData()
                {
                    boneWeight = new BoneWeight()
                    {
                        boneIndex0 = 0, weight0 = 0.25f,
                        boneIndex1 = 2, weight1 = 0.25f,
                        boneIndex2 = 4, weight2 = 0.25f,
                        boneIndex3 = 5, weight3 = 0.25f
                    }
                }
            };

            m_ExpectedVertices = new Vertex2DMetaData[m_OriginalVertices.Length];
            m_OriginalVertices.CopyTo(m_ExpectedVertices, 0);

            var spriteBones = new List <SpriteBone>();

            spriteBones.Add(new SpriteBone()
            {
                name = "root", parentId = -1, rotation = Quaternion.identity
            });
            spriteBones.Add(new SpriteBone()
            {
                name = "child_1", parentId = 0, rotation = Quaternion.identity
            });
            spriteBones.Add(new SpriteBone()
            {
                name = "child_1_1", parentId = 1, rotation = Quaternion.identity
            });
            spriteBones.Add(new SpriteBone()
            {
                name = "child_1_2", parentId = 1, rotation = Quaternion.identity
            });
            spriteBones.Add(new SpriteBone()
            {
                name = "child_1_2_1", parentId = 3, rotation = Quaternion.identity
            });
            spriteBones.Add(new SpriteBone()
            {
                name = "child_1_2_2", parentId = 3, rotation = Quaternion.identity
            });

            m_BoneDPMock.GetBones(m_SpriteId).Returns(spriteBones);
            m_MeshDPMock.GetVertices(m_SpriteId).Returns(m_OriginalVertices);

            var uniqueBone = m_CacheManager.GetSpriteBoneRawData(m_SpriteId);

            m_Model = new BoneModel(() => { });
            m_Model.SetRawData(uniqueBone, Vector3.zero);
        }
 public void Setup()
 {
     m_Model = new BoneModel(() => { });
 }