- Timestamp:
- Aug 7, 2006, 4:23:45 PM (18 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/smooth.h
r9657 r9658 1 1 2 2 /*! 3 * @file timer.h 4 * @brief Definition of Time Class. 5 * 6 * These are mainly Classes, that are used for wrapping around SDL_thread 3 * @file smooth.h 4 * @brief Definition of Smooth Class. 7 5 */ 8 6 9 #ifndef __ TIMER_H__10 #define __ TIMER_H__7 #ifndef __SMOOTH_H__ 8 #define __SMOOTH_H__ 11 9 12 //! A class to handle time itself 13 class Timer 10 namespace VariableHandler 14 11 { 15 public:16 static double getNow();17 12 18 13 19 }; 14 template <typename var_type = float> class LinearIteration 15 { 16 public: 17 static void step(var_type* current, const var_type& fromValue, const var_type& toValue, float stepping); 18 static bool reached(const var_type& current, const var_type& toValue) const; 19 }; 20 20 21 #endif /* __TIMER_H__ */ 21 22 //! A class to handle smoothness of Variables. 23 /** With this smoothing can be achived for many different types of variables. 24 */ 25 template <typename var_type = float, class iteration_type = LinearIteration<var_type> > class Smooth 26 { 27 public: 28 Smooth(); 29 30 const var_type& from() const { return _from; } 31 const var_type& current() const { return _current; }; 32 const var_type& to() const { return _to; } 33 34 inline void tick(float dt) { if (!iteration_type::reached(_current, _to)) iteration_type::step(&_current, _from, _to, dt); }; 35 36 private: 37 var_type _from; 38 var_type _current; 39 var_type _to; 40 }; 41 } 42 #endif /* __SMOOTH_H__ */ -
trunk/src/lib/util/timer.cc
r7919 r9658 3 3 * @brief A Timer class, that handles all about time. 4 4 * 5 * code taken from audiere.5 * code borrowed from audiere. http://www.audiere.org 6 6 */ 7 7 … … 45 45 return tv.tv_sec + tv.tv_usec / 1000000.0; 46 46 } 47 -
trunk/src/lib/util/timer.h
r7919 r9658 4 4 * @brief Definition of Time Class. 5 5 * 6 * These are mainly Classes, that are used for wrapping around SDL_thread 6 * Here is a Class that is for measuring time, 7 * getting the current time, and stepping through time. 8 * 9 * @todo: Implement: 10 * 1. TimeStep 11 * 2. ApproxTimer 12 * 3. Class that handles the time-stepping 13 * 4. Transformations from one time-coding into another: 14 * 5. debug of Timer. 7 15 */ 8 16 … … 14 22 { 15 23 public: 24 Timer(); 25 Timer(int time); 26 27 void debug() const; 28 29 /// STATIC PUBLIC MEMBERS 16 30 static double getNow(); 17 31 32 private: 33 double _lastTime; 34 double _timeStep; 18 35 19 36 };
Note: See TracChangeset
for help on using the changeset viewer.