[Orxonox-commit 1452] r6170 - code/branches/presentation2/src/orxonox/graphics

rgrieder at orxonox.net rgrieder at orxonox.net
Thu Nov 26 23:29:20 CET 2009


Author: rgrieder
Date: 2009-11-26 23:29:20 +0100 (Thu, 26 Nov 2009)
New Revision: 6170

Modified:
   code/branches/presentation2/src/orxonox/graphics/Camera.cc
   code/branches/presentation2/src/orxonox/graphics/Camera.h
Log:
Reduced camera lag induced by occasional high delta times.

Modified: code/branches/presentation2/src/orxonox/graphics/Camera.cc
===================================================================
--- code/branches/presentation2/src/orxonox/graphics/Camera.cc	2009-11-26 22:27:37 UTC (rev 6169)
+++ code/branches/presentation2/src/orxonox/graphics/Camera.cc	2009-11-26 22:29:20 UTC (rev 6170)
@@ -68,6 +68,7 @@
         this->bHasFocus_ = false;
         this->bDrag_ = false;
         this->nearClipDistance_ = 1;
+        this->lastDtLagged_ = false;
 
         this->setSyncMode(0x0);
 
@@ -110,15 +111,24 @@
 
         if (this->bDrag_)
         {
-            dt = dt / this->getTimeFactor();
             // this stuff here may need some adjustments
-            float coeff = std::min(1.0f, 15.0f * dt);
+            float coeff = 15.0f * dt / this->getTimeFactor();
+            // Only clamp if fps rate is actually falling. Occasional high dts should
+            // not be clamped to reducing lagging effects.
+            if (coeff > 1.0f)
+            {
+                if (this->lastDtLagged_)
+                    coeff = 1.0f;
+                else
+                    this->lastDtLagged_ = true;
+            }
+            else
+                this->lastDtLagged_ = false;
 
             Vector3 offset = this->getWorldPosition() - this->cameraNode_->_getDerivedPosition();
             this->cameraNode_->translate(coeff * offset);
 
             this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true));
-            //this->cameraNode_->setOrientation(this->getWorldOrientation());
         }
     }
 

Modified: code/branches/presentation2/src/orxonox/graphics/Camera.h
===================================================================
--- code/branches/presentation2/src/orxonox/graphics/Camera.h	2009-11-26 22:27:37 UTC (rev 6169)
+++ code/branches/presentation2/src/orxonox/graphics/Camera.h	2009-11-26 22:29:20 UTC (rev 6170)
@@ -72,6 +72,7 @@
             float            nearClipDistance_;
             bool             bHasFocus_;
             bool             bDrag_;
+            bool             lastDtLagged_;
     };
 }
 




More information about the Orxonox-commit mailing list