mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 09:19:58 +00:00
Prediction fix
This commit is contained in:
parent
480ce82217
commit
ee25d7be38
2 changed files with 7 additions and 1 deletions
|
@ -118,6 +118,9 @@ void VRSession::swapBuffers(osg::GraphicsContext* gc, VRViewer& viewer)
|
||||||
|
|
||||||
xr->endFrame(mPostdrawFrame->mPredictedDisplayTime, 1, &layerStack);
|
xr->endFrame(mPostdrawFrame->mPredictedDisplayTime, 1, &layerStack);
|
||||||
mLastRenderedFrame = mPostdrawFrame->mFrameNo;
|
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)
|
void VRSession::advanceFramePhase(void)
|
||||||
|
@ -148,7 +151,7 @@ void VRSession::startFrame()
|
||||||
}
|
}
|
||||||
else if (mFrames > mLastRenderedFrame)
|
else if (mFrames > mLastRenderedFrame)
|
||||||
{
|
{
|
||||||
predictedDisplayTime = frameState.predictedDisplayTime + frameState.predictedDisplayPeriod;
|
predictedDisplayTime = frameState.predictedDisplayTime + mLastFrameInterval.count() * (mFrames - mLastRenderedFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFrames == 0 || predictedDisplayTime == 0)
|
if (mFrames == 0 || predictedDisplayTime == 0)
|
||||||
|
|
|
@ -73,6 +73,9 @@ public:
|
||||||
long long mFrames{ 0 };
|
long long mFrames{ 0 };
|
||||||
long long mLastRenderedFrame{ 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 };
|
float mPlayerScale{ 1.f };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue