using UnityEngine; using UnityEngine.Animations; using UnityEngine.Animations.Rigging; namespace UnityEditor.Animations.Rigging { /// /// The TwistChain inverse constraint job. /// [Unity.Burst.BurstCompile] public struct TwistChainInverseConstraintJob : IWeightedAnimationJob { /// The Transform handle for the root Transform of the chain. public ReadOnlyTransformHandle root; /// The Transform handle for the tip Transform of the chain. public ReadOnlyTransformHandle tip; /// The Transform handle for the root target Transform. public ReadWriteTransformHandle rootTarget; /// The Transform handle for the tip target Transform. public ReadWriteTransformHandle tipTarget; /// public FloatProperty jobWeight { get; set; } /// /// Defines what to do when processing the root motion. /// /// The animation stream to work on. public void ProcessRootMotion(AnimationStream stream) { } /// /// Defines what to do when processing the animation. /// /// The animation stream to work on. public void ProcessAnimation(AnimationStream stream) { jobWeight.Set(stream, 1f); rootTarget.SetPosition(stream, root.GetPosition(stream)); rootTarget.SetRotation(stream, root.GetRotation(stream)); tipTarget.SetPosition(stream, tip.GetPosition(stream)); tipTarget.SetRotation(stream, tip.GetRotation(stream)); } } /// /// The TwistChain inverse constraint job binder. /// /// The constraint data type public class TwistChainInverseConstraintJobBinder : AnimationJobBinder where T : struct, IAnimationJobData, ITwistChainConstraintData { /// public override TwistChainInverseConstraintJob Create(Animator animator, ref T data, Component component) { var job = new TwistChainInverseConstraintJob(); job.root = ReadOnlyTransformHandle.Bind(animator, data.root); job.tip = ReadOnlyTransformHandle.Bind(animator, data.tip); job.rootTarget = ReadWriteTransformHandle.Bind(animator, data.rootTarget); job.tipTarget = ReadWriteTransformHandle.Bind(animator, data.tipTarget); return job; } /// public override void Destroy(TwistChainInverseConstraintJob job) { } } }