/// <summary> /// Defines what to do when processing the animation. /// </summary> /// <param name="stream">The animation stream to work on.</param> public void ProcessAnimation(AnimationStream stream) { float w = jobWeight.Get(stream); if (w > 0f) { if (twistTransforms.Length == 0) { return; } AnimationStreamHandleUtility.ReadFloats(stream, twistWeights, weightBuffer); Quaternion twistRot = TwistRotation(axisMask, sourceInverseBindRotation * source.GetLocalRotation(stream)); Quaternion invTwistRot = Quaternion.Inverse(twistRot); for (int i = 0; i < twistTransforms.Length; ++i) { ReadWriteTransformHandle twistTransform = twistTransforms[i]; float twistWeight = Mathf.Clamp(weightBuffer[i], -1f, 1f); Quaternion rot = Quaternion.Lerp(Quaternion.identity, Mathf.Sign(twistWeight) < 0f ? invTwistRot : twistRot, Mathf.Abs(twistWeight)); twistTransform.SetLocalRotation(stream, Quaternion.Lerp(twistBindRotations[i], rot, w)); // Required to update handles with binding info. twistTransforms[i] = twistTransform; } } else { for (int i = 0; i < twistTransforms.Length; ++i) { AnimationRuntimeUtils.PassThrough(stream, twistTransforms[i]); } } }