using Unity.Jobs; using Unity.Mathematics; using LitMotion; using LitMotion.Adapters; [assembly: RegisterGenericJobType(typeof(MotionUpdateJob))] [assembly: RegisterGenericJobType(typeof(MotionUpdateJob))] [assembly: RegisterGenericJobType(typeof(MotionUpdateJob))] [assembly: RegisterGenericJobType(typeof(MotionUpdateJob))] namespace LitMotion.Adapters { public readonly struct FloatMotionAdapter : IMotionAdapter { public float Evaluate(ref float startValue, ref float endValue, ref NoOptions options, in MotionEvaluationContext context) { return math.lerp(startValue, endValue, context.Progress); } } public readonly struct DoubleMotionAdapter : IMotionAdapter { public double Evaluate(ref double startValue, ref double endValue, ref NoOptions options, in MotionEvaluationContext context) { return math.lerp(startValue, endValue, context.Progress); } } public readonly struct IntMotionAdapter : IMotionAdapter { public int Evaluate(ref int startValue, ref int endValue, ref IntegerOptions options, in MotionEvaluationContext context) { var value = math.lerp(startValue, endValue, context.Progress); return options.RoundingMode switch { RoundingMode.AwayFromZero => value >= 0f ? (int)math.ceil(value) : (int)math.floor(value), RoundingMode.ToZero => (int)math.trunc(value), RoundingMode.ToPositiveInfinity => (int)math.ceil(value), RoundingMode.ToNegativeInfinity => (int)math.floor(value), _ => (int)math.round(value), }; } } public readonly struct LongMotionAdapter : IMotionAdapter { public long Evaluate(ref long startValue, ref long endValue, ref IntegerOptions options, in MotionEvaluationContext context) { var value = math.lerp((double)startValue, endValue, context.Progress); return options.RoundingMode switch { RoundingMode.AwayFromZero => value >= 0f ? (long)math.ceil(value) : (long)math.floor(value), RoundingMode.ToZero => (long)math.trunc(value), RoundingMode.ToPositiveInfinity => (long)math.ceil(value), RoundingMode.ToNegativeInfinity => (long)math.floor(value), _ => (long)math.round(value), }; } } }