Index: code/branches/hud/src/orxonox/GraphicsEngine.h
===================================================================
--- code/branches/hud/src/orxonox/GraphicsEngine.h	(revision 1620)
+++ code/branches/hud/src/orxonox/GraphicsEngine.h	(revision 1621)
@@ -72,8 +72,8 @@
             int getWindowHeight() const;
             float getWindowAspectRatio() const;
-            float getAverageFPS() const
-            { if (renderWindow_) return this->renderWindow_->getAverageFPS(); else return 0.0f; }
-            float getAverageRTR() const { return this->renderTimeRatio_; }
-            void setAverageRTR(float rtr) { this->renderTimeRatio_ = rtr; }
+            float getAverageFramesPerSecond() const { return this->avgFramesPerSecond_; }
+            float getAverageTickTime() const { return this->avgTickTime_; }
+            void setAverageTickTime(float tickTime) { this->avgTickTime_ = tickTime; }
+            void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
 
             void setWindowActivity(bool activity)
@@ -113,5 +113,6 @@
             int                 ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
             unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
-            float               renderTimeRatio_;       //!< Ratio between time required to render a frame and to tick() it
+            float               avgTickTime_;           //!< time in ms to tick() one frame
+            float               avgFramesPerSecond_;    //!< number of frames processed in one second
     };
 }
Index: code/branches/hud/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/hud/src/orxonox/Orxonox.cc	(revision 1620)
+++ code/branches/hud/src/orxonox/Orxonox.cc	(revision 1621)
@@ -103,7 +103,4 @@
     //, auMan_(0)
     , timer_(0)
-    // turn on frame smoothing by setting a value different from 0
-    , frameSmoothingTime_(0.0f)
-    //orxonoxHUD_(0)
     , bAbort_(false)
     , timefactor_(1.0f)
@@ -438,61 +435,69 @@
 
 
-    // Contains the times of recently fired events
-    // eventTimes[4] is the list for the times required for the fps counter
-    std::deque<unsigned long> eventTimes[3];
-    // Clear event times
-    for (int i = 0; i < 3; ++i)
-      eventTimes[i].clear();
-
     // use the ogre timer class to measure time.
     if (!timer_)
       timer_ = new Ogre::Timer();
+
+    unsigned long frameCount = 0;
+    
+    const unsigned long refreshTime = 3000000;
+    unsigned long refreshStartTime = 0;
+    unsigned long tickTime = 0;
+    unsigned long oldFrameCount = 0;
+
+    unsigned long timeBeforeTick = 0;
+    unsigned long timeBeforeTickOld = 0;
+    unsigned long timeAfterTick = 0;
+
+    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
+
     timer_->reset();
-
-    float renderTime = 0.0f;
-    float frameTime = 0.0f;
-//    clock_t time = 0;
-
-    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
     while (!bAbort_)
     {
       // get current time
-      unsigned long now = timer_->getMilliseconds();
-
-      // create an event to pass to the frameStarted method in ogre
-      Ogre::FrameEvent evt;
-      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
-      evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]);
-      frameTime += evt.timeSinceLastFrame;
-
-      // OverlayGroup::getHUD().setTime(now);
-      if (mode_ != DEDICATED && frameTime > 0.4f)
-      {
-        GraphicsEngine::getSingleton().setAverageRTR(renderTime / frameTime);
-        frameTime = 0.0f;
-        renderTime = 0.0f;
-      }
-
-      // tick the core
-      Core::tick((float)evt.timeSinceLastFrame);
+      timeBeforeTickOld = timeBeforeTick;
+      timeBeforeTick    = timer_->getMicroseconds();
+      float dt = (timeBeforeTick - timeBeforeTickOld) / 1000000.0;
+
+
+      // tick the core (needs real time for input and tcl thread management)
+      Core::tick(dt);
+
       // Call those objects that need the real time
       for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
-        it->tick((float)evt.timeSinceLastFrame);
+        it->tick(dt);
       // Call the scene objects
       for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
-        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
-      //AudioManager::tick();
+        it->tick(dt * this->timefactor_);
+
+      // call server/client with normal dt
       if (client_g)
-        client_g->tick((float)evt.timeSinceLastFrame);
+        client_g->tick(dt * this->timefactor_);
       if (server_g)
