public override void Destroy(MultiPositionConstraintJob job) { job.sourceTransforms.Dispose(); job.sourceWeights.Dispose(); job.sourceOffsets.Dispose(); job.weightBuffer.Dispose(); }
public override MultiPositionConstraintJob Create(Animator animator, ref T data, Component component) { var job = new MultiPositionConstraintJob(); 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 <Vector3>(sourceObjects.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); job.weightBuffer = new NativeArray <float>(sourceObjects.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); Vector3 drivenPos = data.constrainedObject.position; for (int i = 0; i < sourceObjects.Count; ++i) { job.sourceOffsets[i] = data.maintainOffset ? (drivenPos - sourceObjects[i].transform.position) : Vector3.zero; } job.axesMask = new Vector3( System.Convert.ToSingle(data.constrainedXAxis), System.Convert.ToSingle(data.constrainedYAxis), System.Convert.ToSingle(data.constrainedZAxis) ); return(job); }
public override MultiPositionConstraintJob Create(Animator animator, ref T data) { var job = new MultiPositionConstraintJob(); 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 <Vector3>(src.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); job.sourceWeightStartIdx = cacheBuilder.AllocateChunk(src.Length); Vector3 drivenPos = data.constrainedObject.position; 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 ? (drivenPos - src[i].position) : Vector3.zero; } 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); }
public override void Update(MultiPositionConstraintJob job, ref T data) { job.cache.Set(data.offset, job.drivenOffsetIdx); job.cache.SetArray(data.sourceWeights, job.sourceWeightStartIdx); }
public override void Destroy(MultiPositionConstraintJob job) { job.sources.Dispose(); job.sourceOffsets.Dispose(); job.cache.Dispose(); }