/// <inheritdoc />
 public override void Destroy(TwistCorrectionJob job)
 {
     job.twistTransforms.Dispose();
     job.twistWeights.Dispose();
     job.twistBindRotations.Dispose();
     job.weightBuffer.Dispose();
 }
        /// <inheritdoc />
        public override TwistCorrectionJob Create(Animator animator, ref T data, Component component)
        {
            var job = new TwistCorrectionJob();

            job.source = ReadOnlyTransformHandle.Bind(animator, data.source);
            job.sourceInverseBindRotation = Quaternion.Inverse(data.source.localRotation);
            job.axisMask = data.twistAxis;

            WeightedTransformArray twistNodes = data.twistNodes;

            WeightedTransformArrayBinder.BindReadWriteTransforms(animator, component, twistNodes, out job.twistTransforms);
            WeightedTransformArrayBinder.BindWeights(animator, component, twistNodes, data.twistNodesProperty, out job.twistWeights);

            job.weightBuffer = new NativeArray <float>(twistNodes.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

            job.twistBindRotations = new NativeArray <Quaternion>(twistNodes.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

            for (int i = 0; i < twistNodes.Count; ++i)
            {
                var sourceTransform = twistNodes[i].transform;
                job.twistBindRotations[i] = sourceTransform.localRotation;
            }

            return(job);
        }
Beispiel #3
0
        public override TwistCorrectionJob Create(Animator animator, ref T data)
        {
            var job          = new TwistCorrectionJob();
            var cacheBuilder = new AnimationJobCacheBuilder();

            job.source = TransformHandle.Bind(animator, data.source);
            job.sourceInverseBindRotation = Quaternion.Inverse(data.source.localRotation);
            job.axisMask = data.twistAxis;

            var twistNodes       = data.twistNodes;
            var twistNodeWeights = data.twistNodeWeights;

            job.twistNodes          = new NativeArray <TransformHandle>(twistNodes.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            job.twistWeightStartIdx = cacheBuilder.AllocateChunk(twistNodes.Length);

            for (int i = 0; i < twistNodes.Length; ++i)
            {
                job.twistNodes[i] = TransformHandle.Bind(animator, twistNodes[i]);
                cacheBuilder.SetValue(job.twistWeightStartIdx, i, twistNodeWeights[i]);
            }
            job.cache = cacheBuilder.Build();

            return(job);
        }
Beispiel #4
0
 public override void Update(TwistCorrectionJob job, ref T data)
 {
     job.cache.SetArray(data.twistNodeWeights, job.twistWeightStartIdx);
 }
Beispiel #5
0
 public override void Destroy(TwistCorrectionJob job)
 {
     job.twistNodes.Dispose();
     job.cache.Dispose();
 }