-        server_g->tick((float)evt.timeSinceLastFrame);
+        server_g->tick(dt * this->timefactor_);
+
+
+      // get current time once again
+      timeAfterTick = timer_->getMicroseconds();
+
+      tickTime += timeAfterTick - timeBeforeTick;
+      if (timeAfterTick > refreshStartTime + refreshTime)
+      {
+        GraphicsEngine::getSingleton().setAverageTickTime(
+            (float)tickTime * 0.001 / (frameCount - oldFrameCount));
+        GraphicsEngine::getSingleton().setAverageFramesPerSecond(
+            (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0);
+        oldFrameCount = frameCount;
+        tickTime = 0;
+        refreshStartTime = timeAfterTick;
+      }
+
 
       // don't forget to call _fireFrameStarted in ogre to make sure
       // everything goes smoothly
+      Ogre::FrameEvent evt;
+      evt.timeSinceLastFrame = dt;
+      evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
       ogreRoot._fireFrameStarted(evt);
-
-      // get current time
-      now = timer_->getMilliseconds();
-      calculateEventTime(now, eventTimes[2]);
 
       if (mode_ != DEDICATED)
@@ -501,4 +506,6 @@
         // This calls the WindowEventListener objects.
         Ogre::WindowEventUtilities::messagePump();
+        // make sure the window stays active even when not focused
+        // (probably only necessary on windows)
         GraphicsEngine::getSingleton().setWindowActivity(true);
 
@@ -507,14 +514,8 @@
       }
 
-      // get current time
-      now = timer_->getMilliseconds();
-
-      // create an event to pass to the frameEnded method in ogre
-      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
-      renderTime += calculateEventTime(now, eventTimes[2]);
-
       // again, just to be sure ogre works fine
-      ogreRoot._fireFrameEnded(evt);
-      //msleep(500);
+      ogreRoot._fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
+
+      ++frameCount;
     }
 
@@ -526,41 +527,3 @@
     return true;
   }
-
-  /**
-    Method for calculating the average time between recently fired events.
-    Code directly taken from OgreRoot.cc
-    @param now The current time in ms.
-    @param type The type of event to be considered.
-  */
-  float Orxonox::calculateEventTime(unsigned long now, std::deque<unsigned long> &times)
-  {
-    // Calculate the average time passed between events of the given type
-    // during the last frameSmoothingTime_ seconds.
-
-    times.push_back(now);
-
-    if(times.size() == 1)
-      return 0;
-
-    // Times up to frameSmoothingTime_ seconds old should be kept
-    unsigned long discardThreshold = (unsigned long)(frameSmoothingTime_ * 1000.0f);
-
-    // Find the oldest time to keep
-    std::deque<unsigned long>::iterator it  = times.begin();
-    // We need at least two times
-    std::deque<unsigned long>::iterator end = times.end() - 2;
-
-    while(it != end)
-    {
-      if (now - *it > discardThreshold)
-        ++it;
-      else
-        break;
-    }
-
-    // Remove old times
-    times.erase(times.begin(), it);
-
-    return (float)(times.back() - times.front()) / ((times.size() - 1) * 1000);
-  }
 }
Index: code/branches/hud/src/orxonox/Orxonox.h
===================================================================
--- code/branches/hud/src/orxonox/Orxonox.h	(revision 1620)
+++ code/branches/hud/src/orxonox/Orxonox.h	(revision 1621)
@@ -62,5 +62,4 @@
 
       void abortRequest();
-      //inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
 
       static Orxonox* getSingleton();
@@ -98,6 +97,4 @@
       //audio::AudioManager*  auMan_;         //!< audio manager
       Ogre::Timer*          timer_;         //!< Main loop timer
-      // TODO: make this a config-value by creating a config class for orxonox
-      float                 frameSmoothingTime_;
       bool                  bAbort_;        //!< aborts the render loop if true
       float                 timefactor_;    //!< A factor to change the gamespeed
Index: code/branches/hud/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/hud/src/orxonox/OrxonoxPrereqs.h	(revision 1620)
+++ code/branches/hud/src/orxonox/OrxonoxPrereqs.h	(revision 1621)
@@ -62,70 +62,60 @@
 namespace orxonox
 {
-  namespace LODParticle
-  {
-    enum LOD
+    namespace LODParticle
     {
-      off = 0,
-      low = 1,
-      normal = 2,
-      high = 3
-    };
-  }
+        enum LOD
+        {
+            off = 0,
+            low = 1,
+            normal = 2,
+            high = 3
+        };
+    }
 
-  class GraphicsEngine;
-  class Orxonox;
+    class GraphicsEngine;
+    class Orxonox;
 
-  class RadarViewable;
-  class Radar;
-  class RadarListener;
+    class RadarViewable;
+    class Radar;
+    class RadarListener;
 
-  // objects
-  class Ambient;
-  class Backlight;
-  class Camera;
-  class Fighter;
-  class Model;
-  class NPC;
-  class ParticleSpawner;
-  class Skybox;
-  class SpaceShip;
-  class SpaceShipAI;
-  class WorldEntity;
+    // objects
+    class Ambient;
+    class Backlight;
+    class Camera;
+    class Fighter;
+    class Model;
+    class NPC;
+    class ParticleSpawner;
+    class Skybox;
+    class SpaceShip;
+    class SpaceShipAI;
+    class WorldEntity;
 
