Ejemplo n.º 1
0
        /// <summary>
        /// Copies the bone transforms from skeleton pose to another skeleton pose.
        /// </summary>
        /// <param name="source">The <see cref="SkeletonPose"/> from which the bone transforms are copied.</param>
        /// <param name="target">The <see cref="SkeletonPose"/> to which the bone transforms are copied.</param>
        /// <remarks>
        /// Copying a <see cref="SkeletonPose"/> using this method is faster than manually copying all
        /// bone transforms.
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="source"/> or <paramref name="target"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="source"/> and <paramref name="target"/> belong to different skeletons and
        /// <paramref name="target"/> has more bones than <paramref name="source"/>.
        /// </exception>
        public static void Copy(SkeletonPose source, SkeletonPose target)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (target != source)
            {
                var sourceTransforms = source.BoneTransforms;
                var targetTransforms = target.BoneTransforms;
                Array.Copy(sourceTransforms, 0, targetTransforms, 0, targetTransforms.Length);
                target.Invalidate();
            }
        }