コード例 #1
0
 /// <summary>
 /// Makes sure that the <see cref="SkeletonBoneAccessor"/> is initialized.
 /// </summary>
 private void EnsureBoneAccessor()
 {
     if (_boneAccessor == null)
     {
         Interlocked.CompareExchange(ref _boneAccessor, SkeletonBoneAccessor.Create(this), null);
     }
 }
コード例 #2
0
        /// <summary>
        /// Recycles this instance of the <see cref="SkeletonPose"/> class.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method resets this instance and returns it to a resource pool if resource pooling is
        /// enabled (see <see cref="ResourcePool.Enabled">ResourcePool.Enabled</see>).
        /// </para>
        /// </remarks>
        public void Recycle()
        {
            // Recycle SkeletonBoneAccessors.
            if (_boneAccessor != null)
            {
                _boneAccessor.Recycle();
                _boneAccessor = null;
            }

            // Recycle AnimatableBoneTransforms.
            if (_animatableBoneTransforms != null)
            {
                foreach (var animatableBoneTransform in _animatableBoneTransforms)
                {
                    animatableBoneTransform.SkeletonPose = null;
                }

                Skeleton.AnimatableBoneTransformsPool.Recycle(_animatableBoneTransforms);
                _animatableBoneTransforms = null;
            }

            // Reset name.
            Name = null;

            // Reset bone transforms.
            for (int i = 0; i < BoneTransforms.Length; i++)
            {
                BoneTransforms[i] = SrtTransform.Identity;
            }

            // Recycle self.
            Skeleton.SkeletonPosePool.Recycle(this);
        }