/// <inheritdoc /> public override MultiRotationInverseConstraintJob Create(Animator animator, ref T data, Component component) { var job = new MultiRotationInverseConstraintJob(); job.driven = ReadOnlyTransformHandle.Bind(animator, data.constrainedObject); job.drivenParent = ReadOnlyTransformHandle.Bind(animator, data.constrainedObject.parent); job.drivenOffset = Vector3Property.Bind(animator, component, data.offsetVector3Property); WeightedTransformArray sourceObjects = data.sourceObjects; WeightedTransformArrayBinder.BindReadWriteTransforms(animator, component, sourceObjects, out job.sourceTransforms); WeightedTransformArrayBinder.BindWeights(animator, component, sourceObjects, data.sourceObjectsProperty, out job.sourceWeights); job.sourceOffsets = new NativeArray <Quaternion>(sourceObjects.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); job.weightBuffer = new NativeArray <float>(sourceObjects.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); Quaternion drivenRotInv = Quaternion.Inverse(data.constrainedObject.rotation); for (int i = 0; i < sourceObjects.Count; ++i) { job.sourceOffsets[i] = data.maintainOffset ? (drivenRotInv * sourceObjects[i].transform.rotation) : Quaternion.identity; } return(job); }
/// <inheritdoc /> public override void Destroy(MultiRotationInverseConstraintJob job) { job.sourceTransforms.Dispose(); job.sourceWeights.Dispose(); job.sourceOffsets.Dispose(); job.weightBuffer.Dispose(); }