llinterp.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @file llinterp.h
  3. *
  4. * $LicenseInfo:firstyear=2001&license=viewergpl$
  5. *
  6. * Copyright (c) 2001-2009, Linden Research, Inc.
  7. *
  8. * Second Life Viewer Source Code
  9. * The source code in this file ("Source Code") is provided by Linden Lab
  10. * to you under the terms of the GNU General Public License, version 2.0
  11. * ("GPL"), unless you have obtained a separate licensing agreement
  12. * ("Other License"), formally executed by you and Linden Lab. Terms of
  13. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  14. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  15. *
  16. * There are special exceptions to the terms and conditions of the GPL as
  17. * it is applied to this Source Code. View the full text of the exception
  18. * in the file doc/FLOSS-exception.txt in this software distribution, or
  19. * online at
  20. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  21. *
  22. * By copying, modifying or distributing this software, you acknowledge
  23. * that you have read and understood your obligations described above,
  24. * and agree to abide by those obligations.
  25. *
  26. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  27. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  28. * COMPLETENESS OR PERFORMANCE.
  29. * $/LicenseInfo$
  30. */
  31. #ifndef LL_LLINTERP_H
  32. #define LL_LLINTERP_H
  33. #include "llpreprocessor.h"
  34. #include "stdtypes.h"
  35. // There used to be several interpolator class templates derived from a base
  36. // LLInterp class template, with different data types, but only the linear type
  37. // with the F32 data type was ever used in the viewer code, so I removed the
  38. // others, and made LLInterpLinear into a non-virtual, non-template class. HB
  39. class LLInterpLinear
  40. {
  41. public:
  42. LL_INLINE LLInterpLinear()
  43. : mStartVal(0.f),
  44. mEndVal(0.f),
  45. mCurVal(0.f),
  46. mStartTime(0.f),
  47. mCurTime(0.f),
  48. mEndTime(1.f),
  49. mDuration(1.f),
  50. mCurFrac(0.f),
  51. mDone(false),
  52. mActive(false)
  53. {
  54. }
  55. LL_INLINE void start()
  56. {
  57. mCurVal = mStartVal;
  58. mCurTime = mStartTime;
  59. mDone = mActive = false;
  60. mCurFrac = 0.f;
  61. }
  62. void update(F32 time);
  63. LL_INLINE const F32& getCurVal() const { return mCurVal; }
  64. LL_INLINE void setStartVal(const F32& val) { mStartVal = val; }
  65. LL_INLINE const F32& getStartVal() const { return mStartVal; }
  66. LL_INLINE void setEndVal(const F32& val) { mEndVal = val; }
  67. LL_INLINE const F32& getEndVal() const { return mEndVal; }
  68. LL_INLINE void setStartTime(F32 time)
  69. {
  70. mStartTime = time;
  71. mDuration = mEndTime - mStartTime;
  72. }
  73. LL_INLINE F32 getStartTime() const { return mStartTime; }
  74. LL_INLINE void setEndTime(F32 time)
  75. {
  76. mEndTime = time;
  77. mDuration = mEndTime - mStartTime;
  78. }
  79. LL_INLINE F32 getEndTime() const { return mEndTime; }
  80. LL_INLINE bool isActive() const { return mActive; }
  81. LL_INLINE bool isDone() const { return mDone; }
  82. LL_INLINE F32 getCurFrac() const { return mCurFrac; }
  83. protected:
  84. F32 mStartTime;
  85. F32 mEndTime;
  86. F32 mDuration;
  87. F32 mCurTime;
  88. F32 mCurFrac;
  89. F32 mStartVal;
  90. F32 mEndVal;
  91. F32 mCurVal;
  92. bool mActive;
  93. bool mDone;
  94. };
  95. #endif // LL_LLINTERP_H