From 6d5f64529959a3e0596244d4f9b2beaeefc3fb05 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 8 Sep 2014 15:57:20 -0700 Subject: [PATCH 01/13] Limit avatar head and body models in preferences to FST files (or blank) --- interface/src/ui/PreferencesDialog.cpp | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 47cb9bad88..0da68a2cfe 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -165,19 +165,29 @@ void PreferencesDialog::savePreferences() { } QUrl faceModelURL(ui.faceURLEdit->text()); - if (faceModelURL.toString() != _faceURLString) { - // change the faceModelURL in the profile, it will also update this user's BlendFace - myAvatar->setFaceModelURL(faceModelURL); - UserActivityLogger::getInstance().changedModel("head", faceModelURL.toString()); - shouldDispatchIdentityPacket = true; + QString faceModelURLString = faceModelURL.toString(); + if (faceModelURLString != _faceURLString) { + if (faceModelURLString.isEmpty() || faceModelURLString.toLower().endsWith(".fst")) { + // change the faceModelURL in the profile, it will also update this user's BlendFace + myAvatar->setFaceModelURL(faceModelURL); + UserActivityLogger::getInstance().changedModel("head", faceModelURLString); + shouldDispatchIdentityPacket = true; + } else { + qDebug() << "ERROR: Head model not FST or blank - " << faceModelURLString; + } } QUrl skeletonModelURL(ui.skeletonURLEdit->text()); - if (skeletonModelURL.toString() != _skeletonURLString) { - // change the skeletonModelURL in the profile, it will also update this user's Body - myAvatar->setSkeletonModelURL(skeletonModelURL); - UserActivityLogger::getInstance().changedModel("skeleton", skeletonModelURL.toString()); - shouldDispatchIdentityPacket = true; + QString skeletonModelURLString = skeletonModelURL.toString(); + if (skeletonModelURLString != _skeletonURLString) { + if (skeletonModelURLString.isEmpty() || skeletonModelURLString.toLower().endsWith(".fst")) { + // change the skeletonModelURL in the profile, it will also update this user's Body + myAvatar->setSkeletonModelURL(skeletonModelURL); + UserActivityLogger::getInstance().changedModel("skeleton", skeletonModelURLString); + shouldDispatchIdentityPacket = true; + } else { + qDebug() << "ERROR: Skeleton model not FST or blank - " << skeletonModelURLString; + } } if (shouldDispatchIdentityPacket) { From 2fde67be724babf83f085b0e444e0e4f744825e0 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 12:40:03 -0700 Subject: [PATCH 02/13] Fix for deferred lighting with 3DTV (/Oculus, although I haven't tested that yet). --- interface/src/MetavoxelSystem.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index 892efe7211..b84b6f97d4 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -181,6 +181,15 @@ void MetavoxelSystem::render() { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID()); + // get the viewport side (left, right, both) + int viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + const int VIEWPORT_X_INDEX = 0; + const int VIEWPORT_WIDTH_INDEX = 2; + QSize widgetSize = Application::getInstance()->getGLWidget()->getDeviceSize(); + float sMin = viewport[VIEWPORT_X_INDEX] / (float)widgetSize.width(); + float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)widgetSize.width(); + if (Menu::getInstance()->getShadowsEnabled()) { glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID()); @@ -210,10 +219,13 @@ void MetavoxelSystem::render() { program->setUniformValue(locations->nearLocation, nearVal); program->setUniformValue(locations->depthScale, (farVal - nearVal) / farVal); float nearScale = -1.0f / nearVal; - program->setUniformValue(locations->depthTexCoordOffset, left * nearScale, bottom * nearScale); - program->setUniformValue(locations->depthTexCoordScale, (right - left) * nearScale, (top - bottom) * nearScale); + float sScale = 1.0f / sWidth; + float depthTexCoordScaleS = (right - left) * nearScale * sScale; + program->setUniformValue(locations->depthTexCoordOffset, left * nearScale - sMin * depthTexCoordScaleS, + bottom * nearScale); + program->setUniformValue(locations->depthTexCoordScale, depthTexCoordScaleS, (top - bottom) * nearScale); - renderFullscreenQuad(); + renderFullscreenQuad(sMin, sMin + sWidth); program->release(); @@ -226,7 +238,7 @@ void MetavoxelSystem::render() { } else { _directionalLight.bind(); - renderFullscreenQuad(); + renderFullscreenQuad(sMin, sMin + sWidth); _directionalLight.release(); } @@ -245,7 +257,7 @@ void MetavoxelSystem::render() { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - renderFullscreenQuad(); + renderFullscreenQuad(sMin, sMin + sWidth); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); From c5ad603321e5fda4e09d2bdd7c8be9c66216a80b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 12:47:46 -0700 Subject: [PATCH 03/13] Fix for glow disabled in 3D TV mode. --- interface/src/devices/TV3DManager.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/interface/src/devices/TV3DManager.cpp b/interface/src/devices/TV3DManager.cpp index 2ce78b7ac1..005f7133f0 100644 --- a/interface/src/devices/TV3DManager.cpp +++ b/interface/src/devices/TV3DManager.cpp @@ -93,8 +93,6 @@ void TV3DManager::display(Camera& whichCamera) { int portalW = Application::getInstance()->getGLWidget()->getDeviceWidth() / 2; int portalH = Application::getInstance()->getGLWidget()->getDeviceHeight(); - const bool glowEnabled = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect); - ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay(); // We only need to render the overlays to a texture once, then we just render the texture as a quad @@ -102,9 +100,7 @@ void TV3DManager::display(Camera& whichCamera) { applicationOverlay.renderOverlay(true); const bool displayOverlays = Menu::getInstance()->isOptionChecked(MenuOption::UserInterface); - if (glowEnabled) { - Application::getInstance()->getGlowEffect()->prepare(); - } + Application::getInstance()->getGlowEffect()->prepare(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -168,7 +164,5 @@ void TV3DManager::display(Camera& whichCamera) { glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(), Application::getInstance()->getGLWidget()->getDeviceHeight()); - if (glowEnabled) { - Application::getInstance()->getGlowEffect()->render(); - } + Application::getInstance()->getGlowEffect()->render(); } From 2cba7b37bf0688ffa391c8554bcb33615cb21698 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 13:51:14 -0700 Subject: [PATCH 04/13] Attempting to fix 3DTV/Oculus deferred lighting/ambient occlusion. --- interface/src/Application.cpp | 7 +++++++ interface/src/devices/OculusManager.cpp | 17 +++++++++++++++++ interface/src/devices/OculusManager.h | 4 ++++ interface/src/devices/TV3DManager.cpp | 16 +++++++++++++++- interface/src/devices/TV3DManager.h | 5 +++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7c7c455d1d..f781c9765d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2971,7 +2971,14 @@ void Application::getProjectionMatrix(glm::dmat4* projectionMatrix) { void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { + // allow 3DTV/Oculus to override parameters from camera _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); + if (OculusManager::isConnected()) { + OculusManager::overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); + + } else if (TV3DManager::isConnected()) { + TV3DManager::overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); + } } glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index bc6dc842ce..e46f2f3182 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -53,6 +53,7 @@ unsigned int OculusManager::_frameIndex = 0; bool OculusManager::_frameTimingActive = false; bool OculusManager::_programInitialized = false; Camera* OculusManager::_camera = NULL; +int OculusManager::_activeEyeIndex = -1; #endif @@ -330,6 +331,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p //Render each eye into an fbo for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++) { + _activeEyeIndex = eyeIndex; + #if defined(__APPLE__) || defined(_WIN32) ovrEyeType eye = _ovrHmd->EyeRenderOrder[eyeIndex]; #else @@ -363,6 +366,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p Application::getInstance()->displaySide(*_camera); applicationOverlay.displayOverlayTextureOculus(*_camera); + _activeEyeIndex = -1; } //Wait till time-warp to reduce latency @@ -528,3 +532,16 @@ QSize OculusManager::getRenderTargetSize() { return QSize(100, 100); #endif } + +void OculusManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, + float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) { +#ifdef HAVE_LIBOVR + if (_activeEyeIndex != -1) { + float extent = nearVal * glm::tan(_eyeRenderDesc[_activeEyeIndex].Fov / 2.0f); + right = extent; + left = -extent; + top = extent; + bottom = -extent; + } +#endif +} diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index 3959ea1ab7..d8e55647b4 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -43,6 +43,9 @@ public: static glm::vec3 getRelativePosition(); static QSize getRenderTargetSize(); + static void overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, + float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane); + private: #ifdef HAVE_LIBOVR static void generateDistortionMesh(); @@ -92,6 +95,7 @@ private: static bool _frameTimingActive; static bool _programInitialized; static Camera* _camera; + static int _activeEyeIndex; #endif }; diff --git a/interface/src/devices/TV3DManager.cpp b/interface/src/devices/TV3DManager.cpp index 005f7133f0..e8644c00d0 100644 --- a/interface/src/devices/TV3DManager.cpp +++ b/interface/src/devices/TV3DManager.cpp @@ -25,6 +25,7 @@ int TV3DManager::_screenHeight = 1; double TV3DManager::_aspect = 1.0; eyeFrustum TV3DManager::_leftEye; eyeFrustum TV3DManager::_rightEye; +eyeFrustum* TV3DManager::_activeEye = NULL; bool TV3DManager::isConnected() { @@ -111,7 +112,7 @@ void TV3DManager::display(Camera& whichCamera) { glPushMatrix(); { - + _activeEye = &_leftEye; glMatrixMode(GL_PROJECTION); glLoadIdentity(); // reset projection matrix glFrustum(_leftEye.left, _leftEye.right, _leftEye.bottom, _leftEye.top, nearZ, farZ); // set left view frustum @@ -128,6 +129,7 @@ void TV3DManager::display(Camera& whichCamera) { if (displayOverlays) { applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov); } + _activeEye = NULL; } glPopMatrix(); glDisable(GL_SCISSOR_TEST); @@ -140,6 +142,7 @@ void TV3DManager::display(Camera& whichCamera) { glScissor(portalX, portalY, portalW, portalH); glPushMatrix(); { + _activeEye = &_rightEye; glMatrixMode(GL_PROJECTION); glLoadIdentity(); // reset projection matrix glFrustum(_rightEye.left, _rightEye.right, _rightEye.bottom, _rightEye.top, nearZ, farZ); // set left view frustum @@ -156,6 +159,7 @@ void TV3DManager::display(Camera& whichCamera) { if (displayOverlays) { applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov); } + _activeEye = NULL; } glPopMatrix(); glDisable(GL_SCISSOR_TEST); @@ -166,3 +170,13 @@ void TV3DManager::display(Camera& whichCamera) { Application::getInstance()->getGlowEffect()->render(); } + +void TV3DManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, + float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) { + if (_activeEye) { + left = _activeEye->left; + right = _activeEye->right; + bottom = _activeEye->bottom; + top = _activeEye->top; + } +} diff --git a/interface/src/devices/TV3DManager.h b/interface/src/devices/TV3DManager.h index 91a78e9bce..2b2b9e0aa1 100644 --- a/interface/src/devices/TV3DManager.h +++ b/interface/src/devices/TV3DManager.h @@ -14,6 +14,8 @@ #include +#include + class Camera; struct eyeFrustum { @@ -32,6 +34,8 @@ public: static bool isConnected(); static void configureCamera(Camera& camera, int screenWidth, int screenHeight); static void display(Camera& whichCamera); + static void overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, + float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane); private: static void setFrustum(Camera& whichCamera); static int _screenWidth; @@ -39,6 +43,7 @@ private: static double _aspect; static eyeFrustum _leftEye; static eyeFrustum _rightEye; + static eyeFrustum* _activeEye; }; #endif // hifi_TV3DManager_h From 600f36aa64769ccf40d7912a3b450878430d925d Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 14:14:02 -0700 Subject: [PATCH 05/13] Fix for Oculus API. --- interface/src/devices/OculusManager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index e46f2f3182..5e4daa3d22 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -537,11 +537,11 @@ void OculusManager::overrideOffAxisFrustum(float& left, float& right, float& bot float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) { #ifdef HAVE_LIBOVR if (_activeEyeIndex != -1) { - float extent = nearVal * glm::tan(_eyeRenderDesc[_activeEyeIndex].Fov / 2.0f); - right = extent; - left = -extent; - top = extent; - bottom = -extent; + const ovrFovPort& port = _eyeFov[_activeEyeIndex]; + right = nearVal * port.RightTan; + left = -nearVal * port.LeftTan; + top = nearVal * port.TopTan; + bottom = -nearVal * port.BottomTan; } #endif } From b328304da40de24b3990b6e24338d77018e1ff2b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 14:15:00 -0700 Subject: [PATCH 06/13] Up/down, not top/bottom. --- interface/src/devices/OculusManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 5e4daa3d22..c47ff2c38b 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -540,8 +540,8 @@ void OculusManager::overrideOffAxisFrustum(float& left, float& right, float& bot const ovrFovPort& port = _eyeFov[_activeEyeIndex]; right = nearVal * port.RightTan; left = -nearVal * port.LeftTan; - top = nearVal * port.TopTan; - bottom = -nearVal * port.BottomTan; + top = nearVal * port.UpTan; + bottom = -nearVal * port.DownTan; } #endif } From 34ccc2ab7bb1d3c3f3c1187388368344f08470af Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 15:13:07 -0700 Subject: [PATCH 07/13] Use the FBO dimensions, which may differ from the widget dimensions (as with the Oculus). --- interface/src/MetavoxelSystem.cpp | 5 ++--- interface/src/renderer/AmbientOcclusionEffect.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index b84b6f97d4..2d27398f4b 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -186,9 +186,8 @@ void MetavoxelSystem::render() { glGetIntegerv(GL_VIEWPORT, viewport); const int VIEWPORT_X_INDEX = 0; const int VIEWPORT_WIDTH_INDEX = 2; - QSize widgetSize = Application::getInstance()->getGLWidget()->getDeviceSize(); - float sMin = viewport[VIEWPORT_X_INDEX] / (float)widgetSize.width(); - float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)widgetSize.width(); + float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width(); + float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width(); if (Menu::getInstance()->getShadowsEnabled()) { glActiveTexture(GL_TEXTURE2); diff --git a/interface/src/renderer/AmbientOcclusionEffect.cpp b/interface/src/renderer/AmbientOcclusionEffect.cpp index a4977e5e01..f1c1538800 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.cpp +++ b/interface/src/renderer/AmbientOcclusionEffect.cpp @@ -116,9 +116,9 @@ void AmbientOcclusionEffect::render() { glGetIntegerv(GL_VIEWPORT, viewport); const int VIEWPORT_X_INDEX = 0; const int VIEWPORT_WIDTH_INDEX = 2; - QSize widgetSize = Application::getInstance()->getGLWidget()->getDeviceSize(); - float sMin = viewport[VIEWPORT_X_INDEX] / (float)widgetSize.width(); - float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)widgetSize.width(); + QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject(); + float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width(); + float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width(); _occlusionProgram->bind(); _occlusionProgram->setUniformValue(_nearLocation, nearVal); @@ -126,7 +126,7 @@ void AmbientOcclusionEffect::render() { _occlusionProgram->setUniformValue(_leftBottomLocation, left, bottom); _occlusionProgram->setUniformValue(_rightTopLocation, right, top); _occlusionProgram->setUniformValue(_noiseScaleLocation, viewport[VIEWPORT_WIDTH_INDEX] / (float)ROTATION_WIDTH, - widgetSize.height() / (float)ROTATION_HEIGHT); + primaryFBO->height() / (float)ROTATION_HEIGHT); _occlusionProgram->setUniformValue(_texCoordOffsetLocation, sMin, 0.0f); _occlusionProgram->setUniformValue(_texCoordScaleLocation, sWidth, 1.0f); @@ -148,7 +148,7 @@ void AmbientOcclusionEffect::render() { glBindTexture(GL_TEXTURE_2D, freeFBO->texture()); _blurProgram->bind(); - _blurProgram->setUniformValue(_blurScaleLocation, 1.0f / widgetSize.width(), 1.0f / widgetSize.height()); + _blurProgram->setUniformValue(_blurScaleLocation, 1.0f / primaryFBO->width(), 1.0f / primaryFBO->height()); renderFullscreenQuad(sMin, sMin + sWidth); From fe249ef3486cf781a357d12d593952918893d3da Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 15:51:10 -0700 Subject: [PATCH 08/13] Make sure the frustum that we use for culling contains the current camera information. --- interface/src/Application.cpp | 3 +++ interface/src/Application.h | 2 ++ interface/src/MetavoxelSystem.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b5826fbcda..273b66e4dc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2724,6 +2724,9 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); // transform by eye offset + // load the view frustum + loadViewFrustum(whichCamera, _displayViewFrustum); + // flip x if in mirror mode (also requires reversing winding order for backface culling) if (whichCamera.getMode() == CAMERA_MODE_MIRROR) { glScalef(-1.0f, 1.0f, 1.0f); diff --git a/interface/src/Application.h b/interface/src/Application.h index f48d88d7a4..fbcc67cf80 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -192,6 +192,7 @@ public: const AudioReflector* getAudioReflector() const { return &_audioReflector; } Camera* getCamera() { return &_myCamera; } ViewFrustum* getViewFrustum() { return &_viewFrustum; } + ViewFrustum* getDisplayViewFrustum() { return &_displayViewFrustum; } ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; } VoxelImporter* getVoxelImporter() { return &_voxelImporter; } VoxelSystem* getVoxels() { return &_voxels; } @@ -486,6 +487,7 @@ private: ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc. ViewFrustum _lastQueriedViewFrustum; /// last view frustum used to query octree servers (voxels, particles) + ViewFrustum _displayViewFrustum; ViewFrustum _shadowViewFrustum; quint64 _lastQueriedTime; diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index 2d27398f4b..903e443cda 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -133,7 +133,7 @@ const GLenum COLOR_NORMAL_DRAW_BUFFERS[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTA void MetavoxelSystem::render() { // update the frustum - ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum(); + ViewFrustum* viewFrustum = Application::getInstance()->getDisplayViewFrustum(); _frustum.set(viewFrustum->getFarTopLeft(), viewFrustum->getFarTopRight(), viewFrustum->getFarBottomLeft(), viewFrustum->getFarBottomRight(), viewFrustum->getNearTopLeft(), viewFrustum->getNearTopRight(), viewFrustum->getNearBottomLeft(), viewFrustum->getNearBottomRight()); @@ -2187,7 +2187,7 @@ private: SpannerRenderVisitor::SpannerRenderVisitor(const MetavoxelLOD& lod) : SpannerVisitor(QVector() << AttributeRegistry::getInstance()->getSpannersAttribute(), QVector(), QVector(), QVector(), - lod, encodeOrder(Application::getInstance()->getViewFrustum()->getDirection())), + lod, encodeOrder(Application::getInstance()->getDisplayViewFrustum()->getDirection())), _containmentDepth(INT_MAX) { } @@ -2223,7 +2223,7 @@ private: BufferRenderVisitor::BufferRenderVisitor(const AttributePointer& attribute) : MetavoxelVisitor(QVector() << attribute), - _order(encodeOrder(Application::getInstance()->getViewFrustum()->getDirection())), + _order(encodeOrder(Application::getInstance()->getDisplayViewFrustum()->getDirection())), _containmentDepth(INT_MAX) { } @@ -2257,12 +2257,12 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox float viewportWidth = viewport[VIEWPORT_WIDTH_INDEX]; float viewportHeight = viewport[VIEWPORT_HEIGHT_INDEX]; float viewportDiagonal = sqrtf(viewportWidth * viewportWidth + viewportHeight * viewportHeight); - float worldDiagonal = glm::distance(Application::getInstance()->getViewFrustum()->getNearBottomLeft(), - Application::getInstance()->getViewFrustum()->getNearTopRight()); + float worldDiagonal = glm::distance(Application::getInstance()->getDisplayViewFrustum()->getNearBottomLeft(), + Application::getInstance()->getDisplayViewFrustum()->getNearTopRight()); _pointProgram.bind(); _pointProgram.setUniformValue(_pointScaleLocation, viewportDiagonal * - Application::getInstance()->getViewFrustum()->getNearClip() / worldDiagonal); + Application::getInstance()->getDisplayViewFrustum()->getNearClip() / worldDiagonal); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); From 590c8042f82eb28bc80c7c44b8599ef0eeb04fdf Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 16:36:32 -0700 Subject: [PATCH 09/13] Attempting to fix a bug in the Oculus overlay. --- interface/src/ui/ApplicationOverlay.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 20ed1d9d58..b7c7c15e13 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -803,24 +803,27 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { float newVTop = 1.0 - (mouseY - reticleSize) / widgetHeight; // Project our position onto the hemisphere using the UV coordinates - float lX = sin((newULeft - 0.5f) * _textureFov); - float rX = sin((newURight - 0.5f) * _textureFov); - float bY = sin((newVBottom - 0.5f) * _textureFov); - float tY = sin((newVTop - 0.5f) * _textureFov); + float radius = _oculusuiRadius * application->getAvatar()->getScale(); + float radius2 = radius * radius; + + float lX = radius * sin((newULeft - 0.5f) * _textureFov); + float rX = radius * sin((newURight - 0.5f) * _textureFov); + float bY = radius * sin((newVBottom - 0.5f) * _textureFov); + float tY = radius * sin((newVTop - 0.5f) * _textureFov); float dist; //Bottom Left dist = sqrt(lX * lX + bY * bY); - float blZ = sqrt(1.0f - dist * dist); + float blZ = sqrt(radius2 - dist * dist); //Top Left dist = sqrt(lX * lX + tY * tY); - float tlZ = sqrt(1.0f - dist * dist); + float tlZ = sqrt(radius2 - dist * dist); //Bottom Right dist = sqrt(rX * rX + bY * bY); - float brZ = sqrt(1.0f - dist * dist); + float brZ = sqrt(radius2 - dist * dist); //Top Right dist = sqrt(rX * rX + tY * tY); - float trZ = sqrt(1.0f - dist * dist); + float trZ = sqrt(radius2 - dist * dist); glBegin(GL_QUADS); From 146a6526bee8f9b40811aac047204f3f8b779b83 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 17:02:04 -0700 Subject: [PATCH 10/13] Fix for Oculus mouse pointer. --- interface/src/ui/ApplicationOverlay.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index b7c7c15e13..df7c2d2289 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -414,7 +414,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { renderTexturedHemisphere(); - renderPointersOculus(whichCamera.getPosition()); + renderPointersOculus(myAvatar->getHead()->getEyePosition()); glDepthMask(GL_TRUE); glBindTexture(GL_TEXTURE_2D, 0); @@ -803,27 +803,24 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { float newVTop = 1.0 - (mouseY - reticleSize) / widgetHeight; // Project our position onto the hemisphere using the UV coordinates - float radius = _oculusuiRadius * application->getAvatar()->getScale(); - float radius2 = radius * radius; - - float lX = radius * sin((newULeft - 0.5f) * _textureFov); - float rX = radius * sin((newURight - 0.5f) * _textureFov); - float bY = radius * sin((newVBottom - 0.5f) * _textureFov); - float tY = radius * sin((newVTop - 0.5f) * _textureFov); + float lX = sin((newULeft - 0.5f) * _textureFov); + float rX = sin((newURight - 0.5f) * _textureFov); + float bY = sin((newVBottom - 0.5f) * _textureFov); + float tY = sin((newVTop - 0.5f) * _textureFov); float dist; //Bottom Left dist = sqrt(lX * lX + bY * bY); - float blZ = sqrt(radius2 - dist * dist); + float blZ = sqrt(1.0f - dist * dist); //Top Left dist = sqrt(lX * lX + tY * tY); - float tlZ = sqrt(radius2 - dist * dist); + float tlZ = sqrt(1.0f - dist * dist); //Bottom Right dist = sqrt(rX * rX + bY * bY); - float brZ = sqrt(radius2 - dist * dist); + float brZ = sqrt(1.0f - dist * dist); //Top Right dist = sqrt(rX * rX + tY * tY); - float trZ = sqrt(radius2 - dist * dist); + float trZ = sqrt(1.0f - dist * dist); glBegin(GL_QUADS); From de8dd4cecc94b541ca9c381b14fd4e1973d364ba Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 18:55:36 -0700 Subject: [PATCH 11/13] Share instances of TextRenderer. --- interface/src/Util.cpp | 7 ++-- interface/src/avatar/Avatar.cpp | 5 ++- interface/src/ui/BandwidthMeter.cpp | 14 +++---- interface/src/ui/BandwidthMeter.h | 2 +- interface/src/ui/TextRenderer.cpp | 49 ++++++++++++++++------- interface/src/ui/TextRenderer.h | 21 +++++++--- interface/src/ui/overlays/TextOverlay.cpp | 9 ++--- 7 files changed, 70 insertions(+), 37 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 4dbb015459..b219509ccd 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -181,9 +181,10 @@ const glm::vec3 randVector() { } static TextRenderer* textRenderer(int mono) { - static TextRenderer* monoRenderer = new TextRenderer(MONO_FONT_FAMILY); - static TextRenderer* proportionalRenderer = new TextRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT); - static TextRenderer* inconsolataRenderer = new TextRenderer(INCONSOLATA_FONT_FAMILY, -1, QFont::Bold, false); + static TextRenderer* monoRenderer = TextRenderer::getInstance(MONO_FONT_FAMILY); + static TextRenderer* proportionalRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, + -1, -1, false, TextRenderer::SHADOW_EFFECT); + static TextRenderer* inconsolataRenderer = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, -1, QFont::Bold, false); switch (mono) { case 1: return monoRenderer; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 5c7e89fc37..ba044c9451 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -239,8 +239,9 @@ enum TextRendererType { }; static TextRenderer* textRenderer(TextRendererType type) { - static TextRenderer* chatRenderer = new TextRenderer(SANS_FONT_FAMILY, 24, -1, false, TextRenderer::SHADOW_EFFECT); - static TextRenderer* displayNameRenderer = new TextRenderer(SANS_FONT_FAMILY, 12, -1, false, TextRenderer::NO_EFFECT); + static TextRenderer* chatRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, 24, -1, + false, TextRenderer::SHADOW_EFFECT); + static TextRenderer* displayNameRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, 12); switch(type) { case CHAT: diff --git a/interface/src/ui/BandwidthMeter.cpp b/interface/src/ui/BandwidthMeter.cpp index 0f41a1a5cf..327f266106 100644 --- a/interface/src/ui/BandwidthMeter.cpp +++ b/interface/src/ui/BandwidthMeter.cpp @@ -50,7 +50,7 @@ BandwidthMeter::ChannelInfo BandwidthMeter::_CHANNELS[] = { }; BandwidthMeter::BandwidthMeter() : - _textRenderer(INCONSOLATA_FONT_FAMILY, -1, QFont::Bold, false), + _textRenderer(TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, -1, QFont::Bold, false)), _scaleMaxIndex(INITIAL_SCALE_MAXIMUM_INDEX) { _channels = static_cast( malloc(sizeof(_CHANNELS)) ); @@ -140,7 +140,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { float totalMax = glm::max(totalIn, totalOut); // Get font / caption metrics - QFontMetrics const& fontMetrics = _textRenderer.metrics(); + QFontMetrics const& fontMetrics = _textRenderer->metrics(); int fontDescent = fontMetrics.descent(); int labelWidthIn = fontMetrics.width(CAPTION_IN); int labelWidthOut = fontMetrics.width(CAPTION_OUT); @@ -163,9 +163,9 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { // Render captions setColorRGBA(COLOR_TEXT); - _textRenderer.draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT); - _textRenderer.draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN); - _textRenderer.draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT); + _textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT); + _textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN); + _textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT); // Render vertical lines for the frame setColorRGBA(COLOR_FRAME); @@ -229,11 +229,11 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { char fmtBuf[8]; setColorRGBA(COLOR_TEXT); sprintf(fmtBuf, "%0.1f", totalIn); - _textRenderer.draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, + _textRenderer->draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, PADDING_HORIZ_VALUE), textYupperLine, fmtBuf); sprintf(fmtBuf, "%0.1f", totalOut); - _textRenderer.draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, + _textRenderer->draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, PADDING_HORIZ_VALUE), textYlowerLine, fmtBuf); diff --git a/interface/src/ui/BandwidthMeter.h b/interface/src/ui/BandwidthMeter.h index c6a28a21c3..09353512d1 100644 --- a/interface/src/ui/BandwidthMeter.h +++ b/interface/src/ui/BandwidthMeter.h @@ -78,7 +78,7 @@ private: static ChannelInfo _CHANNELS[]; - TextRenderer _textRenderer; + TextRenderer* _textRenderer; ChannelInfo* _channels; Stream _streams[N_STREAMS]; int _scaleMaxIndex; diff --git a/interface/src/ui/TextRenderer.cpp b/interface/src/ui/TextRenderer.cpp index 4ced8c1f2e..c4f6b328ef 100644 --- a/interface/src/ui/TextRenderer.cpp +++ b/interface/src/ui/TextRenderer.cpp @@ -24,22 +24,23 @@ // the width/height of the cached glyph textures const int IMAGE_SIZE = 256; -Glyph::Glyph(int textureID, const QPoint& location, const QRect& bounds, int width) : - _textureID(textureID), _location(location), _bounds(bounds), _width(width) { +static uint qHash(const TextRenderer::Properties& key, uint seed = 0) { + // can be switched to qHash(key.font, seed) when we require Qt 5.3+ + return qHash(key.font.family(), qHash(key.font.pointSize(), seed)); } -TextRenderer::TextRenderer(const char* family, int pointSize, int weight, bool italic, - EffectType effectType, int effectThickness, QColor color) : - _font(family, pointSize, weight, italic), - _metrics(_font), - _effectType(effectType), - _effectThickness(effectThickness), - _x(IMAGE_SIZE), - _y(IMAGE_SIZE), - _rowHeight(0), - _color(color) { - - _font.setKerning(false); +static bool operator==(const TextRenderer::Properties& p1, const TextRenderer::Properties& p2) { + return p1.font == p2.font && p1.effect == p2.effect && p1.effectThickness == p2.effectThickness && p1.color == p2.color; +} + +TextRenderer* TextRenderer::getInstance(const char* family, int pointSize, int weight, bool italic, + EffectType effect, int effectThickness, const QColor& color) { + Properties properties = { QFont(family, pointSize, weight, italic), effect, effectThickness, color }; + TextRenderer*& instance = _instances[properties]; + if (!instance) { + instance = new TextRenderer(properties); + } + return instance; } TextRenderer::~TextRenderer() { @@ -122,6 +123,19 @@ int TextRenderer::computeWidth(const char* str) return width; } +TextRenderer::TextRenderer(const Properties& properties) : + _font(properties.font), + _metrics(_font), + _effectType(properties.effect), + _effectThickness(properties.effectThickness), + _x(IMAGE_SIZE), + _y(IMAGE_SIZE), + _rowHeight(0), + _color(properties.color) { + + _font.setKerning(false); +} + const Glyph& TextRenderer::getGlyph(char c) { Glyph& glyph = _glyphs[c]; if (glyph.isValid()) { @@ -213,3 +227,10 @@ const Glyph& TextRenderer::getGlyph(char c) { glBindTexture(GL_TEXTURE_2D, 0); return glyph; } + +QHash TextRenderer::_instances; + +Glyph::Glyph(int textureID, const QPoint& location, const QRect& bounds, int width) : + _textureID(textureID), _location(location), _bounds(bounds), _width(width) { +} + diff --git a/interface/src/ui/TextRenderer.h b/interface/src/ui/TextRenderer.h index 2daba79c8f..d3340462d5 100644 --- a/interface/src/ui/TextRenderer.h +++ b/interface/src/ui/TextRenderer.h @@ -33,7 +33,6 @@ const char SOLID_BLOCK_CHAR = 127; // the Inconsolata font family #define INCONSOLATA_FONT_FAMILY "Inconsolata" - class Glyph; class TextRenderer { @@ -41,9 +40,17 @@ public: enum EffectType { NO_EFFECT, SHADOW_EFFECT, OUTLINE_EFFECT }; - TextRenderer(const char* family, int pointSize = -1, int weight = -1, bool italic = false, - EffectType effect = NO_EFFECT, int effectThickness = 1, - QColor color = QColor(255, 255, 255)); + class Properties { + public: + QFont font; + EffectType effect; + int effectThickness; + QColor color; + }; + + static TextRenderer* getInstance(const char* family, int pointSize = -1, int weight = -1, bool italic = false, + EffectType effect = NO_EFFECT, int effectThickness = 1, const QColor& color = QColor(255, 255, 255)); + ~TextRenderer(); const QFontMetrics& metrics() const { return _metrics; } @@ -59,7 +66,9 @@ public: private: - const Glyph& getGlyph (char c); + TextRenderer(const Properties& properties); + + const Glyph& getGlyph(char c); // the font to render QFont _font; @@ -90,6 +99,8 @@ private: // text color QColor _color; + + static QHash _instances; }; class Glyph { diff --git a/interface/src/ui/overlays/TextOverlay.cpp b/interface/src/ui/overlays/TextOverlay.cpp index 691179ec54..bc7cbb2cfa 100644 --- a/interface/src/ui/overlays/TextOverlay.cpp +++ b/interface/src/ui/overlays/TextOverlay.cpp @@ -45,22 +45,21 @@ void TextOverlay::render() { //TextRenderer(const char* family, int pointSize = -1, int weight = -1, bool italic = false, // EffectType effect = NO_EFFECT, int effectThickness = 1); - TextRenderer textRenderer(SANS_FONT_FAMILY, _fontSize, 50, false, TextRenderer::NO_EFFECT, 1, - QColor(_color.red, _color.green, _color.blue)); + TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, 50); const int leftAdjust = -1; // required to make text render relative to left edge of bounds const int topAdjust = -2; // required to make text render relative to top edge of bounds int x = _bounds.left() + _leftMargin + leftAdjust; int y = _bounds.top() + _topMargin + topAdjust; - glColor3f(1.0f, 1.0f, 1.0f); + glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR); QStringList lines = _text.split("\n"); int lineOffset = 0; foreach(QString thisLine, lines) { if (lineOffset == 0) { - lineOffset = textRenderer.calculateHeight(qPrintable(thisLine)); + lineOffset = textRenderer->calculateHeight(qPrintable(thisLine)); } - lineOffset += textRenderer.draw(x, y + lineOffset, qPrintable(thisLine)); + lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine)); const int lineGap = 2; lineOffset += lineGap; From 7b3d06a78335b6f862443b32c16b3cfa4c834549 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 19:34:21 -0700 Subject: [PATCH 12/13] Add option to change Faceshift hostname. --- interface/src/Menu.cpp | 4 ++ interface/src/Menu.h | 3 ++ interface/src/devices/Faceshift.cpp | 2 +- interface/src/ui/PreferencesDialog.cpp | 5 ++ interface/ui/preferencesDialog.ui | 64 ++++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d7679968ae..ff5e50d66c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -70,6 +70,7 @@ Menu* Menu::getInstance() { const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f}; const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; +const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost"; const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f; const int ONE_SECOND_OF_FRAMES = 60; const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES; @@ -87,6 +88,7 @@ Menu::Menu() : _fieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES), _realWorldFieldOfView(DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), _faceshiftEyeDeflection(DEFAULT_FACESHIFT_EYE_DEFLECTION), + _faceshiftHostname(DEFAULT_FACESHIFT_HOSTNAME), _frustumDrawMode(FRUSTUM_DRAW_MODE_ALL), _viewFrustumOffset(DEFAULT_FRUSTUM_OFFSET), _jsConsole(NULL), @@ -713,6 +715,7 @@ void Menu::loadSettings(QSettings* settings) { _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES); _realWorldFieldOfView = loadSetting(settings, "realWorldFieldOfView", DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES); _faceshiftEyeDeflection = loadSetting(settings, "faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION); + _faceshiftHostname = settings->value("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME).toString(); _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM); _maxVoxelPacketsPerSecond = loadSetting(settings, "maxVoxelsPPS", DEFAULT_MAX_VOXEL_PPS); _voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_OCTREE_SIZE_SCALE); @@ -777,6 +780,7 @@ void Menu::saveSettings(QSettings* settings) { settings->setValue("fieldOfView", _fieldOfView); settings->setValue("faceshiftEyeDeflection", _faceshiftEyeDeflection); + settings->setValue("faceshiftHostname", _faceshiftHostname); settings->setValue("maxVoxels", _maxVoxels); settings->setValue("maxVoxelsPPS", _maxVoxelPacketsPerSecond); settings->setValue("voxelSizeScale", _voxelSizeScale); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 3b263add36..7ed963f473 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -104,6 +104,8 @@ public: float getFaceshiftEyeDeflection() const { return _faceshiftEyeDeflection; } void setFaceshiftEyeDeflection(float faceshiftEyeDeflection) { _faceshiftEyeDeflection = faceshiftEyeDeflection; bumpSettings(); } + const QString& getFaceshiftHostname() const { return _faceshiftHostname; } + void setFaceshiftHostname(const QString& hostname) { _faceshiftHostname = hostname; bumpSettings(); } QString getSnapshotsLocation() const; void setSnapshotsLocation(QString snapshotsLocation) { _snapshotsLocation = snapshotsLocation; bumpSettings(); } @@ -271,6 +273,7 @@ private: float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus float _realWorldFieldOfView; // The actual FOV set by the user's monitor size and view distance float _faceshiftEyeDeflection; + QString _faceshiftHostname; FrustumDrawMode _frustumDrawMode; ViewFrustumOffset _viewFrustumOffset; QPointer _MetavoxelEditor; diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 345e635045..74e36a98d1 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -151,7 +151,7 @@ void Faceshift::connectSocket() { qDebug("Faceshift: Connecting..."); } - _tcpSocket.connectToHost("localhost", FACESHIFT_PORT); + _tcpSocket.connectToHost(Menu::getInstance()->getFaceshiftHostname(), FACESHIFT_PORT); _tracking = false; } } diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 47cb9bad88..a71e75e655 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -121,6 +121,8 @@ void PreferencesDialog::loadPreferences() { ui.faceshiftEyeDeflectionSider->setValue(menuInstance->getFaceshiftEyeDeflection() * ui.faceshiftEyeDeflectionSider->maximum()); + ui.faceshiftHostnameEdit->setText(menuInstance->getFaceshiftHostname()); + const InboundAudioStream::Settings& streamSettings = menuInstance->getReceivedAudioStreamSettings(); ui.dynamicJitterBuffersCheckBox->setChecked(streamSettings._dynamicJitterBuffers); @@ -211,6 +213,9 @@ void PreferencesDialog::savePreferences() { Menu::getInstance()->setFaceshiftEyeDeflection(ui.faceshiftEyeDeflectionSider->value() / (float)ui.faceshiftEyeDeflectionSider->maximum()); + + Menu::getInstance()->setFaceshiftHostname(ui.faceshiftHostnameEdit->text()); + Menu::getInstance()->setMaxVoxelPacketsPerSecond(ui.maxVoxelsPPSSpin->value()); Menu::getInstance()->setOculusUIAngularSize(ui.oculusUIAngularSizeSpin->value()); diff --git a/interface/ui/preferencesDialog.ui b/interface/ui/preferencesDialog.ui index 9b6e381602..0108437c1f 100644 --- a/interface/ui/preferencesDialog.ui +++ b/interface/ui/preferencesDialog.ui @@ -1726,6 +1726,70 @@ + + + + 0 + + + 7 + + + 0 + + + 7 + + + + + + Arial + + + + Faceshift hostname + + + 0 + + + faceshiftHostnameEdit + + + + + + + + Arial + + + + Qt::Horizontal + + + + + + + + Arial + + + + Qt::LeftToRight + + + + + + localhost + + + + + From b1cfafdbe7f8624290dd56a508fc9e3f090aeda8 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Sep 2014 23:09:03 -0700 Subject: [PATCH 13/13] Missed a spot in the TextRenderer conversion. --- interface/src/devices/PrioVR.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index d6c74e4a5d..fad80fda6f 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -207,10 +207,11 @@ void PrioVR::renderCalibrationCountdown() { Application::getInstance()->disconnect(this); return; } - static TextRenderer textRenderer(MONO_FONT_FAMILY, 18, QFont::Bold, false, TextRenderer::OUTLINE_EFFECT, 2); + static TextRenderer* textRenderer = TextRenderer::getInstance(MONO_FONT_FAMILY, 18, QFont::Bold, + false, TextRenderer::OUTLINE_EFFECT, 2); QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "..."; - textRenderer.draw((Application::getInstance()->getGLWidget()->width() - - textRenderer.computeWidth(text.constData())) / 2, Application::getInstance()->getGLWidget()->height() / 2, + textRenderer->draw((Application::getInstance()->getGLWidget()->width() - + textRenderer->computeWidth(text.constData())) / 2, Application::getInstance()->getGLWidget()->height() / 2, text); #endif }