#if BURST_PRESENT using Unity.Burst; #endif using System; using Unity.Jobs; using Unity.Mathematics; namespace UnityEngine.XR.Interaction.Toolkit.AffordanceSystem.Jobs { /// /// Tween job implementation for tweening Float values. /// #if BURST_PRESENT [BurstCompile] #endif [Obsolete("The Affordance System namespace and all associated classes have been deprecated. The existing affordance system will be moved, replaced and updated with a new interaction feedback system in a future version of XRI.")] public struct FloatTweenJob : ITweenJob { /// public TweenJobData jobData { get; set; } /// /// Perform work on a worker thread. /// /// public void Execute() { var stateTransitionAmount = jobData.nativeCurve.Evaluate(jobData.stateTransitionAmountFloat); var newTargetValue = Lerp(jobData.stateOriginValue, jobData.stateTargetValue, stateTransitionAmount); var outputData = jobData.outputData; outputData[0] = Lerp(jobData.tweenStartValue, newTargetValue, jobData.tweenAmount); } /// public float Lerp(float from, float to, float t) { if (IsNearlyEqual(from, to)) { return to; } return math.lerp(from, to, t); } /// public bool IsNearlyEqual(float from, float to) { return math.distancesq(from, to) < TweenJobData.squareSnapDistanceThreshold; } } /// /// Tween job implementation for tweening float2 values. /// #if BURST_PRESENT [BurstCompile] #endif [Obsolete("The Affordance System namespace and all associated classes have been deprecated. The existing affordance system will be moved, replaced and updated with a new interaction feedback system in a future version of XRI.")] public struct Float2TweenJob : ITweenJob { /// public TweenJobData jobData { get; set; } /// /// Perform work on a worker thread. /// /// public void Execute() { var stateTransitionAmount = jobData.nativeCurve.Evaluate(jobData.stateTransitionAmountFloat); var newTargetValue = Lerp(jobData.stateOriginValue, jobData.stateTargetValue, stateTransitionAmount); var outputData = jobData.outputData; outputData[0] = Lerp(jobData.tweenStartValue, newTargetValue, jobData.tweenAmount); } /// public float2 Lerp(float2 from, float2 to, float t) { if (IsNearlyEqual(from, to)) { return to; } return math.lerp(from, to, t); } /// public bool IsNearlyEqual(float2 from, float2 to) { return math.distancesq(from, to) < TweenJobData.squareSnapDistanceThreshold; } } /// /// Tween job implementation for tweening float3 values. /// #if BURST_PRESENT [BurstCompile] #endif [Obsolete("The Affordance System namespace and all associated classes have been deprecated. The existing affordance system will be moved, replaced and updated with a new interaction feedback system in a future version of XRI.")] public struct Float3TweenJob : ITweenJob { /// public TweenJobData jobData { get; set; } /// /// Perform work on a worker thread. /// /// public void Execute() { var stateTransitionAmount = jobData.nativeCurve.Evaluate(jobData.stateTransitionAmountFloat); var newTargetValue = Lerp(jobData.stateOriginValue, jobData.stateTargetValue, stateTransitionAmount); var outputData = jobData.outputData; outputData[0] = Lerp(jobData.tweenStartValue, newTargetValue, jobData.tweenAmount); } /// public float3 Lerp(float3 from, float3 to, float t) { if (IsNearlyEqual(from, to)) { return to; } return math.lerp(from, to, t); } /// public bool IsNearlyEqual(float3 from, float3 to) { return math.distancesq(from, to) < TweenJobData.squareSnapDistanceThreshold; } } /// /// Tween job implementation for tweening float4 values. /// #if BURST_PRESENT [BurstCompile] #endif [Obsolete("The Affordance System namespace and all associated classes have been deprecated. The existing affordance system will be moved, replaced and updated with a new interaction feedback system in a future version of XRI.")] public struct Float4TweenJob : ITweenJob { /// public TweenJobData jobData { get; set; } /// /// Perform work on a worker thread. /// /// public void Execute() { var stateTransitionAmount = jobData.nativeCurve.Evaluate(jobData.stateTransitionAmountFloat); var newTargetValue = Lerp(jobData.stateOriginValue, jobData.stateTargetValue, stateTransitionAmount); var outputData = jobData.outputData; outputData[0] = Lerp(jobData.tweenStartValue, newTargetValue, jobData.tweenAmount); } /// public float4 Lerp(float4 from, float4 to, float t) { if (IsNearlyEqual(from, to)) { return to; } return math.lerp(from, to, t); } /// public bool IsNearlyEqual(float4 from, float4 to) { return math.distancesq(from, to) < TweenJobData.squareSnapDistanceThreshold; } } }