private void DeleteBone(IBone bone) { // Remove the whole bone hierarchy. if (bone.isRoot) { // Delete everything. (Less efficient code, but performance is not crucial at this time). foreach (var otherBone in m_Model.bones.Reverse()) { m_Model.DeleteBone(otherBone); } } // Remove just the selected bone. // All direct children will belong to the parent of deleted bone. else { List <IBone> directChildOfDeletingBone = new List <IBone>(); foreach (var otherBone in m_Model.bones) { if (otherBone.parent == bone) { directChildOfDeletingBone.Add(otherBone); } } foreach (var child in directChildOfDeletingBone) { m_Model.Parent(child, bone.parent); } // Remove the bone when all children transfered. m_Model.DeleteBone(bone); } }
public void RemovingABone_InvalidateWeightForThatBone_WeightBoneIndexUpdate() { InvalidateBoneIndex(1, m_ExpectedVertices); ChangeBoneIndex(new int[4] { 2, 3, 4, 5 }, new int[4] { 1, 2, 3, 4 }, 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); m_Model.Parent(child_1_1, root); m_Model.Parent(child_1_2, root); m_Model.DeleteBone(child_1); 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))); }