Merge pull request #7148 from hyperlogic/tony/smooth-vive-controllers

Vive: smoother updates for IK driven by vive controllers
This commit is contained in:
Brad Hefta-Gaub 2016-02-20 09:37:37 -08:00
commit 28638f19e3
2 changed files with 9 additions and 3 deletions

View file

@ -210,7 +210,7 @@ static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html";
static const unsigned int THROTTLED_SIM_FRAMERATE = 15;
static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE;
static const unsigned int CAPPED_SIM_FRAMERATE = 60;
static const unsigned int CAPPED_SIM_FRAMERATE = 120;
static const int CAPPED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / CAPPED_SIM_FRAMERATE;
static const uint32_t INVALID_FRAME = UINT32_MAX;
@ -1733,6 +1733,7 @@ bool Application::event(QEvent* event) {
if ((int)event->type() == (int)Paint) {
paintGL();
return true;
}
if (!_keyboardFocusedItem.isInvalidID()) {

View file

@ -101,9 +101,16 @@ glm::mat4 OpenVrDisplayPlugin::getHeadPose(uint32_t frameIndex) const {
float frameDuration = 1.f / displayFrequency;
float vsyncToPhotons = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float);
#if THREADED_PRESENT
// TODO: this seems awfuly long, 44ms total, but it produced the best results.
const float NUM_PREDICTION_FRAMES = 3.0f;
float predictedSecondsFromNow = NUM_PREDICTION_FRAMES * frameDuration + vsyncToPhotons;
#else
uint64_t frameCounter;
float timeSinceLastVsync;
_system->GetTimeSinceLastVsync(&timeSinceLastVsync, &frameCounter);
float predictedSecondsFromNow = 3.0f * frameDuration - timeSinceLastVsync + vsyncToPhotons;
#endif
vr::TrackedDevicePose_t predictedTrackedDevicePose[vr::k_unMaxTrackedDeviceCount];
_system->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseSeated, predictedSecondsFromNow, predictedTrackedDevicePose, vr::k_unMaxTrackedDeviceCount);
@ -126,8 +133,6 @@ void OpenVrDisplayPlugin::internalPresent() {
_compositor->Submit(vr::Eye_Left, &texture, &leftBounds);
_compositor->Submit(vr::Eye_Right, &texture, &rightBounds);
glFinish();
vr::TrackedDevicePose_t currentTrackedDevicePose[vr::k_unMaxTrackedDeviceCount];
_compositor->WaitGetPoses(currentTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, nullptr, 0);