From 436bed3a692dd371329dbbc9f6b7ffd3da293ce5 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 24 Oct 2020 16:00:39 +1300 Subject: [PATCH 1/7] Increase HUD overlay radius --- interface/src/ui/OverlayConductor.cpp | 2 ++ .../src/display-plugins/CompositorHelper.cpp | 7 +++---- .../display-plugins/src/display-plugins/CompositorHelper.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 8edd8ee3a5..a359b8d4c9 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -70,6 +70,8 @@ bool OverlayConductor::updateAvatarIsAtRest() { void OverlayConductor::centerUI() { // place the overlay at the current hmd position in sensor space auto camMat = cancelOutRollAndPitch(qApp->getHMDSensorPose()); + // Set its radius. + camMat = glm::scale(camMat, glm::vec3(HUD_RADIUS)); qApp->getApplicationCompositor().setModelTransform(Transform(camMat)); } diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp index 9b6946bbcc..dc841d6308 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp @@ -384,9 +384,9 @@ bool CompositorHelper::calculateRayUICollisionPoint(const glm::vec3& position, c glm::vec3 localPosition = transformPoint(worldToUi, position); glm::vec3 localDirection = glm::normalize(transformVectorFast(worldToUi, direction)); - const float UI_RADIUS = 1.0f; + const float UNIT_RADIUS = 1.0f; float intersectionDistance; - if (raySphereIntersect(localDirection, localPosition, UI_RADIUS, &intersectionDistance)) { + if (raySphereIntersect(localDirection, localPosition, UNIT_RADIUS, &intersectionDistance)) { result = transformPoint(uiToWorld, localPosition + localDirection * intersectionDistance); #ifdef WANT_DEBUG DebugDraw::getInstance().drawRay(position, result, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f)); @@ -407,9 +407,8 @@ bool CompositorHelper::calculateParabolaUICollisionPoint(const glm::vec3& origin glm::vec3 localVelocity = glm::normalize(transformVectorFast(worldToUi, velocity)); glm::vec3 localAcceleration = glm::normalize(transformVectorFast(worldToUi, acceleration)); - const float UI_RADIUS = 1.0f; float intersectionDistance; - if (findParabolaSphereIntersection(localOrigin, localVelocity, localAcceleration, glm::vec3(0.0f), UI_RADIUS, intersectionDistance)) { + if (findParabolaSphereIntersection(localOrigin, localVelocity, localAcceleration, glm::vec3(0.0f), HUD_RADIUS, intersectionDistance)) { result = origin + velocity * intersectionDistance + 0.5f * acceleration * intersectionDistance * intersectionDistance; parabolicDistance = intersectionDistance; return true; diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.h b/libraries/display-plugins/src/display-plugins/CompositorHelper.h index c45119fd63..3149d7fa3f 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.h +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.h @@ -28,6 +28,7 @@ class ReticleInterface; const float DEFAULT_RETICLE_DEPTH = 1.0f; // FIXME - probably should be based on UI radius +const float HUD_RADIUS = 1.5f; const float MAGNIFY_WIDTH = 220.0f; const float MAGNIFY_HEIGHT = 100.0f; From 4d70651c699930454d2a55d0b748f410bb3a7eac Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 24 Oct 2020 16:00:55 +1300 Subject: [PATCH 2/7] Make default reticle depth be HUD overlay radius --- .../display-plugins/src/display-plugins/CompositorHelper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.h b/libraries/display-plugins/src/display-plugins/CompositorHelper.h index 3149d7fa3f..b44d6ffbd9 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.h +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.h @@ -27,8 +27,8 @@ class ReticleInterface; -const float DEFAULT_RETICLE_DEPTH = 1.0f; // FIXME - probably should be based on UI radius const float HUD_RADIUS = 1.5f; +const float DEFAULT_RETICLE_DEPTH = HUD_RADIUS; const float MAGNIFY_WIDTH = 220.0f; const float MAGNIFY_HEIGHT = 100.0f; @@ -155,7 +155,7 @@ private: std::unique_ptr _alphaPropertyAnimation; std::atomic _reticleVisible { true }; - std::atomic _reticleDepth { 1.0f }; + std::atomic _reticleDepth { DEFAULT_RETICLE_DEPTH }; // NOTE: when the compositor is running in HMD mode, it will control the reticle position as a custom // application specific position, when it's in desktop mode, the reticle position will simply move From 01cd4aa22dd8e8e24ed8bfa63b3745e5aa8045ef Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 24 Oct 2020 16:05:17 +1300 Subject: [PATCH 3/7] Reduce horizontal size of HUD overlay from 270 deg to 180 deg --- .../src/display-plugins/CompositorHelper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp index dc841d6308..c645c39eb4 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp @@ -41,10 +41,10 @@ static const float reticleSize = TWO_PI / 100.0f; //EntityItemID CompositorHelper::_noItemId; static QString _tooltipId; -const uvec2 CompositorHelper::VIRTUAL_SCREEN_SIZE = uvec2(3960, 1188); // ~10% more pixel density than old version, 72dx240d FOV -const QRect CompositorHelper::VIRTUAL_SCREEN_RECOMMENDED_OVERLAY_RECT = QRect(956, 0, 2048, 1188); // don't include entire width only center 2048 +const uvec2 CompositorHelper::VIRTUAL_SCREEN_SIZE = uvec2(2640, 1188); +const QRect CompositorHelper::VIRTUAL_SCREEN_RECOMMENDED_OVERLAY_RECT = QRect(296, 0, 2048, 1188); // Center 2048 pixels. const float CompositorHelper::VIRTUAL_UI_ASPECT_RATIO = (float)VIRTUAL_SCREEN_SIZE.x / (float)VIRTUAL_SCREEN_SIZE.y; -const vec2 CompositorHelper::VIRTUAL_UI_TARGET_FOV = vec2(PI * 3.0f / 2.0f, PI * 3.0f / 2.0f / VIRTUAL_UI_ASPECT_RATIO); +const vec2 CompositorHelper::VIRTUAL_UI_TARGET_FOV = vec2(PI, PI / VIRTUAL_UI_ASPECT_RATIO); const vec2 CompositorHelper::MOUSE_EXTENTS_ANGULAR_SIZE = vec2(PI * 2.0f, PI * 0.95f); // horizontal: full sphere, vertical: ~5deg from poles const vec2 CompositorHelper::MOUSE_EXTENTS_PIXELS = vec2(VIRTUAL_SCREEN_SIZE) * (MOUSE_EXTENTS_ANGULAR_SIZE / VIRTUAL_UI_TARGET_FOV); From d2b15d7cbab0f23c2191338220311b30d7884a4c Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 24 Oct 2020 16:27:03 +1300 Subject: [PATCH 4/7] Reduce "center UI" trigger distance from 0.99m to 0.33m --- interface/src/ui/OverlayConductor.cpp | 6 +++--- interface/src/ui/OverlayConductor.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index a359b8d4c9..2f0c3c3252 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -23,7 +23,7 @@ OverlayConductor::OverlayConductor() { OverlayConductor::~OverlayConductor() { } -bool OverlayConductor::headOutsideOverlay() const { +bool OverlayConductor::headNotCenteredInOverlay() const { glm::mat4 hmdMat = qApp->getHMDSensorPose(); glm::vec3 hmdPos = extractTranslation(hmdMat); glm::vec3 hmdForward = transformVectorFast(hmdMat, glm::vec3(0.0f, 0.0f, -1.0f)); @@ -32,7 +32,7 @@ bool OverlayConductor::headOutsideOverlay() const { glm::vec3 uiPos = uiTransform.getTranslation(); glm::vec3 uiForward = uiTransform.getRotation() * glm::vec3(0.0f, 0.0f, -1.0f); - const float MAX_COMPOSITOR_DISTANCE = 0.99f; // If you're 1m from center of ui sphere, you're at the surface. + const float MAX_COMPOSITOR_DISTANCE = 0.33f; const float MAX_COMPOSITOR_ANGLE = 180.0f; // rotation check is effectively disabled if (glm::distance(uiPos, hmdPos) > MAX_COMPOSITOR_DISTANCE || glm::dot(uiForward, hmdForward) < cosf(glm::radians(MAX_COMPOSITOR_ANGLE))) { @@ -106,7 +106,7 @@ void OverlayConductor::update(float dt) { shouldRecenter = true; } } else { - if (_hmdMode && headOutsideOverlay()) { + if (_hmdMode && headNotCenteredInOverlay()) { _suppressedByHead = true; } } diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h index 6c3732cf3c..7e7cf5bd3c 100644 --- a/interface/src/ui/OverlayConductor.h +++ b/interface/src/ui/OverlayConductor.h @@ -22,7 +22,7 @@ public: void centerUI(); private: - bool headOutsideOverlay() const; + bool headNotCenteredInOverlay() const; bool updateAvatarIsAtRest(); #if !defined(DISABLE_QML) From 9f95b101fe9266548c5737b12765af3c7532e3dc Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 24 Oct 2020 16:37:38 +1300 Subject: [PATCH 5/7] Enable "center UI" to be triggered on rotation --- interface/src/ui/OverlayConductor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 2f0c3c3252..f1aa75eaf9 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -33,7 +33,7 @@ bool OverlayConductor::headNotCenteredInOverlay() const { glm::vec3 uiForward = uiTransform.getRotation() * glm::vec3(0.0f, 0.0f, -1.0f); const float MAX_COMPOSITOR_DISTANCE = 0.33f; - const float MAX_COMPOSITOR_ANGLE = 180.0f; // rotation check is effectively disabled + const float MAX_COMPOSITOR_ANGLE = 90.0f; if (glm::distance(uiPos, hmdPos) > MAX_COMPOSITOR_DISTANCE || glm::dot(uiForward, hmdForward) < cosf(glm::radians(MAX_COMPOSITOR_ANGLE))) { return true; From cbef9d2926f5df51bbbc741aa6f0744414d10097 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 24 Oct 2020 21:28:49 +1300 Subject: [PATCH 6/7] Fix HUD content displaying only every second HUD recentering --- interface/src/ui/OverlayConductor.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index f1aa75eaf9..557b4d09bf 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -85,7 +85,6 @@ void OverlayConductor::update(float dt) { if (!desktop) { return; } - bool currentVisible = !desktop->property("pinned").toBool(); auto myAvatar = DependencyManager::get()->getMyAvatar(); // centerUI when hmd mode is first enabled and mounted @@ -98,24 +97,24 @@ void OverlayConductor::update(float dt) { _hmdMode = false; } - bool shouldRecenter = false; - - if (_suppressedByHead) { - if (updateAvatarIsAtRest()) { - _suppressedByHead = false; - shouldRecenter = true; - } - } else { - if (_hmdMode && headNotCenteredInOverlay()) { - _suppressedByHead = true; - } + bool initiateRecenter = false; + if (_hmdMode && headNotCenteredInOverlay()) { + initiateRecenter = true; } + bool shouldRecenter = false; + if (initiateRecenter || _suppressedByHead) { + _suppressedByHead = !updateAvatarIsAtRest(); + shouldRecenter = !_suppressedByHead; + } + + bool currentVisible = !desktop->property("pinned").toBool(); bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && !_suppressedByHead; if (targetVisible != currentVisible) { offscreenUi->setPinned(!targetVisible); } - if (shouldRecenter && !_suppressedByHead) { + + if (shouldRecenter) { centerUI(); } #endif From b865e9bc8cde9eefb835a62ae1c372246daedcb7 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 23 Nov 2020 16:02:32 +1300 Subject: [PATCH 7/7] Fix laser intersection with HUD overlay dialogs Also fixes dialog resize outline being drawn in the wrong position (desktop and HMD). --- interface/resources/qml/desktop/Desktop.qml | 4 ++-- interface/resources/qml/windows/Frame.qml | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index 9a9252112c..971fb06414 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -309,8 +309,8 @@ FocusScope { if (child.hasOwnProperty("modality")) { var mappedPoint = mapToItem(child, point.x, point.y); if (child.hasOwnProperty("frame")) { - var outLine = child.frame.children[2]; - var framePoint = outLine.mapFromGlobal(point.x, point.y); + var outLine = child.frame.children[2]; // sizeOutline + var framePoint = mapToItem(outLine, point.x, point.y); if (outLine.contains(framePoint)) { return true; } diff --git a/interface/resources/qml/windows/Frame.qml b/interface/resources/qml/windows/Frame.qml index 7b0fbf8d8c..cfff40bbf6 100644 --- a/interface/resources/qml/windows/Frame.qml +++ b/interface/resources/qml/windows/Frame.qml @@ -27,7 +27,6 @@ Item { readonly property int frameMarginRight: frame.decoration ? frame.decoration.frameMarginRight : 0 readonly property int frameMarginTop: frame.decoration ? frame.decoration.frameMarginTop : 0 readonly property int frameMarginBottom: frame.decoration ? frame.decoration.frameMarginBottom : 0 - readonly property int offsetCorrection: 20 // Frames always fill their parents, but their decorations may extend // beyond the window via negative margin sizes @@ -76,7 +75,7 @@ Item { Rectangle { id: sizeOutline x: -frameMarginLeft - y: -frameMarginTop - offsetCorrection + y: -frameMarginTop width: window ? window.width + frameMarginLeft + frameMarginRight + 2 : 0 height: window ? window.height + frameMarginTop + frameMarginBottom + 2 : 0 color: hifi.colors.baseGrayHighlight15