-  class Projectile;
-  class BillboardProjectile;
-  class RotatingProjectile;
-  class ParticleProjectile;
+    class Projectile;
+    class BillboardProjectile;
+    class RotatingProjectile;
+    class ParticleProjectile;
 
-  class AmmunitionDump;
-  class Bullet;
-  class BulletManager;
-  class BaseWeapon;
-  class BarrelGun;
-  class WeaponStation;
+    // tools
+    class BillboardSet;
+    class Light;
+    class Mesh;
+    class ParticleInterface;
+    template <class T>
+    class Timer;
 
-  // tools
-  class BillboardSet;
-  class Light;
-  class Mesh;
-  template <class T>
-  class Timer;
-  class TimerBase;
-
-  // particle
-  class ParticleInterface;
-
-  // hud
-  class BarOverlayElement;
-  class BarOverlayElementFactory;
-  class OverlayGroup;
-  class OrxonoxOverlay;
-  class HUDNavigation;
-  class RadarObject;
-  class RadarOverlayElement;
-  class RadarOverlayElementFactory;
-
-  //console
-  class InGameConsole;
+    // overlays
+    class BarColour;
+    class DebugFPSText;
+    class DebugRTRText;
+    class HUDBar;
+    class HUDNavigation;
+    class HUDRadar;
+    class HUDSpeedBar;
+    class InGameConsole;
+    class OrxonoxOverlay;
+    class OverlayGroup;
+    class OverlayText;
 }
 
@@ -138,4 +128,3 @@
 }
 
-
 #endif /* _OrxonoxPrereqs_H__ */
Index: code/branches/hud/src/orxonox/overlays/debug/DebugFPSText.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 1620)
+++ code/branches/hud/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 1621)
@@ -49,5 +49,5 @@
     void DebugFPSText::tick(float dt)
     {
-        float fps = GraphicsEngine::getSingleton().getAverageFPS();
+        float fps = GraphicsEngine::getSingleton().getAverageFramesPerSecond();
         this->text_->setCaption(this->getCaption() + convertToString(fps));
     }
Index: code/branches/hud/src/orxonox/overlays/debug/DebugRTRText.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 1620)
+++ code/branches/hud/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 1621)
@@ -49,5 +49,5 @@
     void DebugRTRText::tick(float dt)
     {
-        float rtr = GraphicsEngine::getSingleton().getAverageRTR();
+        float rtr = GraphicsEngine::getSingleton().getAverageTickTime();
         this->text_->setCaption(this->getCaption() + convertToString(rtr));
     }
Index: code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.cc	(revision 1620)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.cc	(revision 1621)
@@ -101,7 +101,7 @@
 
         XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode);
-        XMLPortParam(HUDNavigation, "textsize", setTextSize, getTextSize, xmlElement, mode);
-        XMLPortParam(HUDNavigation, "navmarkersize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
-        XMLPortParam(HUDNavigation, "aimmarkersize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
+        XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode);
+        XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
+        XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
 
         if (mode == XMLPort::LoadObject)
Index: code/branches/hud/visual_studio/vc8/audio.vcproj
===================================================================
--- code/branches/hud/visual_studio/vc8/audio.vcproj	(revision 1620)
+++ code/branches/hud/visual_studio/vc8/audio.vcproj	(revision 1621)
@@ -82,5 +82,5 @@
 			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\audio_properties.vsprops"
 			CharacterSet="1"
-			WholeProgramOptimization="1"
+			WholeProgramOptimization="0"
 			>
 			<Tool
Index: code/branches/hud/visual_studio/vc8/ois.vcproj
===================================================================
--- code/branches/hud/visual_studio/vc8/ois.vcproj	(revision 1620)
+++ code/branches/hud/visual_studio/vc8/ois.vcproj	(revision 1621)
@@ -24,5 +24,5 @@
 			InheritedPropertySheets="..\directory_properties.vsprops"
 			CharacterSet="2"
-			WholeProgramOptimization="1"
+			WholeProgramOptimization="0"
 			>
 			<Tool
Index: code/branches/hud/visual_studio/vc8/util.vcproj
===================================================================
--- code/branches/hud/visual_studio/vc8/util.vcproj	(revision 1620)
+++ code/branches/hud/visual_studio/vc8/util.vcproj	(revision 1621)
@@ -82,5 +82,5 @@
 			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\util_properties.vsprops"
 			CharacterSet="1"
-			WholeProgramOptimization="1"
+			WholeProgramOptimization="0"
 			>
 			<Tool
