dm 7 years ago
parent
commit
1bbb0af87d
3 changed files with 48 additions and 17 deletions
  1. 28 8
      oxygine/src/oxygine/Clock.cpp
  2. 19 8
      oxygine/src/oxygine/Clock.h
  3. 1 1
      oxygine/src/oxygine/actor/Actor.cpp

+ 28 - 8
oxygine/src/oxygine/Clock.cpp

@@ -41,14 +41,29 @@ namespace oxygine
         return (int)_fixedStep;
         return (int)_fixedStep;
     }
     }
 
 
+    float   Clock::getFixedStepF() const
+    {
+        return _fixedStep / 1000.0f;
+    }
+
+    float   Clock::getLastDTF() const
+    {
+        return (float)(_lastDT/1000.0f);
+    }
+
     int Clock::getLastDT() const
     int Clock::getLastDT() const
     {
     {
-        return _lastDT;
+        return (int)_lastDT;
     }
     }
 
 
     timeMS  Clock::getLastUpdateTime() const
     timeMS  Clock::getLastUpdateTime() const
     {
     {
-        return _lastUpdateTime;
+        return (timeMS)_lastUpdateTime;
+    }
+
+    float   Clock::getLastUpdateTimeF() const
+    {
+        return (float)(_lastUpdateTime / 1000.0f);
     }
     }
 
 
     void Clock::setMultiplier(float m)
     void Clock::setMultiplier(float m)
@@ -61,6 +76,11 @@ namespace oxygine
         _fixedStep = step;
         _fixedStep = step;
     }
     }
 
 
+    void Clock::setFixedStepF(float step)
+    {
+        _fixedStep = step * 1000.0f;
+    }
+
     void Clock::pause()
     void Clock::pause()
     {
     {
         _counter += 1;
         _counter += 1;
@@ -94,7 +114,7 @@ namespace oxygine
             dt = 100;
             dt = 100;
         if (dt < 0)
         if (dt < 0)
             dt = 1;
             dt = 1;
-
+         
         if (_counter > 0)
         if (_counter > 0)
             dt = 0;//todo destTime == srcTime ??
             dt = 0;//todo destTime == srcTime ??
 
 
@@ -102,7 +122,7 @@ namespace oxygine
         _destTime += dt;
         _destTime += dt;
 
 
         _lastUpdateTime = time;
         _lastUpdateTime = time;
-        _lastDT = static_cast<int>(dt);
+        _lastDT = dt;
 
 
         //if (_fixedStep > 0)
         //if (_fixedStep > 0)
         //  printf("ticks: %d\n", int((_destTime - _srcTime)/_fixedStep));
         //  printf("ticks: %d\n", int((_destTime - _srcTime)/_fixedStep));
@@ -138,13 +158,13 @@ namespace oxygine
 
 
         if (_fixedStep == 0)
         if (_fixedStep == 0)
         {
         {
-            float dt = _destTime - _srcTime;
+            float dt = (float)(_destTime - _srcTime);
             _srcTime = _destTime;
             _srcTime = _destTime;
-            return dt;
+            return dt / 1000.0f;
         }
         }
 
 
         _srcTime += _fixedStep;
         _srcTime += _fixedStep;
-        return _fixedStep;
+        return _fixedStep / 1000.0f;
     }
     }
 
 
     timeMS Clock::getTime() const
     timeMS Clock::getTime() const
@@ -154,7 +174,7 @@ namespace oxygine
 
 
     float Clock::getTimeF() const
     float Clock::getTimeF() const
     {
     {
-        return _srcTime;
+        return (float)(_srcTime / 1000.0f);
     }
     }
 
 
     int Clock::getPauseCounter() const
     int Clock::getPauseCounter() const

+ 19 - 8
oxygine/src/oxygine/Clock.h

@@ -11,15 +11,26 @@ namespace oxygine
         Clock();
         Clock();
         ~Clock();
         ~Clock();
 
 
-        timeMS  getTime() const;
+        timeMS  getTime() const;//deprecated, use F 
+        int     getFixedStep() const;//deprecated, use F
+        void    setFixedStep(float stepMS);//deprecated, use F
+        timeMS  doTick();//deprecated, use F
+        timeMS  getLastUpdateTime() const;//deprecated, use F
+        int     getLastDT() const;//deprecated, use F
+
+        /**returns current clock time in seconds*/
         float   getTimeF() const;
         float   getTimeF() const;
         int     getPauseCounter() const;
         int     getPauseCounter() const;
-        int     getFixedStep() const;
-        int     getLastDT() const;
-        timeMS  getLastUpdateTime() const;
+        
+        float   getFixedStepF() const;
+        float   getLastDTF() const;
+        
+        float   getLastUpdateTimeF() const;
         float   getMultiplier() const;
         float   getMultiplier() const;
 
 
-        void    setFixedStep(float stepMS);
+        
+        /**set fixed actor update in seconds*/
+        void    setFixedStepF(float step);
         void    setMultiplier(float m);
         void    setMultiplier(float m);
 
 
         void    pause();
         void    pause();
@@ -27,7 +38,7 @@ namespace oxygine
         void    resetPause();
         void    resetPause();
 
 
         void    update(timeMS globalTime = -1);
         void    update(timeMS globalTime = -1);
-        timeMS  doTick();
+        
         float   doTickF();
         float   doTickF();
 
 
         std::string dump() const;
         std::string dump() const;
@@ -40,7 +51,7 @@ namespace oxygine
         float   _multiplier;
         float   _multiplier;
         float   _fixedStep;
         float   _fixedStep;
 
 
-        int    _lastDT;
-        timeMS _lastUpdateTime;
+        double _lastDT;
+        double _lastUpdateTime;
     };
     };
 }
 }

+ 1 - 1
oxygine/src/oxygine/actor/Actor.cpp

@@ -1079,7 +1079,7 @@ namespace oxygine
             float dt = _clock->doTickF();
             float dt = _clock->doTickF();
             while (dt > 0.0f)
             while (dt > 0.0f)
             {
             {
-                us.dt = (timeMS)dt;
+                us.dt = (timeMS)(dt * 1000);
                 us.dtf = dt;
                 us.dtf = dt;
                 us.time = _clock->getTime();
                 us.time = _clock->getTime();
                 us.timef = _clock->getTimeF();
                 us.timef = _clock->getTimeF();