/// <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;
     }
 }
        public unsafe void QuerySurfaceParameters(Vector3D localOrigin, ref BoundingBoxD queryBounds, List<Vector3> queries, List<MySurfaceParams> results)
        {
            localOrigin -= Planet.PositionLeftBottomCorner;

            using (Planet.Storage.Pin())
            {
                var bounds = (BoundingBox)queryBounds.Translate(-Planet.PositionLeftBottomCorner);

                Planet.Provider.Shape.PrepareCache();
                Planet.Provider.Material.PrepareRulesForBox(ref bounds);

                if (results.Capacity != queries.Count)
                {
                    results.Capacity = queries.Count;
                }

                fixed (MySurfaceParams* pars = results.GetInternalArray())
                {
                    for (int i = 0; i < queries.Count; ++i)
                    {
                        Planet.Provider.ComputeCombinedMaterialAndSurface(queries[i] + localOrigin, true, out pars[i]);
                        pars[i].Position -= localOrigin;
                    }
                }

                results.SetSize(queries.Count);
            }
        }