Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6170


Ignore:
Timestamp:
Nov 26, 2009, 11:29:20 PM (14 years ago)
Author:
rgrieder
Message:

Reduced camera lag induced by occasional high delta times.

Location:
code/branches/presentation2/src/orxonox/graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/graphics/Camera.cc

    r6158 r6170  
    6969        this->bDrag_ = false;
    7070        this->nearClipDistance_ = 1;
     71        this->lastDtLagged_ = false;
    7172
    7273        this->setSyncMode(0x0);
     
    111112        if (this->bDrag_)
    112113        {
    113             dt = dt / this->getTimeFactor();
    114114            // this stuff here may need some adjustments
    115             float coeff = std::min(1.0f, 15.0f * dt);
     115            float coeff = 15.0f * dt / this->getTimeFactor();
     116            // Only clamp if fps rate is actually falling. Occasional high dts should
     117            // not be clamped to reducing lagging effects.
     118            if (coeff > 1.0f)
     119            {
     120                if (this->lastDtLagged_)
     121                    coeff = 1.0f;
     122                else
     123                    this->lastDtLagged_ = true;
     124            }
     125            else
     126                this->lastDtLagged_ = false;
    116127
    117128            Vector3 offset = this->getWorldPosition() - this->cameraNode_->_getDerivedPosition();
     
    119130
    120131            this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true));
    121             //this->cameraNode_->setOrientation(this->getWorldOrientation());
    122132        }
    123133    }
  • code/branches/presentation2/src/orxonox/graphics/Camera.h

    r6158 r6170  
    7373            bool             bHasFocus_;
    7474            bool             bDrag_;
     75            bool             lastDtLagged_;
    7576    };
    7677}
Note: See TracChangeset for help on using the changeset viewer.