Esempio n. 1
0
 /// <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
             // initialize will default data
             rtn[i] = new MyAnimationClip.BoneState
             {
                 Translation = m_currentDefaultPose[i].Translation,
                 Rotation    = m_currentDefaultPose[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_currentDefaultPose[i].Translation;
             rtn[i].Rotation    = m_currentDefaultPose[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
             // initialize will default data
             rtn[i] = new MyAnimationClip.BoneState
             {
                 Translation = m_currentDefaultPose[i].Translation,
                 Rotation = m_currentDefaultPose[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_currentDefaultPose[i].Translation;
             rtn[i].Rotation = m_currentDefaultPose[i].Rotation;
         }
         return rtn;
     }
 }