Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1695


Ignore:
Timestamp:
Sep 3, 2008, 8:29:53 PM (16 years ago)
Author:
rgrieder
Message:

Changed internal Timer clock from float to uint64_t

Location:
code/branches/gui/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/CorePrereqs.h

    r1689 r1695  
    100100  class ClassTreeMaskIterator;
    101101  class ClassTreeMaskNode;
     102  class Clock;
    102103  class CommandEvaluation;
    103104  class CommandExecutor;
  • code/branches/gui/src/core/RootGameState.cc

    r1690 r1695  
    131131    void RootGameState::start(int argc, char** argv)
    132132    {
     133        // start global orxonox time
     134        Clock clock;
     135
    133136        parseArguments(argc, argv);
    134137
     
    140143        gotoState(initialState);
    141144
    142         Clock clock;
    143145        while (this->activeChild_)
    144146        {
  • code/branches/gui/src/orxonox/tools/Timer.cc

    r1552 r1695  
    3636#include "core/ConsoleCommand.h"
    3737#include "core/CommandExecutor.h"
     38#include "core/Clock.h"
    3839
    3940namespace orxonox
     
    125126        @brief Updates the timer before the frames are rendered.
    126127    */
    127     void TimerBase::tick(float dt)
     128    void TimerBase::tick(const Clock& time)
    128129    {
    129130        if (this->bActive_)
    130131        {
    131132            // If active: Decrease the timer by the duration of the last frame
    132             this->time_ -= dt;
     133            this->time_ -= time.getDeltaTimeMicroseconds();
    133134
    134135            if (this->time_ <= 0)
  • code/branches/gui/src/orxonox/tools/Timer.h

    r1608 r1695  
    6262
    6363#include "OrxonoxPrereqs.h"
    64 #include "objects/Tickable.h"
     64#include "util/Integers.h"
     65#include "core/OrxonoxClass.h"
    6566
    6667namespace orxonox
     
    7273
    7374    //! TimerBase is the parent of the Timer class.
    74     class _OrxonoxExport TimerBase : public Tickable
     75    class _OrxonoxExport TimerBase : public OrxonoxClass
    7576    {
    7677        public:
     
    9798            /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */
    9899            inline float getRemainingTime() const
    99                 { return this->time_; }
     100                { return (float)this->time_ / 1000000.0f; }
    100101            /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */
    101102            inline void addTime(float time)
    102                 { this->time_ += time; }
     103                { if (time > 0.0f) this->time_ += (uint64_t)(time * 1000000.0f); }
    103104            /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */
    104105            inline void removeTime(float time)
    105                 { this->time_ -= time; }
     106                { if (time > 0.0f) this->time_ -= (uint64_t)(time * 1000000.0f); }
    106107            /** @brief Sets the interval of the Timer. @param interval The interval */
    107108            inline void setInterval(float interval)
    108                 { this->interval_ = interval; }
     109                { this->interval_ = (uint64_t)(interval * 1000000.0f); }
    109110            /** @brief Sets bLoop to a given value. @param bLoop True = loop */
    110111            inline void setLoop(bool bLoop)
    111112                { this->bLoop_ = bLoop; }
    112113
    113             void tick(float dt);
     114            void tick(const Clock& time);
    114115
    115116        protected:
     
    118119            Executor* executor_; //!< The executor of the function that should be called when the time expires
    119120
    120             float interval_;     //!< The time-interval in seconds
     121            uint64_t interval_;  //!< The time-interval in micro seconds
    121122            bool bLoop_;         //!< If true, the function gets called every 'interval' seconds
    122123            bool bActive_;       //!< If true, the Timer ticks and calls the function if the time's up
    123124
    124             float time_;         //!< Internal variable, counting the time till the next function-call
     125            uint64_t time_;      //!< Internal variable, counting the time till the next function-call
    125126    };
    126127
     
    155156                this->deleteExecutor();
    156157
    157                 this->interval_ = interval;
     158                this->setInterval(interval);
    158159                this->bLoop_ = bLoop;
    159160                executor->setObject(object);
     
    161162                this->bActive_ = true;
    162163
    163                 this->time_ = interval;
     164                this->time_ = this->interval_;
    164165            }
    165166    };
     
    193194                this->deleteExecutor();
    194195
    195                 this->interval_ = interval;
     196                this->setInterval(interval);
    196197                this->bLoop_ = bLoop;
    197198                this->executor_ = (Executor*)executor;
    198199                this->bActive_ = true;
    199200
    200                 this->time_ = interval;
     201                this->time_ = this->interval_;
    201202            }
    202203    };
Note: See TracChangeset for help on using the changeset viewer.