public override void Update(OverrideTransformJob job, ref T data) { job.UpdateSpace(data.space); job.cache.Set(data.position, job.positionIdx); job.cache.Set(data.rotation, job.rotationIdx); job.cache.SetRaw(data.positionWeight, job.positionWeightIdx); job.cache.SetRaw(data.rotationWeight, job.rotationWeightIdx); }
public override OverrideTransformJob Create(Animator animator, ref T data, Component component) { var job = new OverrideTransformJob(); var cacheBuilder = new AnimationJobCacheBuilder(); job.driven = ReadWriteTransformHandle.Bind(animator, data.constrainedObject); if (data.sourceObject != null) { // Cache source to possible space rotation offsets (world, local and pivot) // at bind time so we can switch dynamically between them at runtime. job.source = ReadOnlyTransformHandle.Bind(animator, data.sourceObject); var sourceLocalTx = new AffineTransform(data.sourceObject.localPosition, data.sourceObject.localRotation); job.sourceInvLocalBindTx = sourceLocalTx.Inverse(); var sourceWorldTx = new AffineTransform(data.sourceObject.position, data.sourceObject.rotation); var drivenWorldTx = new AffineTransform(data.constrainedObject.position, data.constrainedObject.rotation); job.sourceToWorldRot = sourceWorldTx.Inverse().rotation; job.sourceToPivotRot = sourceWorldTx.InverseMul(drivenWorldTx).rotation; var drivenParent = data.constrainedObject.parent; if (drivenParent != null) { var drivenParentWorldTx = new AffineTransform(drivenParent.position, drivenParent.rotation); job.sourceToLocalRot = sourceWorldTx.InverseMul(drivenParentWorldTx).rotation; } else { job.sourceToLocalRot = job.sourceToPivotRot; } } job.spaceIdx = cacheBuilder.Add(data.space); if (data.space == (int)OverrideTransformJob.Space.Pivot) { job.sourceToCurrSpaceRotIdx = cacheBuilder.Add(job.sourceToPivotRot); } else if (data.space == (int)OverrideTransformJob.Space.Local) { job.sourceToCurrSpaceRotIdx = cacheBuilder.Add(job.sourceToLocalRot); } else { job.sourceToCurrSpaceRotIdx = cacheBuilder.Add(job.sourceToWorldRot); } job.position = Vector3Property.Bind(animator, component, data.positionVector3Property); job.rotation = Vector3Property.Bind(animator, component, data.rotationVector3Property); job.positionWeight = FloatProperty.Bind(animator, component, data.positionWeightFloatProperty); job.rotationWeight = FloatProperty.Bind(animator, component, data.rotationWeightFloatProperty); job.cache = cacheBuilder.Build(); return(job); }
public override void Destroy(OverrideTransformJob job) { job.cache.Dispose(); }
public override void Update(OverrideTransformJob job, ref T data) { job.UpdateSpace(data.space); }