1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 06:49:55 +00:00

Prediction fix

This commit is contained in:
Mads Buvik Sandvei 2020-05-24 18:20:57 +02:00
parent 480ce82217
commit ee25d7be38
2 changed files with 7 additions and 1 deletions

View file

@ -118,6 +118,9 @@ void VRSession::swapBuffers(osg::GraphicsContext* gc, VRViewer& viewer)
xr->endFrame(mPostdrawFrame->mPredictedDisplayTime, 1, &layerStack);
mLastRenderedFrame = mPostdrawFrame->mFrameNo;
auto now = std::chrono::steady_clock::now();
mLastFrameInterval = std::chrono::duration_cast<std::chrono::nanoseconds>(now - mLastRenderedFrameTimestamp);
mLastRenderedFrameTimestamp = now;
}
void VRSession::advanceFramePhase(void)
@ -148,7 +151,7 @@ void VRSession::startFrame()
}
else if (mFrames > mLastRenderedFrame)
{
predictedDisplayTime = frameState.predictedDisplayTime + frameState.predictedDisplayPeriod;
predictedDisplayTime = frameState.predictedDisplayTime + mLastFrameInterval.count() * (mFrames - mLastRenderedFrame);
}
if (mFrames == 0 || predictedDisplayTime == 0)

View file

@ -73,6 +73,9 @@ public:
long long mFrames{ 0 };
long long mLastRenderedFrame{ 0 };
std::chrono::nanoseconds mLastFrameInterval{};
std::chrono::steady_clock::time_point mLastRenderedFrameTimestamp{std::chrono::steady_clock::now()};
float mPlayerScale{ 1.f };
};