BsCurveCache.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Animation-Internal
  8. * @{
  9. */
  10. /**
  11. * Holds cached information used for animation curve evaluation so that sequential evaluations can be sped up.
  12. * You should not use the same instance of this object for evaluating multiple different animation curves.
  13. */
  14. template <class T>
  15. struct TCurveCache
  16. {
  17. public:
  18. TCurveCache()
  19. : cachedKey((UINT32)-1), cachedCurveStart(std::numeric_limits<float>::infinity()), cachedCurveEnd(0.0f)
  20. , cachedCubicCoefficients()
  21. { }
  22. private:
  23. friend class TAnimationCurve<T>;
  24. mutable UINT32 cachedKey; /**< Left-most key the curve was last evaluated at. -1 if no cached data. */
  25. mutable float cachedCurveStart; /**< Time relative to the animation curve, at which the cached data starts. */
  26. mutable float cachedCurveEnd; /**< Time relative to the animation curve, at which the cached data end. */
  27. /**
  28. * Coefficients of the cubic hermite curve, in order [t^3, t^2, t, 1]. Coefficients assume unnormalized @p t, with
  29. * length of @p cachedCurveEnd - @p cachedCurveStart.
  30. */
  31. mutable T cachedCubicCoefficients[4];
  32. };
  33. /** @} */
  34. }