/// <summary>
 /// Allocate array of bones from pool. Bones are in the rest (bind) position by default.
 /// </summary>
 /// <returns></returns>
 public List <MyAnimationClip.BoneState> Alloc()
 {
     if (m_freeToUse.Count == 0)
     {
         var rtn = new List <MyAnimationClip.BoneState>(m_boneCount);
         rtn.SetSize(m_boneCount);
         for (int i = 0; i < m_boneCount; i++)
         {
             // item not created yet
             rtn[i] = new MyAnimationClip.BoneState();
             // fill will default data
             rtn[i].Translation = m_restPose[i].Translation;
             rtn[i].Rotation    = m_restPose[i].Rotation;
         }
         m_taken.Add(rtn);
         return(rtn);
     }
     else
     {
         var rtn = m_freeToUse[m_freeToUse.Count - 1];
         m_freeToUse.RemoveAt(m_freeToUse.Count - 1);
         m_taken.Add(rtn);
         for (int i = 0; i < m_boneCount; i++)
         {
             // item is already created
             // fill will default data
             rtn[i].Translation = m_restPose[i].Translation;
             rtn[i].Rotation    = m_restPose[i].Rotation;
         }
         return(rtn);
     }
 }
 /// <summary>
 /// Allocate array of bones from pool. Bones are in the rest (bind) position by default.
 /// </summary>
 /// <returns></returns>
 public List<MyAnimationClip.BoneState> Alloc()
 {
     if (m_freeToUse.Count == 0)
     {
         var rtn = new List<MyAnimationClip.BoneState>(m_boneCount);
         rtn.SetSize(m_boneCount);
         for (int i = 0; i < m_boneCount; i++)
         {
             // item not created yet
             rtn[i] = new MyAnimationClip.BoneState();
             // fill will default data
             rtn[i].Translation = m_restPose[i].Translation;
             rtn[i].Rotation = m_restPose[i].Rotation;
         }
         m_taken.Add(rtn);
         return rtn;
     }
     else
     {
         var rtn = m_freeToUse[m_freeToUse.Count - 1];
         m_freeToUse.RemoveAt(m_freeToUse.Count - 1);
         m_taken.Add(rtn);
         for (int i = 0; i < m_boneCount; i++)
         {
             // item is already created
             // fill will default data
             rtn[i].Translation = m_restPose[i].Translation;
             rtn[i].Rotation = m_restPose[i].Rotation;
         }
         return rtn;
     }
 }
            /// <summary>
            /// Set the new bone count and default (rest) pose.
            /// </summary>
            public void Reset(MyCharacterBone[] restPoseBones)
            {
                m_freeToUse.Clear();
                m_taken.Clear();
                if (restPoseBones == null)
                {
                    m_boneCount = 0;
                    m_restPose = null;
                    return;
                }

                int boneCount = restPoseBones.Length;
                m_boneCount = boneCount;
                m_restPose = new MyAnimationClip.BoneState[boneCount];
                for (int i = 0; i < boneCount; i++)
                {
                    m_restPose[i] = new MyAnimationClip.BoneState();
                    m_restPose[i].Translation = restPoseBones[i].BindTransform.Translation;
                    m_restPose[i].Rotation = Quaternion.CreateFromRotationMatrix(restPoseBones[i].BindTransform);
                }
            }
            /// <summary>
            /// Set the new bone count and default (rest) pose.
            /// </summary>
            public void Reset(MyCharacterBone[] restPoseBones)
            {
                m_freeToUse.Clear();
                m_taken.Clear();
                if (restPoseBones == null)
                {
                    m_boneCount = 0;
                    m_restPose  = null;
                    return;
                }

                int boneCount = restPoseBones.Length;

                m_boneCount = boneCount;
                m_restPose  = new MyAnimationClip.BoneState[boneCount];
                for (int i = 0; i < boneCount; i++)
                {
                    m_restPose[i]             = new MyAnimationClip.BoneState();
                    m_restPose[i].Translation = restPoseBones[i].BindTransform.Translation;
                    m_restPose[i].Rotation    = Quaternion.CreateFromRotationMatrix(restPoseBones[i].BindTransform);
                }
            }