BsAnimationUtility.cpp 745 B

1234567891011121314151617181920212223242526272829
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsAnimationUtility.h"
  4. namespace BansheeEngine
  5. {
  6. void AnimationUtility::wrapTime(float& time, float start, float end, bool loop)
  7. {
  8. float length = end - start;
  9. // Clamp to start or loop
  10. if (time < start)
  11. {
  12. if (loop)
  13. time = time - std::floor(time / length) * length;
  14. else // Clamping
  15. time = start;
  16. }
  17. // Clamp to end or loop
  18. if (time > end)
  19. {
  20. if (loop)
  21. time = time - std::floor(time / length) * length;
  22. else // Clamping
  23. time = end;
  24. }
  25. }
  26. }