From 5e9425d9ebb940028bc5c80b402fb81b0c89d98b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 19:48:28 -0700 Subject: [PATCH] Fix view frustum preference --- interface/src/Application.cpp | 24 +++++++++++++++--------- interface/src/Application.h | 2 +- interface/src/avatar/MyAvatar.cpp | 3 +-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cb6ce018c5..f6fddc06fd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1316,6 +1316,13 @@ void Application::faceTrackerMuteToggled() { Menu::getInstance()->getActionForOption(MenuOption::CalibrateCamera)->setEnabled(!isMuted); } +void Application::setFieldOfView(float fov) { + if (fov != _fieldOfView.get()) { + _fieldOfView.set(fov); + resizeGL(); + } +} + void Application::aboutApp() { InfoView::show(INFO_HELP_PATH); } @@ -1342,16 +1349,15 @@ void Application::resizeGL() { if (_renderResolution != renderSize) { _renderResolution = renderSize; DependencyManager::get()->setFrameBufferSize(fromGlm(renderSize)); - - // Possible change in aspect ratio - loadViewFrustum(_myCamera, _viewFrustum); - float fov = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES); - // FIXME the aspect ratio for stereo displays is incorrect based on this. - float aspectRatio = displayPlugin->getRecommendedAspectRatio(); - _myCamera.setProjection(glm::perspective(fov, aspectRatio, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); } - - + + // FIXME the aspect ratio for stereo displays is incorrect based on this. + float aspectRatio = displayPlugin->getRecommendedAspectRatio(); + _myCamera.setProjection(glm::perspective(glm::radians(_fieldOfView.get()), aspectRatio, + DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); + // Possible change in aspect ratio + loadViewFrustum(_myCamera, _viewFrustum); + auto offscreenUi = DependencyManager::get(); auto uiSize = displayPlugin->getRecommendedUiSize(); // Bit of a hack since there's no device pixel ratio change event I can find. diff --git a/interface/src/Application.h b/interface/src/Application.h index 68cfc6aeaf..fa736b5ac6 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -159,7 +159,7 @@ public: float getFps() const { return _fps; } float getFieldOfView() { return _fieldOfView.get(); } - void setFieldOfView(float fov) { _fieldOfView.set(fov); } + void setFieldOfView(float fov); NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 60f7857f27..f94362c4e4 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -428,8 +428,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { head->setDeltaYaw(estimatedRotation.y); head->setDeltaRoll(estimatedRotation.z); } else { - float magnifyFieldOfView = qApp->getFieldOfView() / - _realWorldFieldOfView.get(); + float magnifyFieldOfView = qApp->getViewFrustum()->getFieldOfView() / _realWorldFieldOfView.get(); head->setDeltaPitch(estimatedRotation.x * magnifyFieldOfView); head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView); head->setDeltaRoll(estimatedRotation.z);