2
0

BsAnimationInstance.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. * Data used for evaluating an AnimationCurve. Holds cached information 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 AnimationInstanceData
  16. {
  17. public:
  18. AnimationInstanceData()
  19. : time(0.0f), cachedKey((UINT32)-1), cachedCurveStart(std::numeric_limits<float>::infinity())
  20. , cachedCurveEnd(0.0f), cachedCubicCoefficients()
  21. { }
  22. float time; /**< Time at which to evaluate the curve. */
  23. private:
  24. template <class U> friend class TAnimationCurve;
  25. mutable UINT32 cachedKey; /**< Left-most key the curve was last evaluated at. -1 if no cached data. */
  26. mutable float cachedCurveStart; /**< Time relative to the animation curve, at which the cached data starts. */
  27. mutable float cachedCurveEnd; /**< Time relative to the animation curve, at which the cached data end. */
  28. /**
  29. * Coefficients of the cubic hermite curve, in order [t^3, t^2, t, 1]. Coefficients assume unnormalized @p t, with
  30. * length of @p cachedCurveEnd - @p cachedCurveStart.
  31. */
  32. mutable T cachedCubicCoefficients[4];
  33. };
  34. /** @} */
  35. }