From f6a62fd5e052042dfee161ac3cd7cbeb6de4f9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 15 Aug 2013 03:16:31 -0300 Subject: [PATCH] Implemented changes to support cTime in eepp. Changed cClock::Reset to cClock::Restart. --- include/eepp/graphics/cparticlesystem.hpp | 2 +- include/eepp/graphics/csprite.hpp | 2 +- include/eepp/math/cinterpolation.hpp | 7 +- include/eepp/math/cwaypoints.hpp | 9 +- include/eepp/math/easing.hpp | 86 +++---- include/eepp/system/cclock.hpp | 10 +- include/eepp/system/ctime.hpp | 210 +++++++----------- include/eepp/ui/cuicontrol.hpp | 2 +- include/eepp/ui/cuimanager.hpp | 4 +- include/eepp/window/cengine.hpp | 2 +- include/eepp/window/cwindow.hpp | 6 +- projects/linux/ee.creator.user | 4 +- projects/linux/ee.files | 2 + src/eepp/graphics/cconsole.cpp | 8 +- src/eepp/graphics/cparticlesystem.cpp | 4 +- src/eepp/graphics/cscrollparallax.cpp | 2 +- src/eepp/graphics/csprite.cpp | 10 +- src/eepp/graphics/ctextureloader.cpp | 4 +- src/eepp/math/cinterpolation.cpp | 4 +- src/eepp/math/cwaypoints.cpp | 6 +- src/eepp/physics/cspace.cpp | 2 +- src/eepp/system/cclock.cpp | 14 +- src/eepp/system/ctime.cpp | 38 +++- src/eepp/system/platform/posix/cclockimpl.cpp | 2 +- src/eepp/system/platform/posix/cclockimpl.hpp | 2 +- src/eepp/system/platform/win/cclockimpl.cpp | 2 +- src/eepp/system/platform/win/cclockimpl.hpp | 2 +- src/eepp/ui/cuicomplexcontrol.cpp | 2 +- src/eepp/ui/cuicontrol.cpp | 2 +- src/eepp/ui/cuigenericgrid.cpp | 6 +- src/eepp/ui/cuilistbox.cpp | 6 +- src/eepp/ui/cuimanager.cpp | 2 +- src/eepp/ui/cuimenusubmenu.cpp | 2 +- src/eepp/ui/cuitextinput.cpp | 2 +- src/eepp/ui/cuitheme.cpp | 4 +- src/eepp/window/cengine.cpp | 2 +- src/eepp/window/cwindow.cpp | 8 +- src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp | 4 +- src/test/eetest.cpp | 40 ++-- src/test/eetest.hpp | 4 +- 40 files changed, 268 insertions(+), 262 deletions(-) diff --git a/include/eepp/graphics/cparticlesystem.hpp b/include/eepp/graphics/cparticlesystem.hpp index 279d9ddce..680ab0f6f 100755 --- a/include/eepp/graphics/cparticlesystem.hpp +++ b/include/eepp/graphics/cparticlesystem.hpp @@ -74,7 +74,7 @@ class EE_API cParticleSystem { /** Update the particles effect * @param Time The time transcurred between the last update. */ - void Update( const eeFloat& Time ); + void Update(const cTime &Time ); /** Update the particles effect taking the elapsed time from cEngine */ void Update(); diff --git a/include/eepp/graphics/csprite.hpp b/include/eepp/graphics/csprite.hpp index 894f4ad2b..3a60bd22e 100755 --- a/include/eepp/graphics/csprite.hpp +++ b/include/eepp/graphics/csprite.hpp @@ -340,7 +340,7 @@ class EE_API cSprite { cSprite * Copy(); /** Update the sprite animation */ - void Update( const eeFloat& ElapsedTime ); + void Update( const cTime& ElapsedTime ); /** Update the sprite animation using the current elapsed time provided by cEngine */ void Update(); diff --git a/include/eepp/math/cinterpolation.hpp b/include/eepp/math/cinterpolation.hpp index 7b5422d09..7cb59eee0 100644 --- a/include/eepp/math/cinterpolation.hpp +++ b/include/eepp/math/cinterpolation.hpp @@ -2,8 +2,11 @@ #define EE_MATHCINTERPOLATION_H #include +#include #include +using namespace EE::System; + namespace EE { namespace Math { /** @brief The basic 1d point template. */ @@ -50,7 +53,7 @@ class EE_API cInterpolation { void SetStepCallback( OnStepCallback StepCallback ); /** Update the movement interpolation */ - void Update( const eeFloat& Elapsed ); + void Update( const cTime& Elapsed ); /** Reset the class */ void Reset(); @@ -117,7 +120,7 @@ class EE_API cInterpolation { eeFloat mTotDist; eeFloat mCurPos; eeUint mCurPoint; - eeFloat mCurTime; + eeDouble mCurTime; eeFloat mSpeed; diff --git a/include/eepp/math/cwaypoints.hpp b/include/eepp/math/cwaypoints.hpp index ae9740c3f..cc55535ff 100755 --- a/include/eepp/math/cwaypoints.hpp +++ b/include/eepp/math/cwaypoints.hpp @@ -3,8 +3,11 @@ #include #include +#include #include +using namespace EE::System; + namespace EE { namespace Math { /** @brief The basic waypoint class. */ @@ -54,7 +57,7 @@ class EE_API cWaypoints { void SetStepCallback( OnStepCallback StepCallback ); /** Update the movement interpolation */ - void Update( const eeFloat& Elapsed ); + void Update( const cTime& Elapsed ); /** Reset the class */ void Reset(); @@ -75,7 +78,7 @@ class EE_API cWaypoints { bool Ended() const; /** Instead if setting the time between every waypoing, this set a total time for all the movement interpolation. */ - void SetTotalTime( const eeFloat& TotTime ); + void SetTotalTime( const eeDouble& TotTime ); /** @return The Current Node */ cWaypoint * GetCurrentActual() const; @@ -116,7 +119,7 @@ class EE_API cWaypoints { eeFloat mTotDist; eeVector2f mCurPos; Uint32 mCurPoint; - eeFloat mCurTime; + eeDouble mCurTime; eeFloat mSpeed; cWaypoint* mActP; diff --git a/include/eepp/math/easing.hpp b/include/eepp/math/easing.hpp index 5fc5cb541..0074db2df 100644 --- a/include/eepp/math/easing.hpp +++ b/include/eepp/math/easing.hpp @@ -5,7 +5,7 @@ namespace EE { namespace Math { namespace easing { -typedef eeFloat( *easingCbFunc )( eeFloat, eeFloat, eeFloat, eeFloat ); +typedef eeDouble( *easingCbFunc )( eeDouble, eeDouble, eeDouble, eeDouble ); extern EE_API easingCbFunc easingCb[]; @@ -18,7 +18,7 @@ extern EE_API easingCbFunc easingCb[]; * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat LinearInterpolation( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble LinearInterpolation( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { return b + t * c / d; } @@ -31,7 +31,7 @@ inline eeFloat LinearInterpolation( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat QuadraticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuadraticIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d; return c * t * t + b; @@ -47,7 +47,7 @@ inline eeFloat QuadraticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat QuadraticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuadraticOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d; return -c * t * ( t - 2 ) + b; @@ -65,7 +65,7 @@ inline eeFloat QuadraticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat QuadraticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuadraticInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d / 2; if ( t < 1 ) @@ -86,7 +86,7 @@ inline eeFloat QuadraticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat SineIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble SineIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { return -c * eecos( t / d * ( EE_PI / 2 ) ) + c + b; } @@ -100,7 +100,7 @@ inline eeFloat SineIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat SineOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble SineOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { return c * eesin( t / d * ( EE_PI / 2 ) ) + b; } @@ -116,7 +116,7 @@ inline eeFloat SineOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat SineInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble SineInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { return -c / 2 * ( eecos( EE_PI * t / d ) - 1 ) + b; } @@ -130,7 +130,7 @@ inline eeFloat SineInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the effect, in milliseconds. * @return Number corresponding to the position of the component. */ -inline eeFloat ExponentialIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble ExponentialIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { return t == 0 ? b : c * eepow( 2, 10 * ( t / d - 1 ) ) + b; } @@ -144,7 +144,7 @@ inline eeFloat ExponentialIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat ExponentialOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble ExponentialOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { return t == d ? b + c : c * ( -eepow( 2, -10 * t / d ) + 1 ) + b; } @@ -160,7 +160,7 @@ inline eeFloat ExponentialOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. */ -inline eeFloat ExponentialInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble ExponentialInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { if (t == 0) return b; @@ -173,19 +173,19 @@ inline eeFloat ExponentialInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { return c / 2 * ( -eepow( 2, -10 * --t ) + 2 ) + b; } -inline eeFloat QuarticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuarticIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d; return c * t * t * t * t + b; } -inline eeFloat QuarticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuarticOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t = t / d - 1; return -c * ( t * t * t * t - 1 ) + b; } -inline eeFloat QuarticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuarticInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d / 2; if ( t < 1) @@ -196,19 +196,19 @@ inline eeFloat QuarticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { return -c / 2 * ( t * t * t * t - 2 ) + b; } -inline eeFloat QuinticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuinticIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d; return c * t * t * t * t * t + b; } -inline eeFloat QuinticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuinticOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t = t / d - 1; return c * ( t * t * t * t * t + 1) + b; } -inline eeFloat QuinticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble QuinticInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d / 2; if ( t < 1 ) @@ -219,19 +219,19 @@ inline eeFloat QuinticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { return c / 2 * ( t * t * t * t * t + 2) + b; } -inline eeFloat CircularIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble CircularIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d; return -c * ( eesqrt( 1 - t * t ) - 1) + b; } -inline eeFloat CircularOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble CircularOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t = t / d - 1; return c * eesqrt( 1 - t * t ) + b; } -inline eeFloat CircularInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble CircularInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d / 2; if ( t < 1 ) @@ -242,19 +242,19 @@ inline eeFloat CircularInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { return c / 2 * ( eesqrt( 1 - t * t ) + 1) + b; } -inline eeFloat CubicIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble CubicIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d; return c * t * t * t + b; } -inline eeFloat CubicOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble CubicOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t = t / d - 1; return c * ( t * t * t + 1) + b; } -inline eeFloat CubicInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble CubicInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d / 2; if ( t < 1 ) @@ -265,23 +265,23 @@ inline eeFloat CubicInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { return c / 2 * ( t * t * t + 2 ) + b; } -inline eeFloat BackIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { - eeFloat s = 1.70158f; +inline eeDouble BackIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { + eeDouble s = 1.70158f; t /= d; return c * t * t * ( ( s + 1 ) * t - s) + b; } -inline eeFloat BackOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { - eeFloat s = 1.70158f; +inline eeDouble BackOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { + eeDouble s = 1.70158f; t = t / d - 1; return c * ( t * t * ( ( s + 1 ) * t + s ) + 1 ) + b; } -inline eeFloat BackInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble BackInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { float s = 1.70158f; t /= d / 2; @@ -295,7 +295,7 @@ inline eeFloat BackInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { return c / 2 * ( t * t * ( ( s + 1 ) * t + s ) + 2) + b; } -inline eeFloat BounceOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble BounceOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { t /= d; if ( t < ( 1.f / 2.75f ) ) { @@ -315,18 +315,18 @@ inline eeFloat BounceOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { } } -inline eeFloat BounceIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble BounceIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { return c - BounceOut( d - t, 0, c, d ) + b; } -inline eeFloat BounceInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble BounceInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { if ( t < d * 0.5f ) return BounceIn( t * 2.f, 0.f, c, d ) * 0.5f + b; return BounceOut( t * 2.f - d, 0.f, c, d ) * 0.5f + c * 0.5f + b; } -inline eeFloat ElasticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble ElasticIn( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { if ( t == 0.f ) return b; @@ -335,16 +335,16 @@ inline eeFloat ElasticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { if ( t == 1.f ) return b + c; - eeFloat p = d * 0.3f; - eeFloat s = p / 4.f; - eeFloat a = c; + eeDouble p = d * 0.3f; + eeDouble s = p / 4.f; + eeDouble a = c; t -= 1.f; return -( a * eepow( 2.f , 10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) ) + b; } -inline eeFloat ElasticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble ElasticOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { if ( t == 0.f ) return b; @@ -353,14 +353,14 @@ inline eeFloat ElasticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { if ( t ==1 ) return b + c; - eeFloat p = d * 0.3f; - eeFloat s = p / 4.f; - eeFloat a = c; + eeDouble p = d * 0.3f; + eeDouble s = p / 4.f; + eeDouble a = c; return ( a * eepow( 2.f, -10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) + c + b ); } -inline eeFloat ElasticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { +inline eeDouble ElasticInOut( eeDouble t, eeDouble b, eeDouble c, eeDouble d ) { if ( t == 0 ) return b; @@ -369,9 +369,9 @@ inline eeFloat ElasticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { if ( t == 2 ) return b + c; - eeFloat p = d * ( 0.3f * 1.5f ); - eeFloat a = c; - eeFloat s = p / 4.f; + eeDouble p = d * ( 0.3f * 1.5f ); + eeDouble a = c; + eeDouble s = p / 4.f; if ( t < 1 ) { t -= 1.f; diff --git a/include/eepp/system/cclock.hpp b/include/eepp/system/cclock.hpp index 68bb5c278..c226584a0 100644 --- a/include/eepp/system/cclock.hpp +++ b/include/eepp/system/cclock.hpp @@ -16,13 +16,15 @@ class EE_API cClock { ~cClock(); /** Resets timer */ - void Reset(); + void Restart(); /** Returns microseconds since initialisation or last reset */ - cTime GetElapsedTime(); + cTime GetElapsedTime() const; - /** Time in milliseconds elapsed between this call and the last call to Elapsed() */ - eeDouble Elapsed(); + /** Time in milliseconds elapsed between this call and the last call to Elapsed() + * This is the equivalent to call GetElapsedTime() and then Reset(). + */ + cTime Elapsed(); private: Platform::cClockImpl * mClockImpl; }; diff --git a/include/eepp/system/ctime.hpp b/include/eepp/system/ctime.hpp index 7f7b121a8..113aa0f2c 100644 --- a/include/eepp/system/ctime.hpp +++ b/include/eepp/system/ctime.hpp @@ -2,7 +2,7 @@ #ifndef EE_SYSTEMCTIME_HPP #define EE_SYSTEMCTIME_HPP -// Base on the SFML2 implementation! +//! Based on the SFML2 implementation ( not the same, this version uses doubles for seconds and milliseconds ) #include @@ -12,23 +12,23 @@ namespace EE { namespace System { class EE_API cTime { public : - /// @brief Default constructor - /// Sets the time value to zero. + /** @brief Default constructor + ** Sets the time value to zero. */ cTime(); - /// @brief Return the time value as a number of seconds - /// @return cTime in seconds - /// @see AsMilliseconds, AsMicroseconds + /** @brief Return the time value as a number of seconds + ** @return cTime in seconds + ** @see AsMilliseconds, AsMicroseconds */ eeDouble AsSeconds() const; - /// @brief Return the time value as a number of milliseconds - /// @return cTime in milliseconds - /// @see AsSeconds, AsMicroseconds + /** @brief Return the time value as a number of milliseconds + ** @return cTime in milliseconds + ** @see AsSeconds, AsMicroseconds */ eeDouble AsMilliseconds() const; - /// @brief Return the time value as a number of microseconds - /// @return cTime in microseconds - /// @see asSeconds, asMilliseconds + /** @brief Return the time value as a number of microseconds + ** @return cTime in microseconds + ** @see asSeconds, asMilliseconds */ Int64 AsMicroseconds() const; static const cTime Zero; ///< Predefined "zero" time value @@ -47,246 +47,206 @@ class EE_API cTime Int64 mMicroseconds; ///< cTime value stored as microseconds }; -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Construct a time value from a number of seconds -/// /// @param amount Number of seconds -/// /// @return cTime value constructed from the amount of seconds -/// -/// @see milliseconds, microseconds -/// -//////////////////////////////////////////////////////////// +/// @see Milliseconds, Microseconds EE_API cTime Seconds(eeDouble amount); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Construct a time value from a number of milliseconds -/// /// @param amount Number of milliseconds -/// /// @return cTime value constructed from the amount of milliseconds -/// -/// @see seconds, microseconds -/// -//////////////////////////////////////////////////////////// +/// @see Seconds, Microseconds EE_API cTime Milliseconds(eeDouble amount); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Construct a time value from a number of microseconds -/// /// @param amount Number of microseconds -/// /// @return cTime value constructed from the amount of microseconds -/// -/// @see seconds, milliseconds -/// -//////////////////////////////////////////////////////////// +/// @see Seconds, Milliseconds EE_API cTime Microseconds(Int64 amount); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of == operator to compare two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return True if both time values are equal -/// -//////////////////////////////////////////////////////////// EE_API bool operator ==(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of != operator to compare two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return True if both time values are different -/// -//////////////////////////////////////////////////////////// EE_API bool operator !=(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of < operator to compare two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return True if \a left is lesser than \a right -/// -//////////////////////////////////////////////////////////// EE_API bool operator <(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of > operator to compare two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return True if \a left is greater than \a right -/// -//////////////////////////////////////////////////////////// EE_API bool operator >(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of <= operator to compare two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return True if \a left is lesser or equal than \a right -/// -//////////////////////////////////////////////////////////// EE_API bool operator <=(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of >= operator to compare two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return True if \a left is greater or equal than \a right -/// -//////////////////////////////////////////////////////////// EE_API bool operator >=(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of unary - operator to negate a time value -/// /// @param right Right operand (a time) -/// /// @return Opposite of the time value -/// -//////////////////////////////////////////////////////////// EE_API cTime operator -(cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary + operator to add two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return Sum of the two times values -/// -//////////////////////////////////////////////////////////// EE_API cTime operator +(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary += operator to add/assign two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return Sum of the two times values -/// -//////////////////////////////////////////////////////////// EE_API cTime& operator +=(cTime& left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary - operator to subtract two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return Difference of the two times values -/// -//////////////////////////////////////////////////////////// EE_API cTime operator -(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary -= operator to subtract/assign two time values -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return Difference of the two times values -/// -//////////////////////////////////////////////////////////// EE_API cTime& operator -=(cTime& left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary * operator to scale a time value -/// /// @param left Left operand (a time) /// @param right Right operand (a number) -/// /// @return \a left multiplied by \a right -/// -//////////////////////////////////////////////////////////// EE_API cTime operator *(cTime left, cTime right); -//////////////////////////////////////////////////////////// +/// @relates Time +/// @brief Overload of binary * operator to scale a time value +/// @param left Left operand (a time) +/// @param right Right operand (a number) +/// @return \a left multiplied by \a right +EE_API cTime operator *(cTime left, eeDouble right); + +/// @relates Time +/// @brief Overload of binary * operator to scale a time value +/// @param left Left operand (a number) +/// @param right Right operand (a time) +/// @return \a left multiplied by \a right +EE_API cTime operator *(eeDouble left, cTime right); + +/// @relates Time +/// @brief Overload of binary * operator to scale a time value +/// @param left Left operand (a number) +/// @param right Right operand (a time) +/// @return \a left multiplied by \a right +EE_API cTime operator *(Int64 left, cTime right); + +/// @relates Time +/// @brief Overload of binary * operator to scale a time value +/// @param left Left operand (a time) +/// @param right Right operand (a number) +/// @return \a left multiplied by \a right +EE_API cTime operator *(cTime left, Int64 right); + +/// @relates Time +/// @brief Overload of binary *= operator to scale/assign a time value +/// @param left Left operand (a time) +/// @param right Right operand (a number) +/// @return \a left multiplied by \a right +EE_API cTime& operator *=(cTime& left, eeDouble right); + +/// @relates Time +/// @brief Overload of binary *= operator to scale/assign a time value +/// @param left Left operand (a time) +/// @param right Right operand (a number) +/// @return \a left multiplied by \a right +EE_API cTime& operator *=(cTime& left, Int64 right); + /// @relates cTime /// @brief Overload of binary *= operator to scale/assign a time value -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return \a left multiplied by \a right -/// -//////////////////////////////////////////////////////////// EE_API cTime& operator *=(cTime& left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary / operator to scale a time value -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return \a left divided by \a right -/// -//////////////////////////////////////////////////////////// EE_API cTime operator /(cTime left, cTime right); -//////////////////////////////////////////////////////////// +/// @relates Time +/// @brief Overload of binary / operator to scale a time value +/// @param left Left operand (a time) +/// @param right Right operand (a number) +/// @return \a left divided by \a right +EE_API cTime operator /(cTime left, eeDouble right); + +/// @relates Time +/// @brief Overload of binary / operator to scale a time value +/// @param left Left operand (a time) +/// @param right Right operand (a number) +/// @return \a left divided by \a right +EE_API cTime operator /(cTime left, Int64 right); + +/// @relates Time +/// @brief Overload of binary /= operator to scale/assign a time value +/// @param left Left operand (a time) +/// @param right Right operand (a number) +/// @return \a left divided by \a right +EE_API cTime& operator /=(cTime& left, Int64 right); + /// @relates cTime /// @brief Overload of binary /= operator to scale/assign a time value -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return \a left divided by \a right -/// -//////////////////////////////////////////////////////////// EE_API cTime& operator /=(cTime& left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary % operator to compute remainder of a time value -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return \a left modulo \a right -/// -//////////////////////////////////////////////////////////// EE_API cTime operator %(cTime left, cTime right); -//////////////////////////////////////////////////////////// /// @relates cTime /// @brief Overload of binary %= operator to compute/assign remainder of a time value -/// /// @param left Left operand (a time) /// @param right Right operand (a time) -/// /// @return \a left modulo \a right -/// -//////////////////////////////////////////////////////////// EE_API cTime& operator %=(cTime& left, cTime right); }} @@ -315,27 +275,27 @@ EE_API cTime& operator %=(cTime& left, cTime right); /// value, times can also be negative. /// /// Usage example: -/// \code +/// @code /// cTime t1 = Seconds(0.1f); -/// Int32 milli = t1.AsMilliseconds(); // 100 +/// eeDouble milli = t1.AsMilliseconds(); // 100 /// /// cTime t2 = Milliseconds(30); /// Int64 micro = t2.AsMicroseconds(); // 30000 /// /// cTime t3 = Microseconds(-800000); -/// float sec = t3.AsSeconds(); // -0.8 -/// \endcode +/// eeDouble sec = t3.AsSeconds(); // -0.8 +/// @endcode /// -/// \code +/// @code /// void update(cTime elapsed) /// { /// position += speed * elapsed; /// } /// /// update(Milliseconds(100)); -/// \endcode +/// @endcode /// -/// @see sf::Clock +/// @see cClock /// //////////////////////////////////////////////////////////// diff --git a/include/eepp/ui/cuicontrol.hpp b/include/eepp/ui/cuicontrol.hpp index 09b24b088..3870bbe27 100644 --- a/include/eepp/ui/cuicontrol.hpp +++ b/include/eepp/ui/cuicontrol.hpp @@ -365,7 +365,7 @@ class EE_API cUIControl { void SendParentSizeChange( const eeVector2i& SizeChange ); - eeFloat Elapsed(); + cTime Elapsed(); eeRecti MakePadding( bool PadLeft = true, bool PadRight = true, bool PadTop = true, bool PadBottom = true, bool SkipFlags = false ); diff --git a/include/eepp/ui/cuimanager.hpp b/include/eepp/ui/cuimanager.hpp index 04bb9933e..5e71e7cd5 100644 --- a/include/eepp/ui/cuimanager.hpp +++ b/include/eepp/ui/cuimanager.hpp @@ -32,7 +32,7 @@ class EE_API cUIManager { void Draw(); - const eeFloat& Elapsed() const; + const cTime& Elapsed() const; void ResizeControl( cWindow * win ); @@ -98,7 +98,7 @@ class EE_API cUIManager { std::list mWindowsList; std::list mCloseList; - eeFloat mElapsed; + cTime mElapsed; Int32 mCbId; Uint32 mResizeCb; diff --git a/include/eepp/window/cengine.hpp b/include/eepp/window/cengine.hpp index f641da650..35428d281 100755 --- a/include/eepp/window/cengine.hpp +++ b/include/eepp/window/cengine.hpp @@ -40,7 +40,7 @@ class EE_API cEngine { bool Running() const; /** @return The current window elapsed time. */ - eeFloat Elapsed() const; + cTime Elapsed() const; /** @return The current window width. */ const Uint32& GetWidth() const; diff --git a/include/eepp/window/cwindow.hpp b/include/eepp/window/cwindow.hpp index 962d34761..e939bd4d0 100644 --- a/include/eepp/window/cwindow.hpp +++ b/include/eepp/window/cwindow.hpp @@ -221,7 +221,7 @@ class EE_API cWindow { virtual void Display( bool clear = true ); /** @return The elapsed time for the last frame rendered */ - virtual eeFloat Elapsed() const; + virtual cTime Elapsed() const; /** @return The current frames per second of the screen */ virtual Uint32 FPS() const; @@ -455,8 +455,8 @@ class EE_API cWindow { }; cFPSData FPS; - cClock * FrameElapsed; - eeFloat ElapsedTime; + cClock * FrameElapsed; + cTime ElapsedTime; cFrameData(); diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index e3b935ea7..8db593040 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -48,7 +48,7 @@ Desktop Desktop {388e5431-b31b-42b3-b9ad-9002d279d75d} - 0 + 10 0 0 diff --git a/projects/linux/ee.files b/projects/linux/ee.files index c8d05c028..93b9d78ac 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -620,3 +620,5 @@ ../../src/eepp/system/platform/posix/cconditionimpl.hpp ../../src/eepp/system/platform/posix/cconditionimpl.cpp ../../include/eepp/graphics/opengl.hpp +../../src/eepp/system/ctime.cpp +../../include/eepp/system/ctime.hpp diff --git a/src/eepp/graphics/cconsole.cpp b/src/eepp/graphics/cconsole.cpp index 14686065b..56b6a5f64 100755 --- a/src/eepp/graphics/cconsole.cpp +++ b/src/eepp/graphics/cconsole.cpp @@ -327,13 +327,13 @@ void cConsole::Toggle() { void cConsole::Fade() { if (mCurSide) { - mCurAlpha -= 255.f * mWindow->Elapsed() / mFadeSpeed; + mCurAlpha -= 255.f * mWindow->Elapsed().AsMilliseconds() / mFadeSpeed; if ( mCurAlpha <= 0.0f ) { mCurAlpha = 0.0f; mCurSide = !mCurSide; } } else { - mCurAlpha += 255.f * mWindow->Elapsed() / mFadeSpeed; + mCurAlpha += 255.f * mWindow->Elapsed().AsMilliseconds() / mFadeSpeed; if ( mCurAlpha >= 255.f ) { mCurAlpha = 255.f; mCurSide = !mCurSide; @@ -347,7 +347,7 @@ void cConsole::Fade() { if ( mFadeIn ) { mFadeOut = false; - mY += mCurHeight * mWindow->Elapsed() / mFadeSpeed; + mY += mCurHeight * mWindow->Elapsed().AsMilliseconds() / mFadeSpeed; mA = ( mY * mMaxAlpha / mCurHeight ) ; if ( mY > mCurHeight ) { @@ -359,7 +359,7 @@ void cConsole::Fade() { if ( mFadeOut ) { mFadeIn = false; - mY -= mCurHeight * mWindow->Elapsed() / mFadeSpeed; + mY -= mCurHeight * mWindow->Elapsed().AsMilliseconds() / mFadeSpeed; mA = ( mY * mMaxAlpha / mCurHeight ) ; if ( mY <= 0.0f ) { diff --git a/src/eepp/graphics/cparticlesystem.cpp b/src/eepp/graphics/cparticlesystem.cpp index f35e78665..7de0d1fe3 100755 --- a/src/eepp/graphics/cparticlesystem.cpp +++ b/src/eepp/graphics/cparticlesystem.cpp @@ -363,7 +363,7 @@ void cParticleSystem::Update() { Update( cEngine::instance()->Elapsed() ); } -void cParticleSystem::Update( const eeFloat& Time ) { +void cParticleSystem::Update( const cTime& Time ) { if ( !mUsed ) return; @@ -373,7 +373,7 @@ void cParticleSystem::Update( const eeFloat& Time ) { P = &mParticle[i]; if ( P->Used() || P->A() > 0.f ) { - P->Update( Time * mTime ); + P->Update( Time.AsMilliseconds() * mTime ); // If not alive if ( P->A() <= 0.f ) { diff --git a/src/eepp/graphics/cscrollparallax.cpp b/src/eepp/graphics/cscrollparallax.cpp index 25eae623a..fe6a65a32 100755 --- a/src/eepp/graphics/cscrollparallax.cpp +++ b/src/eepp/graphics/cscrollparallax.cpp @@ -82,7 +82,7 @@ const eeVector2f& cScrollParallax::Position() const { void cScrollParallax::Draw() { if ( NULL != mSubTexture && mAABB.Left != mAABB.Right && mAABB.Top != mAABB.Bottom && 0 != mColor.Alpha ) { - mPos += ( ( mSpeed * (eeFloat)mElapsed.Elapsed() ) / (eeFloat)1000 ); + mPos += mSpeed * (eeFloat)mElapsed.Elapsed().AsSeconds(); if ( mPos.x > mAABB.Left + mRealSize.Width() || mPos.x < mAABB.Left - mRealSize.Width() ) mPos.x = mAABB.Left; diff --git a/src/eepp/graphics/csprite.cpp b/src/eepp/graphics/csprite.cpp index 1ccb66db1..a88535e8f 100755 --- a/src/eepp/graphics/csprite.cpp +++ b/src/eepp/graphics/csprite.cpp @@ -481,20 +481,20 @@ bool cSprite::AddSubFrame(const Uint32& TexId, const eeUint& NumFrame, const eeU } void cSprite::Update() { - Update( (eeFloat)cEngine::instance()->Elapsed() ); + Update( cEngine::instance()->Elapsed() ); } -void cSprite::Update( const eeFloat& ElapsedTime ) { - if ( mFrames.size() > 1 && !SPR_FGET( SPRITE_FLAG_ANIM_PAUSED ) && 0 != ElapsedTime ) { +void cSprite::Update( const cTime& ElapsedTime ) { + if ( mFrames.size() > 1 && !SPR_FGET( SPRITE_FLAG_ANIM_PAUSED ) && cTime::Zero != ElapsedTime ) { eeUint Size = (eeUint)mFrames.size() - 1; if ( mRepeations == 0 ) return; if ( !SPR_FGET( SPRITE_FLAG_REVERSE_ANIM ) ) - mfCurrentFrame += ( ( mAnimSpeed * ElapsedTime ) / 1000.f ); + mfCurrentFrame += mAnimSpeed * ElapsedTime.AsSeconds(); else - mfCurrentFrame -= ( ( mAnimSpeed * ElapsedTime ) / 1000.f ); + mfCurrentFrame -= mAnimSpeed * ElapsedTime.AsSeconds(); mCurrentFrame = (eeUint)mfCurrentFrame; diff --git a/src/eepp/graphics/ctextureloader.cpp b/src/eepp/graphics/ctextureloader.cpp index 79bc5ffe1..d7accab9e 100644 --- a/src/eepp/graphics/ctextureloader.cpp +++ b/src/eepp/graphics/ctextureloader.cpp @@ -227,7 +227,7 @@ cTextureLoader::~cTextureLoader() { void cTextureLoader::Start() { cObjectLoader::Start(); - mTE.Reset(); + mTE.Restart(); if ( TEX_LT_PATH == mLoadType ) LoadFromPath(); @@ -471,7 +471,7 @@ void cTextureLoader::LoadFromPixels() { mTexId = cTextureFactory::instance()->PushTexture( mFilepath, tTexId, width, height, mImgWidth, mImgHeight, mMipmap, mChannels, mClampMode, mCompressTexture || mIsCompressed, mLocalCopy, mSize ); - cLog::instance()->Write( "Texture " + mFilepath + " loaded in " + String::ToStr( mTE.Elapsed() ) + " ms." ); + cLog::instance()->Write( "Texture " + mFilepath + " loaded in " + String::ToStr( mTE.Elapsed().AsMilliseconds() ) + " ms." ); } else { cLog::instance()->Write( "Failed to create texture. Reason: " + std::string( SOIL_last_result() ) ); } diff --git a/src/eepp/math/cinterpolation.cpp b/src/eepp/math/cinterpolation.cpp index d0f14c878..22b00ef08 100644 --- a/src/eepp/math/cinterpolation.cpp +++ b/src/eepp/math/cinterpolation.cpp @@ -127,7 +127,7 @@ const eeFloat& cInterpolation::GetRealPos() const { return mCurPos; } -void cInterpolation::Update( const eeFloat& Elapsed ) { +void cInterpolation::Update( const cTime& Elapsed ) { if ( mEnable && mPoints.size() > 1 && mCurPoint != mPoints.size() ) { if ( mUpdate ) { mCurTime = 0; @@ -161,7 +161,7 @@ void cInterpolation::Update( const eeFloat& Elapsed ) { mUpdate = false; } - mCurTime += Elapsed; + mCurTime += Elapsed.AsMilliseconds(); mCurPos = easingCb[ mType ]( mCurTime, mActP->p, ( mNexP->p - mActP->p ), mActP->t ); diff --git a/src/eepp/math/cwaypoints.cpp b/src/eepp/math/cwaypoints.cpp index 85198188f..573277461 100755 --- a/src/eepp/math/cwaypoints.cpp +++ b/src/eepp/math/cwaypoints.cpp @@ -143,7 +143,7 @@ const eeVector2f& cWaypoints::GetPos() { return mCurPos; } -void cWaypoints::Update( const eeFloat& Elapsed ) { +void cWaypoints::Update( const cTime& Elapsed ) { if ( mEnable && mPoints.size() > 1 && mCurPoint != mPoints.size() ) { if ( mUpdate ) { mCurTime = 0; @@ -177,7 +177,7 @@ void cWaypoints::Update( const eeFloat& Elapsed ) { mUpdate = false; } - mCurTime += Elapsed; + mCurTime += Elapsed.AsMilliseconds(); mCurPos.x = easingCb[ mType ]( mCurTime, mActP->p.x, ( mNexP->p.x - mActP->p.x ), mActP->t ); mCurPos.y = easingCb[ mType ]( mCurTime, mActP->p.y, ( mNexP->p.y - mActP->p.y ), mActP->t ); @@ -195,7 +195,7 @@ void cWaypoints::Update( const eeFloat& Elapsed ) { } } -void cWaypoints::SetTotalTime( const eeFloat& TotTime ) { +void cWaypoints::SetTotalTime( const eeDouble& TotTime ) { eeUint i; eeFloat tdist = mTotDist; diff --git a/src/eepp/physics/cspace.cpp b/src/eepp/physics/cspace.cpp index 238ca715f..68bd14096 100644 --- a/src/eepp/physics/cspace.cpp +++ b/src/eepp/physics/cspace.cpp @@ -64,7 +64,7 @@ void cSpace::Step( const cpFloat& dt ) { void cSpace::Update() { #ifdef PHYSICS_RENDERER_ENABLED - Step( Window::cEngine::instance()->Elapsed() / 1000 ); + Step( Window::cEngine::instance()->Elapsed().AsSeconds() ); #else Step( 1 / 60 ); #endif diff --git a/src/eepp/system/cclock.cpp b/src/eepp/system/cclock.cpp index f17788eeb..d16fcb2de 100755 --- a/src/eepp/system/cclock.cpp +++ b/src/eepp/system/cclock.cpp @@ -6,24 +6,24 @@ namespace EE { namespace System { cClock::cClock() : mClockImpl( eeNew( Platform::cClockImpl, () ) ) { - Reset(); + Restart(); } cClock::~cClock() { eeSAFE_DELETE( mClockImpl ); } -void cClock::Reset() { - mClockImpl->Reset(); +void cClock::Restart() { + mClockImpl->Restart(); } -cTime cClock::GetElapsedTime() { +cTime cClock::GetElapsedTime() const { return Microseconds( mClockImpl->GetElapsedTime() ); } -eeDouble cClock::Elapsed() { - eeDouble r = GetElapsedTime().AsMicroseconds() / 1000.0; - Reset(); +cTime cClock::Elapsed() { + cTime r = GetElapsedTime(); + Restart(); return r; } diff --git a/src/eepp/system/ctime.cpp b/src/eepp/system/ctime.cpp index 6f9629c16..0a783c7f6 100644 --- a/src/eepp/system/ctime.cpp +++ b/src/eepp/system/ctime.cpp @@ -14,7 +14,7 @@ eeDouble cTime::AsSeconds() const { } eeDouble cTime::AsMilliseconds() const { - return static_cast(mMicroseconds / 1000.0); + return mMicroseconds / 1000.0; } Int64 cTime::AsMicroseconds() const { @@ -86,18 +86,54 @@ cTime operator *(cTime left, cTime right) { return Microseconds(left.AsMicroseconds() * right.AsMicroseconds()); } +cTime operator *(cTime left, eeDouble right) { + return Seconds(left.AsSeconds() * right); +} + +cTime operator *(eeDouble left, cTime right) { + return right * left; +} + +cTime operator *(cTime left, Int64 right) { + return Microseconds(left.AsMicroseconds() * right); +} + +cTime operator *(Int64 left, cTime right) { + return right * left; +} + cTime& operator *=(cTime& left, cTime right) { return left = left * right; } +cTime& operator *=(cTime& left, eeDouble right) { + return left = left * right; +} + +cTime& operator *=(cTime& left, Int64 right) { + return left = left * right; +} + cTime operator /(cTime left, cTime right) { return Microseconds(left.AsMicroseconds() / right.AsMicroseconds()); } +cTime operator /(cTime left, eeDouble right) { + return Seconds(left.AsSeconds() / right); +} + +cTime operator /(cTime left, Int64 right) { + return Microseconds(left.AsMicroseconds() / right); +} + cTime& operator /=(cTime& left, cTime right) { return left = left / right; } +cTime& operator /=(cTime& left, Int64 right) { + return left = left / right; +} + cTime operator %(cTime left, cTime right) { return Microseconds(left.AsMicroseconds() % right.AsMicroseconds()); } diff --git a/src/eepp/system/platform/posix/cclockimpl.cpp b/src/eepp/system/platform/posix/cclockimpl.cpp index fd887846a..0b5e3fd52 100644 --- a/src/eepp/system/platform/posix/cclockimpl.cpp +++ b/src/eepp/system/platform/posix/cclockimpl.cpp @@ -10,7 +10,7 @@ cClockImpl::cClockImpl() { cClockImpl::~cClockImpl() { } -void cClockImpl::Reset() { +void cClockImpl::Restart() { #ifdef EE_HAVE_CLOCK_GETTIME clock_gettime( CLOCK_MONOTONIC, &mStart ); #else diff --git a/src/eepp/system/platform/posix/cclockimpl.hpp b/src/eepp/system/platform/posix/cclockimpl.hpp index ab8ccc584..3d9428585 100644 --- a/src/eepp/system/platform/posix/cclockimpl.hpp +++ b/src/eepp/system/platform/posix/cclockimpl.hpp @@ -19,7 +19,7 @@ class cClockImpl { ~cClockImpl(); - void Reset(); + void Restart(); unsigned long GetElapsedTime(); private: diff --git a/src/eepp/system/platform/win/cclockimpl.cpp b/src/eepp/system/platform/win/cclockimpl.cpp index 7bc216f30..879b47580 100644 --- a/src/eepp/system/platform/win/cclockimpl.cpp +++ b/src/eepp/system/platform/win/cclockimpl.cpp @@ -12,7 +12,7 @@ cClockImpl::cClockImpl() : cClockImpl::~cClockImpl() { } -void cClockImpl::Reset() { +void cClockImpl::Restart() { // Get the current process core mask DWORD procMask; DWORD sysMask; diff --git a/src/eepp/system/platform/win/cclockimpl.hpp b/src/eepp/system/platform/win/cclockimpl.hpp index c952d95b3..db323015f 100644 --- a/src/eepp/system/platform/win/cclockimpl.hpp +++ b/src/eepp/system/platform/win/cclockimpl.hpp @@ -29,7 +29,7 @@ class cClockImpl { ~cClockImpl(); - void Reset(); + void Restart(); unsigned long GetElapsedTime(); private: diff --git a/src/eepp/ui/cuicomplexcontrol.cpp b/src/eepp/ui/cuicomplexcontrol.cpp index 90aef3b21..243c0e12e 100644 --- a/src/eepp/ui/cuicomplexcontrol.cpp +++ b/src/eepp/ui/cuicomplexcontrol.cpp @@ -55,7 +55,7 @@ void cUIComplexControl::Update() { mTooltip->Show(); } else { if ( -1.f != mTooltip->TooltipTime() ) { - mTooltip->TooltipTimeAdd( cUIManager::instance()->Elapsed() ); + mTooltip->TooltipTimeAdd( cUIManager::instance()->Elapsed().AsMilliseconds() ); } if ( mTooltip->TooltipTime() >= cUIThemeManager::instance()->TooltipTimeToShow() ) { diff --git a/src/eepp/ui/cuicontrol.cpp b/src/eepp/ui/cuicontrol.cpp index a3fff384a..1df4f41b5 100644 --- a/src/eepp/ui/cuicontrol.cpp +++ b/src/eepp/ui/cuicontrol.cpp @@ -872,7 +872,7 @@ void cUIControl::UpdateQuad() { }; } -eeFloat cUIControl::Elapsed() { +cTime cUIControl::Elapsed() { return cUIManager::instance()->Elapsed(); } diff --git a/src/eepp/ui/cuigenericgrid.cpp b/src/eepp/ui/cuigenericgrid.cpp index f87928a19..58d0d1e7b 100644 --- a/src/eepp/ui/cuigenericgrid.cpp +++ b/src/eepp/ui/cuigenericgrid.cpp @@ -579,11 +579,11 @@ void cUIGenericGrid::Update() { mVScrollBar->Value( mVScrollBar->Value() + ( -diff.y / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ) ); - mTouchDragAcceleration += Elapsed() * diff.y * mTouchDragDeceleration; + mTouchDragAcceleration += Elapsed().AsMilliseconds() * diff.y * mTouchDragDeceleration; mTouchDragPoint = Pos; } else { - mTouchDragAcceleration -= Elapsed() * mTouchDragAcceleration * 0.01f; + mTouchDragAcceleration -= Elapsed().AsMilliseconds() * mTouchDragAcceleration * 0.01f; } } else { // Mouse Down @@ -605,7 +605,7 @@ void cUIGenericGrid::Update() { if ( mTouchDragAcceleration > 0.01f || mTouchDragAcceleration < -0.01f ) { mVScrollBar->Value( mVScrollBar->Value() + ( -mTouchDragAcceleration / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ) ); - mTouchDragAcceleration -= mTouchDragAcceleration * mTouchDragDeceleration * Elapsed(); + mTouchDragAcceleration -= mTouchDragAcceleration * mTouchDragDeceleration * Elapsed().AsMilliseconds(); } } } diff --git a/src/eepp/ui/cuilistbox.cpp b/src/eepp/ui/cuilistbox.cpp index 5bb88a69f..3074f4452 100644 --- a/src/eepp/ui/cuilistbox.cpp +++ b/src/eepp/ui/cuilistbox.cpp @@ -970,11 +970,11 @@ void cUIListBox::Update() { mVScrollBar->Value( mVScrollBar->Value() + ( -diff.y / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ) ); - mTouchDragAcceleration += Elapsed() * diff.y * mTouchDragDeceleration; + mTouchDragAcceleration += Elapsed().AsMilliseconds() * diff.y * mTouchDragDeceleration; mTouchDragPoint = Pos; } else { - mTouchDragAcceleration -= Elapsed() * mTouchDragAcceleration * 0.01f; + mTouchDragAcceleration -= Elapsed().AsMilliseconds() * mTouchDragAcceleration * 0.01f; } } else { // Mouse Down @@ -996,7 +996,7 @@ void cUIListBox::Update() { if ( mTouchDragAcceleration > 0.01f || mTouchDragAcceleration < -0.01f ) { mVScrollBar->Value( mVScrollBar->Value() + ( -mTouchDragAcceleration / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ) ); - mTouchDragAcceleration -= mTouchDragAcceleration * mTouchDragDeceleration * Elapsed(); + mTouchDragAcceleration -= mTouchDragAcceleration * mTouchDragDeceleration * Elapsed().AsMilliseconds(); } } } diff --git a/src/eepp/ui/cuimanager.cpp b/src/eepp/ui/cuimanager.cpp index f6488dce4..ba86ab096 100644 --- a/src/eepp/ui/cuimanager.cpp +++ b/src/eepp/ui/cuimanager.cpp @@ -254,7 +254,7 @@ cUIWindow * cUIManager::MainControl() const { return mControl; } -const eeFloat& cUIManager::Elapsed() const { +const cTime& cUIManager::Elapsed() const { return mElapsed; } diff --git a/src/eepp/ui/cuimenusubmenu.cpp b/src/eepp/ui/cuimenusubmenu.cpp index c01069f7c..101ab230a 100644 --- a/src/eepp/ui/cuimenusubmenu.cpp +++ b/src/eepp/ui/cuimenusubmenu.cpp @@ -88,7 +88,7 @@ Uint32 cUIMenuSubMenu::OnMouseMove( const eeVector2i &Pos, const Uint32 Flags ) cUIMenuItem::OnMouseMove( Pos, Flags ); if ( NULL != mSubMenu && !mSubMenu->Visible() ) { - mTimeOver += cUIManager::instance()->Elapsed(); + mTimeOver += cUIManager::instance()->Elapsed().AsMilliseconds(); if ( mTimeOver >= mMaxTime ) { ShowSubMenu(); diff --git a/src/eepp/ui/cuitextinput.cpp b/src/eepp/ui/cuitextinput.cpp index e72207790..6ed91ca1d 100644 --- a/src/eepp/ui/cuitextinput.cpp +++ b/src/eepp/ui/cuitextinput.cpp @@ -70,7 +70,7 @@ void cUITextInput::Draw() { cUITextBox::Draw(); if ( mVisible && mTextBuffer.Active() && mTextBuffer.SupportFreeEditing() ) { - mWaitCursorTime += cUIManager::instance()->Elapsed(); + mWaitCursorTime += cUIManager::instance()->Elapsed().AsMilliseconds(); if ( mShowingWait ) { bool disableSmooth = mShowingWait && GLi->IsLineSmooth(); diff --git a/src/eepp/ui/cuitheme.cpp b/src/eepp/ui/cuitheme.cpp index 5941fd7b9..02e50cf05 100644 --- a/src/eepp/ui/cuitheme.cpp +++ b/src/eepp/ui/cuitheme.cpp @@ -169,7 +169,7 @@ cUITheme * cUITheme::LoadFromTextureAtlas( cUITheme * tTheme, cTextureAtlas * Te tTheme->Add( eeNew( cUISkinSimple, ( ElemFound[i] ) ) ); } - cLog::instance()->Write( "UI Theme Loaded in: " + String::ToStr( TE.Elapsed() ) + " ( from TextureAtlas )" ); + cLog::instance()->Write( "UI Theme Loaded in: " + String::ToStr( TE.Elapsed().AsMilliseconds() ) + " ( from TextureAtlas )" ); return tTheme; } @@ -232,7 +232,7 @@ cUITheme * cUITheme::LoadFromPath( cUITheme * tTheme, const std::string& Path, c tTheme->Add( eeNew( cUISkinSimple, ( ElemFound[i] ) ) ); } - cLog::instance()->Write( "UI Theme Loaded in: " + String::ToStr( TE.Elapsed() ) + " ( from path )" ); + cLog::instance()->Write( "UI Theme Loaded in: " + String::ToStr( TE.Elapsed().AsMilliseconds() ) + " ( from path )" ); return tTheme; } diff --git a/src/eepp/window/cengine.cpp b/src/eepp/window/cengine.cpp index d916a0481..a92cf4d23 100755 --- a/src/eepp/window/cengine.cpp +++ b/src/eepp/window/cengine.cpp @@ -261,7 +261,7 @@ bool cEngine::Running() const { return NULL != mWindow; } -eeFloat cEngine::Elapsed() const { +cTime cEngine::Elapsed() const { eeASSERT( Running() ); return mWindow->Elapsed(); diff --git a/src/eepp/window/cwindow.cpp b/src/eepp/window/cwindow.cpp index 58d735dd1..ac4af57df 100644 --- a/src/eepp/window/cwindow.cpp +++ b/src/eepp/window/cwindow.cpp @@ -45,7 +45,7 @@ namespace EE { namespace Window { cWindow::cFrameData::cFrameData() : FrameElapsed(NULL), - ElapsedTime(0) + ElapsedTime() {} cWindow::cFrameData::~cFrameData() @@ -261,7 +261,7 @@ Uint32 cWindow::FPS() const { return mFrameData.FPS.Current; } -eeFloat cWindow::Elapsed() const { +cTime cWindow::Elapsed() const { return mFrameData.ElapsedTime; } @@ -270,7 +270,7 @@ void cWindow::GetElapsedTime() { mFrameData.FrameElapsed = eeNew( cClock, () ); } - mFrameData.ElapsedTime = static_cast ( mFrameData.FrameElapsed->Elapsed() ); + mFrameData.ElapsedTime = mFrameData.FrameElapsed->Elapsed(); } void cWindow::CalculateFps() { @@ -286,7 +286,7 @@ void cWindow::CalculateFps() { void cWindow::LimitFps() { if ( mFrameData.FPS.Limit > 0 ) { mFrameData.FPS.Error = 0; - eeFloat RemainT = 1000.f / mFrameData.FPS.Limit - ( mFrameData.ElapsedTime * 0.1f ); + eeDouble RemainT = 1000.0 / mFrameData.FPS.Limit - ( mFrameData.ElapsedTime.AsMilliseconds() * 0.1f ); if ( RemainT < 0 ) { mFrameData.FPS.Error = 0; diff --git a/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp b/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp index 1853826ba..ecf709765 100644 --- a/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp +++ b/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp @@ -126,7 +126,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) Batch.Draw(); // Add the rotation angle - ang+=win->Elapsed() * 0.1f; + ang+=win->Elapsed().AsMilliseconds() * 0.1f; ang = (ang>=360) ? 0 : ang; // Change the scale value @@ -137,7 +137,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) side = false; scale = 0.5f; } - scale = (!side) ? scale+win->Elapsed() * 0.00025f : scale-win->Elapsed() * 0.00025f; + scale = (!side) ? scale+win->Elapsed().AsMilliseconds() * 0.00025f : scale-win->Elapsed().AsMilliseconds() * 0.00025f; // Draw frame win->Display(); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index f9ff4378d..c42814f47 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -153,7 +153,7 @@ void cEETest::CreateUIThemeTextureAtlas() { } void cEETest::LoadFonts() { - mFTE.Reset(); + mFTE.Restart(); cTextureLoader * tl = eeNew( cTextureLoader, ( MyPath + "fonts/conchars.png" ) ); tl->SetColorKey( eeColor(0,0,0) ); @@ -980,7 +980,7 @@ void cEETest::Run() { void cEETest::ParticlesThread() { while ( mWindow->Running() ) { if ( MultiViewportMode || Screen == 2 ) { - PSElapsed = (eeFloat)cElapsed.Elapsed(); + PSElapsed = cElapsed.Elapsed(); for ( Uint8 i = 0; i < PS.size(); i++ ) PS[i].Update( PSElapsed ); @@ -1041,7 +1041,7 @@ void cEETest::Screen2() { eeFloat PlanetX = HWidth - TNP[6]->Width() * 0.5f; eeFloat PlanetY = HHeight - TNP[6]->Height() * 0.5f; - ang+=et * 0.1f; + ang+=et.AsMilliseconds() * 0.1f; ang = (ang>=360) ? 0 : ang; if (scale>=1.5f) { @@ -1051,7 +1051,7 @@ void cEETest::Screen2() { side = false; scale = 0.5f; } - scale = (!side) ? scale+et * 0.00025f : scale-et * 0.00025f; + scale = (!side) ? scale+et.AsMilliseconds() * 0.00025f : scale-et.AsMilliseconds() * 0.00025f; if ( mUseShaders ) { mBlurFactor = ( 1.5f * 0.01f ) - ( scale * 0.01f ); @@ -1069,7 +1069,7 @@ void cEETest::Screen2() { TNP[3]->Draw( HWidth - 128, HHeight, 0, 1, eeColorA(255,255,255,50), ALPHA_NORMAL, RN_ISOMETRICVERTICAL); TNP[3]->Draw( HWidth, HHeight, 0, 1, eeColorA(255,255,255,50), ALPHA_NORMAL, RN_ISOMETRICVERTICALNEGATIVE); - alpha = (!aside) ? alpha+et * 0.1f : alpha-et * 0.1f; + alpha = (!aside) ? alpha+et.AsMilliseconds() * 0.1f : alpha-et.AsMilliseconds() * 0.1f; if (alpha>=255) { aside = true; alpha = 255; @@ -1113,7 +1113,7 @@ void cEETest::Screen2() { PR.DrawQuad( CL1.GetQuad() ); #endif - Ang = Ang + mWindow->Elapsed() * 0.1f; + Ang = Ang + mWindow->Elapsed().AsMilliseconds() * 0.1f; if (Ang > 360.f) Ang = 1.f; if ( ShowParticles ) @@ -1170,7 +1170,7 @@ void cEETest::Screen3() { AnimVal = 0.5f; AnimSide = false; } - AnimVal = (!AnimSide) ? AnimVal+et * 0.1f : AnimVal-et * 0.1f; + AnimVal = (!AnimSide) ? AnimVal+et.AsMilliseconds() * 0.1f : AnimVal-et.AsMilliseconds() * 0.1f; Batch.SetTexture( TNP[3] ); Batch.LineLoopBegin(); @@ -1221,7 +1221,7 @@ void cEETest::Render() { #ifdef EE_DEBUG mInfo = String::StrFormated( "EE - FPS: %d Elapsed Time: %4.2f\nMouse X: %d Mouse Y: %d\nTexture Memory Usage: %s\nApp Memory Usage: %s\nApp Peak Memory Usage: %s", mWindow->FPS(), - et, + et.AsMilliseconds(), (Int32)Mouse.x, (Int32)Mouse.y, FileSystem::SizeToString( TF->MemorySize() ).c_str(), @@ -1231,7 +1231,7 @@ void cEETest::Render() { #else mInfo = String::StrFormated( "EE - FPS: %d Elapsed Time: %4.2f\nMouse X: %d Mouse Y: %d\nTexture Memory Usage: %s", mWindow->FPS(), - et, + et.AsMilliseconds(), (Int32)Mouse.x, (Int32)Mouse.y, FileSystem::SizeToString( TF->MemorySize() ).c_str() @@ -1425,7 +1425,7 @@ void cEETest::Input() { eeFloat aY = Joy->GetAxis( AXIS_Y ); if ( 0 != aX || 0 != aY ) { - eeFloat rE = mWindow->Elapsed(); + eeDouble rE = mWindow->Elapsed().AsMilliseconds(); mAxisX += aX * rE; mAxisY += aY * rE; } @@ -1466,39 +1466,39 @@ void cEETest::Input() { Uint8 hat = Joy->GetHat(); if ( HAT_LEFT == hat || HAT_LEFTDOWN == hat || HAT_LEFTUP == hat ) - Map.Move( (mWindow->Elapsed() * 0.2f), 0 ); + Map.Move( (mWindow->Elapsed().AsMilliseconds() * 0.2f), 0 ); if ( HAT_RIGHT == hat || HAT_RIGHTDOWN == hat || HAT_RIGHTUP == hat ) - Map.Move( -mWindow->Elapsed() * 0.2f, 0 ); + Map.Move( -mWindow->Elapsed().AsMilliseconds() * 0.2f, 0 ); if ( HAT_UP == hat || HAT_LEFTUP == hat || HAT_RIGHTUP == hat ) - Map.Move( 0, (mWindow->Elapsed() * 0.2f) ); + Map.Move( 0, (mWindow->Elapsed().AsMilliseconds() * 0.2f) ); if ( HAT_DOWN == hat || HAT_LEFTDOWN == hat || HAT_RIGHTDOWN == hat ) - Map.Move( 0, -mWindow->Elapsed() * 0.2f ); + Map.Move( 0, -mWindow->Elapsed().AsMilliseconds() * 0.2f ); } if ( KM->IsKeyDown(KEY_LEFT) ) { - Map.Move( mWindow->Elapsed() * 0.2f, 0 ); + Map.Move( mWindow->Elapsed().AsMilliseconds() * 0.2f, 0 ); } if ( KM->IsKeyDown(KEY_RIGHT) ) { - Map.Move( -mWindow->Elapsed() * 0.2f, 0 ); + Map.Move( -mWindow->Elapsed().AsMilliseconds() * 0.2f, 0 ); } if ( KM->IsKeyDown(KEY_UP) ) { - Map.Move( 0, mWindow->Elapsed() * 0.2f ); + Map.Move( 0, mWindow->Elapsed().AsMilliseconds() * 0.2f ); } if ( KM->IsKeyDown(KEY_DOWN) ) { - Map.Move( 0, -mWindow->Elapsed() * 0.2f ); + Map.Move( 0, -mWindow->Elapsed().AsMilliseconds() * 0.2f ); } if ( KM->IsKeyDown(KEY_KP_MINUS) ) - Map.BaseLight().Radius( Map.BaseLight().Radius() - mWindow->Elapsed() * 0.2f ); + Map.BaseLight().Radius( Map.BaseLight().Radius() - mWindow->Elapsed().AsMilliseconds() * 0.2f ); if ( KM->IsKeyDown(KEY_KP_PLUS) ) - Map.BaseLight().Radius( Map.BaseLight().Radius() + mWindow->Elapsed() * 0.2f ); + Map.BaseLight().Radius( Map.BaseLight().Radius() + mWindow->Elapsed().AsMilliseconds() * 0.2f ); if ( KM->IsKeyUp(KEY_F6) ) { Wireframe = !Wireframe; diff --git a/src/test/eetest.hpp b/src/test/eetest.hpp index 71b960f2f..39862d622 100644 --- a/src/test/eetest.hpp +++ b/src/test/eetest.hpp @@ -84,7 +84,7 @@ class cEETest : private cThread { void CmdSetPartsNum ( const std::vector < String >& params ); cClock cElapsed; - eeFloat PSElapsed; + cTime PSElapsed; private: cEngine * EE; Window::cWindow * mWindow; @@ -95,7 +95,7 @@ class cEETest : private cThread { bool side, aside; eeFloat ang, scale, alpha, Ang; - eeFloat et; + cTime et; Int32 x, y; Uint32 lasttick;