/// <inheritdoc /> public override void Destroy(MultiRotationConstraintJob job) { job.sourceTransforms.Dispose(); job.sourceWeights.Dispose(); job.sourceOffsets.Dispose(); job.weightBuffer.Dispose(); }
public override MultiRotationConstraintJob Create(Animator animator, ref T data) { var job = new MultiRotationConstraintJob(); var cacheBuilder = new AnimationJobCacheBuilder(); job.driven = TransformHandle.Bind(animator, data.constrainedObject); job.drivenParent = TransformHandle.Bind(animator, data.constrainedObject.parent); job.drivenOffsetIdx = cacheBuilder.Add(data.offset); var src = data.sourceObjects; var srcWeights = data.sourceWeights; job.sources = new NativeArray <TransformHandle>(src.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); job.sourceOffsets = new NativeArray <Quaternion>(src.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); job.sourceWeightStartIdx = cacheBuilder.AllocateChunk(srcWeights.Length); Quaternion drivenRot = data.constrainedObject.rotation; for (int i = 0; i < src.Length; ++i) { job.sources[i] = TransformHandle.Bind(animator, src[i]); cacheBuilder.SetValue(job.sourceWeightStartIdx, i, srcWeights[i]); job.sourceOffsets[i] = data.maintainOffset ? (Quaternion.Inverse(src[i].rotation) * drivenRot) : Quaternion.identity; } job.axesMask = new Vector3( System.Convert.ToSingle(data.constrainedXAxis), System.Convert.ToSingle(data.constrainedYAxis), System.Convert.ToSingle(data.constrainedZAxis) ); job.cache = cacheBuilder.Build(); return(job); }
/// <inheritdoc /> public override MultiRotationConstraintJob Create(Animator animator, ref T data, Component component) { var job = new MultiRotationConstraintJob(); job.driven = ReadWriteTransformHandle.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.BindReadOnlyTransforms(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 drivenRot = data.constrainedObject.rotation; for (int i = 0; i < sourceObjects.Count; ++i) { job.sourceOffsets[i] = data.maintainOffset ? (Quaternion.Inverse(sourceObjects[i].transform.rotation) * drivenRot) : Quaternion.identity; } job.axesMask = new Vector3( System.Convert.ToSingle(data.constrainedXAxis), System.Convert.ToSingle(data.constrainedYAxis), System.Convert.ToSingle(data.constrainedZAxis) ); return(job); }
public override void Update(MultiRotationConstraintJob job, ref T data) { job.cache.Set(data.offset, job.drivenOffsetIdx); job.cache.SetArray(data.sourceWeights, job.sourceWeightStartIdx); }
public override void Destroy(MultiRotationConstraintJob job) { job.sources.Dispose(); job.sourceOffsets.Dispose(); job.cache.Dispose(); }