public void DeleteEverythingAndReconstruct_AllWeightInvalidated() { InvalidateBoneIndex(0, m_ExpectedVertices); InvalidateBoneIndex(1, m_ExpectedVertices); InvalidateBoneIndex(2, m_ExpectedVertices); InvalidateBoneIndex(3, m_ExpectedVertices); InvalidateBoneIndex(4, m_ExpectedVertices); InvalidateBoneIndex(5, m_ExpectedVertices); var root = m_Model.bones.ElementAt(0); var child_1 = m_Model.bones.ElementAt(1); var child_1_1 = m_Model.bones.ElementAt(2); var child_1_2 = m_Model.bones.ElementAt(3); var child_1_2_1 = m_Model.bones.ElementAt(4); var child_1_2_2 = m_Model.bones.ElementAt(5); m_Model.DeleteBone(child_1_2_2); m_Model.DeleteBone(child_1_2_1); m_Model.DeleteBone(child_1_2); m_Model.DeleteBone(child_1_1); m_Model.DeleteBone(child_1); m_Model.DeleteBone(root); var newRoot = m_Model.CreateNewRoot(Vector2.zero); m_Model.CreateNewChildBone(newRoot, Vector2.zero); m_CacheManager.SetSpriteBoneRawData(m_SpriteId, m_Model.GetRawData()); m_CacheManager.Apply(); m_MeshDPMock.Received(1).SetVertices(m_SpriteId, Arg.Is <Vertex2DMetaData[]>(x => CompareVertices(m_ExpectedVertices, x))); }
// Global mouse click to create bone, then tip, then another bone, then tip, until user cancel. private void HandleCreation() { // Change cursor looks. m_View.ShowCreationCursor(); var position = Vector3.zero; // This function return true if user clicked, and fill in the position (rect space). if (m_View.HandleFullViewCursor(ref position)) { // Normal creating is a smooth creation series of bones, each is a child of the previous bone. // And looks continuous, meaning the tip of parent always point to the child. if (state.normalCreating) { RecordUndo(null, "bone create children"); if (state.normalCreatingRoot) { if (selectingBone) { var selectedBone = state.selectedBones[0]; // Normal creation state > creating root state > selected a bone (root) > define the root's tip. m_Model.MoveTip(selectedBone, position); // Exiting the normal creating root state. state.normalCreatingRoot = false; } else { // Normal creation state > creating root state > nothing selected yet > create the root's bone. var newBone = m_Model.CreateNewRoot(position); SelectSingleBone(newBone); } } else if (selectingBone) { var selectedBone = state.selectedBones[0]; // Create a new bone at the tip of current selected bone. var newBone = m_Model.CreateNewChildBone(selectedBone, selectedBone.tip); // Define the tip of the newly created bone at the position user clicked. m_Model.MoveTip(newBone, position); // Continue creating bones. SelectSingleBone(newBone); } else { throw new InvalidOperationException("While not creating a root, there should always be a selected bone."); } } // Free creating is an alternative way to create direct children of selected bone. // Each newly created bone is a sibling to each other. // The creation is disjointed, meaning the tip of the parent will not follow the newly created child. else if (state.freeCreating) { if (state.freeCreatingBone) { RecordUndo(null, "bone free create"); if (selectingBone) { var selectedBone = state.selectedBones[0]; // Free creation state > creating bone state > selected > create the child bone. var newBone = m_Model.CreateNewChildBone(selectedBone, position); SelectSingleBone(newBone); } else { // Free creation state > creating bone state > nothing selected yet > create the root's bone. var newBone = m_Model.CreateNewRoot(position); SelectSingleBone(newBone); } // Exit the creating bone state, next should be defining the tip for this newly created bone. state.freeCreatingBone = false; } else if (selectingBone) { var selectedBone = state.selectedBones[0]; // Define the tip of the newly created bone at the position user clicked. m_Model.MoveTip(selectedBone, position); // Reselect the parent (unless the newly created is a root bone). // We are creating direct child remember? if (state.freeCreating && !selectedBone.isRoot) { SelectSingleBone(selectedBone.parent); } // Goes back to creating bone state, tip is done. state.freeCreatingBone = true; } else { throw new InvalidOperationException("While not creating a root, there should always be a selected bone."); } } // There's a click and potentially new stuff on screen, repaint. m_View.Refresh(); } }
public void CreateNewRoot_NamedAsRoot() { var root = m_Model.CreateNewRoot(Vector3.zero); Assert.AreEqual("root", root.name); }