Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FrameRate.cs 1.5KB

123456789101112131415161718192021222324252627282930
  1. #if !TIMELINE_FRAMEACCURATE
  2. using System;
  3. namespace UnityEngine.Timeline
  4. {
  5. internal readonly struct FrameRate : IEquatable<FrameRate>
  6. {
  7. public readonly double rate;
  8. public static readonly FrameRate k_23_976Fps = new FrameRate(23.976023976024);
  9. public static readonly FrameRate k_24Fps = new FrameRate(24);
  10. public static readonly FrameRate k_25Fps = new FrameRate(25);
  11. public static readonly FrameRate k_30Fps = new FrameRate(30);
  12. public static readonly FrameRate k_29_97Fps = new FrameRate(29.97002997003);
  13. public static readonly FrameRate k_50Fps = new FrameRate(50);
  14. public static readonly FrameRate k_59_94Fps = new FrameRate(59.9400599400599);
  15. public static readonly FrameRate k_60Fps = new FrameRate(60);
  16. FrameRate(double framerate) { rate = framerate; }
  17. public bool IsValid() => rate > TimeUtility.kTimeEpsilon;
  18. public bool Equals(FrameRate other) => Math.Abs(rate - other.rate) < TimeUtility.kFrameRateEpsilon;
  19. public override bool Equals(object obj) => obj is FrameRate other && Equals(other);
  20. public override int GetHashCode() => rate.GetHashCode();
  21. public static bool operator ==(FrameRate a, FrameRate b) => a.Equals(b);
  22. public static bool operator !=(FrameRate a, FrameRate b) => !a.Equals(b);
  23. public static FrameRate DoubleToFrameRate(double rate) => new FrameRate(Math.Ceiling(rate) - rate < TimeUtility.kFrameRateEpsilon ? rate : Math.Ceiling(rate) * 1000.0 / 1001.0);
  24. }
  25. }
  26. #endif