public void JustMovingBones_WeightRemained_NeverCallSetMesh() { var root = m_Model.bones.ElementAt(0); var child_1 = m_Model.bones.ElementAt(1); var child_1_2 = m_Model.bones.ElementAt(3); var child_1_2_2 = m_Model.bones.ElementAt(5); m_Model.MoveBone(root, Vector2.one); m_Model.MoveBone(child_1, Vector2.one); m_Model.MoveTip(child_1_2, Vector2.one); m_Model.MoveTip(child_1_2_2, Vector2.one); m_CacheManager.SetSpriteBoneRawData(m_SpriteId, m_Model.GetRawData()); m_CacheManager.Apply(); m_MeshDPMock.DidNotReceiveWithAnyArgs().SetVertices(Arg.Any <GUID>(), Arg.Any <Vertex2DMetaData[]>()); }
// 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(); } }