ExMath.cs 720 B

1234567891011121314151617181920212223242526272829303132333435
  1. namespace AtlasUtility
  2. {
  3. using UnityEngine;
  4. public static class ExMath
  5. {
  6. public static int PrevPOT(float value)
  7. {
  8. int result = Mathf.ClosestPowerOfTwo(Mathf.CeilToInt(value));
  9. if (result > value)
  10. {
  11. return result/2;
  12. }
  13. else
  14. {
  15. return result;
  16. }
  17. }
  18. public static int NextPOT(float value)
  19. {
  20. int result = Mathf.ClosestPowerOfTwo(Mathf.CeilToInt(value));
  21. if (result >= value)
  22. {
  23. return result;
  24. }
  25. else
  26. {
  27. return result*2;
  28. }
  29. }
  30. }
  31. }