From 5828c320416c6f3f30f901c016384815e76bcff4 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 25 Feb 2016 08:31:11 -0800 Subject: [PATCH 01/12] add toggleOverlays menu item and action --- interface/src/Application.cpp | 11 ++++++++--- interface/src/Application.h | 2 ++ interface/src/Menu.cpp | 3 +++ interface/src/Menu.h | 1 + libraries/controllers/src/controllers/Actions.cpp | 1 + libraries/controllers/src/controllers/Actions.h | 1 + 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7314bce0bd..45fa27db78 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -817,6 +817,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : } else if (action == controller::toInt(controller::Action::RETICLE_Y)) { auto oldPos = _compositor.getReticlePosition(); _compositor.setReticlePosition({ oldPos.x, oldPos.y + state }); + } else if (action == controller::toInt(controller::Action::TOGGLE_OVERLAY)) { + _overlayConductor.setEnabled(!_overlayConductor.getEnabled()); } } }); @@ -2030,9 +2032,7 @@ void Application::keyPressEvent(QKeyEvent* event) { Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)); cameraMenuChanged(); break; - case Qt::Key_O: - _overlayConductor.setEnabled(!_overlayConductor.getEnabled()); - break; + case Qt::Key_Slash: Menu::getInstance()->triggerOption(MenuOption::Stats); break; @@ -2993,6 +2993,11 @@ void Application::updateThreads(float deltaTime) { } } +void Application::toggleOverlays() { + auto overlaysVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays); + _overlayConductor.setEnabled(overlaysVisible); +} + void Application::cycleCamera() { auto menu = Menu::getInstance(); if (menu->isOptionChecked(MenuOption::FullscreenMirror)) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 51b90bcb99..13dab6137e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -149,6 +149,7 @@ public: const ApplicationOverlay& getApplicationOverlay() const { return _applicationOverlay; } ApplicationCompositor& getApplicationCompositor() { return _compositor; } const ApplicationCompositor& getApplicationCompositor() const { return _compositor; } + Overlays& getOverlays() { return _overlays; } bool isForeground() const { return _isForeground; } @@ -270,6 +271,7 @@ public slots: void cycleCamera(); void cameraMenuChanged(); + void toggleOverlays(); void reloadResourceCaches(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 9c7788851c..bf8cd2e61e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -255,6 +255,9 @@ Menu::Menu() { 0, true, qApp, SLOT(rotationModeChanged()), UNSPECIFIED_POSITION, "Advanced"); + // View > Overlays + addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Overlays, 0, true, + qApp, SLOT(toggleOverlays())); // Navigate menu ---------------------------------- MenuWrapper* navigateMenu = addMenu("Navigate"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 44a24ee895..ca5bf295db 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -247,6 +247,7 @@ namespace MenuOption { const QString OnePointCalibration = "1 Point Calibration"; const QString OnlyDisplayTopTen = "Only Display Top Ten"; const QString OutputMenu = "Display"; + const QString Overlays = "Overlays"; const QString PackageModel = "Package Model..."; const QString Pair = "Pair"; const QString PhysicsShowHulls = "Draw Collision Hulls"; diff --git a/libraries/controllers/src/controllers/Actions.cpp b/libraries/controllers/src/controllers/Actions.cpp index e6662caa37..dba856cbaa 100644 --- a/libraries/controllers/src/controllers/Actions.cpp +++ b/libraries/controllers/src/controllers/Actions.cpp @@ -61,6 +61,7 @@ namespace controller { makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"), makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"), makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"), + makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"), makeAxisPair(Action::RETICLE_CLICK, "ReticleClick"), makeAxisPair(Action::RETICLE_X, "ReticleX"), diff --git a/libraries/controllers/src/controllers/Actions.h b/libraries/controllers/src/controllers/Actions.h index e77e5e5a93..efdc45cb3d 100644 --- a/libraries/controllers/src/controllers/Actions.h +++ b/libraries/controllers/src/controllers/Actions.h @@ -52,6 +52,7 @@ enum class Action { CONTEXT_MENU, TOGGLE_MUTE, CYCLE_CAMERA, + TOGGLE_OVERLAY, SHIFT, From 526f9dc2481940d0bf11e5f5020eecc23030d99e Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 25 Feb 2016 08:41:38 -0800 Subject: [PATCH 02/12] check/uncheck the overlays menu when you toggle the overlays via some other mechanism --- interface/src/ui/OverlayConductor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index f777e5d4dc..4cc5e6d534 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -110,6 +110,8 @@ void OverlayConductor::setEnabled(bool enabled) { return; } + Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, enabled); + if (_enabled) { // alpha fadeOut the overlay mesh. qApp->getApplicationCompositor().fadeOut(); From 626b1702072163d2ddd6076db0d7fe15aeb2a655 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 25 Feb 2016 14:10:23 -0800 Subject: [PATCH 03/12] Crash fix for RenderableBoxEntityItem::render --- libraries/entities-renderer/src/RenderableBoxEntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp b/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp index 2d054ec31b..671043813e 100644 --- a/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp @@ -62,7 +62,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) { } batch.setModelTransform(transToCenter); // we want to include the scale as well - if (_procedural->ready()) { + if (_procedural && _procedural->ready()) { _procedural->prepare(batch, getPosition(), getDimensions()); auto color = _procedural->getColor(cubeColor); batch._glColor4f(color.r, color.g, color.b, color.a); From 366aa39be8cc27d0545dc57740b97e893e4ecccd Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 25 Feb 2016 14:46:08 -0800 Subject: [PATCH 04/12] handle startup overlay visibility correctly --- interface/src/Application.cpp | 16 +++++++++++++++- interface/src/Application.h | 1 + interface/src/Menu.cpp | 2 +- interface/src/ui/ApplicationCompositor.h | 2 +- interface/src/ui/ApplicationOverlay.cpp | 4 ---- interface/src/ui/OverlayConductor.cpp | 9 ++++----- interface/src/ui/OverlayConductor.h | 4 ++-- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 45fa27db78..6845524631 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1200,7 +1200,6 @@ void Application::initializeUi() { // OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to // support the window management and scripting proxies for VR use offscreenUi->createDesktop(QString("hifi/Desktop.qml")); - connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop); // FIXME either expose so that dialogs can set this themselves or // do better detection in the offscreen UI of what has focus @@ -2435,6 +2434,17 @@ void Application::idle(uint64_t now) { if (_aboutToQuit) { return; // bail early, nothing to do here. } + + Stats::getInstance()->updateStats(); + AvatarInputs::getInstance()->update(); + + static bool firstIdle = true; + if (firstIdle) { + firstIdle = false; + auto offscreenUi = DependencyManager::get(); + connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop); + } + auto displayPlugin = getActiveDisplayPlugin(); // depending on whether we're throttling or not. @@ -2998,6 +3008,10 @@ void Application::toggleOverlays() { _overlayConductor.setEnabled(overlaysVisible); } +void Application::setOverlaysVisible(bool visible) { + _overlayConductor.setEnabled(visible); +} + void Application::cycleCamera() { auto menu = Menu::getInstance(); if (menu->isOptionChecked(MenuOption::FullscreenMirror)) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 13dab6137e..aacf0b5b08 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -272,6 +272,7 @@ public slots: void cycleCamera(); void cameraMenuChanged(); void toggleOverlays(); + void setOverlaysVisible(bool visible); void reloadResourceCaches(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index bf8cd2e61e..a5795c5a3b 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -257,7 +257,7 @@ Menu::Menu() { // View > Overlays addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Overlays, 0, true, - qApp, SLOT(toggleOverlays())); + qApp, SLOT(setOverlaysVisible(bool))); // Navigate menu ---------------------------------- MenuWrapper* navigateMenu = addMenu("Navigate"); diff --git a/interface/src/ui/ApplicationCompositor.h b/interface/src/ui/ApplicationCompositor.h index 7bdb97727f..b94afd2cce 100644 --- a/interface/src/ui/ApplicationCompositor.h +++ b/interface/src/ui/ApplicationCompositor.h @@ -131,7 +131,7 @@ private: float _textureAspectRatio { 1.0f }; int _hemiVerticesID { GeometryCache::UNKNOWN_ID }; - float _alpha { 1.0f }; + float _alpha { 0.0f }; // hidden by default float _prevAlpha { 1.0f }; float _fadeInAlpha { true }; float _oculusUIRadius { 1.0f }; diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 67b5135e0c..998a64d81a 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -58,10 +58,6 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) { CHECK_GL_ERROR(); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()"); - // TODO move to Application::idle()? - Stats::getInstance()->updateStats(); - AvatarInputs::getInstance()->update(); - buildFramebufferObject(); if (!_overlayFramebuffer) { diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 4cc5e6d534..21b1aa879e 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -110,9 +110,12 @@ void OverlayConductor::setEnabled(bool enabled) { return; } + qDebug() << "OverlayConductor::setEnabled() enabled:" << enabled; Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, enabled); - if (_enabled) { + _enabled = enabled; // set the new value + + if (!_enabled) { // alpha fadeOut the overlay mesh. qApp->getApplicationCompositor().fadeOut(); @@ -122,8 +125,6 @@ void OverlayConductor::setEnabled(bool enabled) { // disable QML events auto offscreenUi = DependencyManager::get(); offscreenUi->getRootItem()->setEnabled(false); - - _enabled = false; } else { // alpha fadeIn the overlay mesh. qApp->getApplicationCompositor().fadeIn(); @@ -144,8 +145,6 @@ void OverlayConductor::setEnabled(bool enabled) { t.setRotation(glm::quat_cast(camMat)); qApp->getApplicationCompositor().setModelTransform(t); } - - _enabled = true; } } diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h index 4b8c0134b5..b94c5be7dd 100644 --- a/interface/src/ui/OverlayConductor.h +++ b/interface/src/ui/OverlayConductor.h @@ -29,8 +29,8 @@ private: STANDING }; - Mode _mode = FLAT; - bool _enabled = true; + Mode _mode { FLAT }; + bool _enabled { false }; }; #endif From 519a90f2bdca815177b208c97d59ac3bc5e93271 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 25 Feb 2016 16:02:05 -0800 Subject: [PATCH 05/12] fix the overlays visible on startup case --- interface/src/Application.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6845524631..df7b203bea 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2438,11 +2438,14 @@ void Application::idle(uint64_t now) { Stats::getInstance()->updateStats(); AvatarInputs::getInstance()->update(); + // These tasks need to be done on our first idle, because we don't want the showing of + // overlay subwindows to do a showDesktop() until after the first time through static bool firstIdle = true; if (firstIdle) { firstIdle = false; auto offscreenUi = DependencyManager::get(); connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop); + _overlayConductor.setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Overlays)); } From e58081ca9c2d2dcfd3afb83edfd019edef888d03 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 25 Feb 2016 16:23:12 -0800 Subject: [PATCH 06/12] remove extra debug code --- interface/src/ui/OverlayConductor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 21b1aa879e..324ec8583b 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -110,7 +110,6 @@ void OverlayConductor::setEnabled(bool enabled) { return; } - qDebug() << "OverlayConductor::setEnabled() enabled:" << enabled; Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, enabled); _enabled = enabled; // set the new value From 1fdae13de100b288b848dcdcc9a088524138b7ea Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 25 Feb 2016 17:38:20 -0800 Subject: [PATCH 07/12] Application: don't simulate until we are ready to render. --- interface/src/Application.cpp | 49 ++++++++++++----------------------- interface/src/Application.h | 1 - 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 29c8e136af..8aa27cfd86 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -210,8 +210,6 @@ 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 = 120; -static const int CAPPED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / CAPPED_SIM_FRAMERATE; static const uint32_t INVALID_FRAME = UINT32_MAX; @@ -317,6 +315,9 @@ bool setupEssentials(int& argc, char** argv) { Setting::preInit(); + LogHandler::getInstance().setShouldDisplayMilliseconds(true); + LogHandler::getInstance().setShouldOutputThreadID(true); + CrashHandler::checkForAndHandleCrash(); CrashHandler::writeRunningMarkerFiler(); qAddPostRoutine(CrashHandler::deleteRunningMarkerFile); @@ -967,6 +968,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(this, &Application::applicationStateChanged, this, &Application::activeChanged); qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0); + _idleTimer = new QTimer(this); connect(_idleTimer, &QTimer::timeout, [=] { idle(usecTimestampNow()); @@ -975,7 +977,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : disconnect(_idleTimer); }); // Setting the interval to zero forces this to get called whenever there are no messages - // in the queue, which can be pretty damn frequent. Hence the idle function has a bunch + // in the queue, which can be pretty damn frequent. Hence the idle function has a bunch // of logic to abort early if it's being called too often. _idleTimer->start(0); } @@ -1296,6 +1298,7 @@ void Application::initializeUi() { } void Application::paintGL() { + // paintGL uses a queued connection, so we can get messages from the queue even after we've quit // and the plugins have shutdown if (_aboutToQuit) { @@ -1321,10 +1324,6 @@ void Application::paintGL() { _lastFramesPerSecondUpdate = now; } - if (_isGLInitialized) { - idle(now); - } - PROFILE_RANGE(__FUNCTION__); PerformanceTimer perfTimer("paintGL"); @@ -1619,7 +1618,6 @@ void Application::paintGL() { } _lastInstantaneousFps = instantaneousFps; - _pendingPaint = false; } void Application::runTests() { @@ -2432,10 +2430,11 @@ bool Application::acceptSnapshot(const QString& urlString) { static uint32_t _renderedFrameIndex { INVALID_FRAME }; void Application::idle(uint64_t now) { + if (_aboutToQuit) { return; // bail early, nothing to do here. } - + auto displayPlugin = getActiveDisplayPlugin(); // depending on whether we're throttling or not. // Once rendering is off on another thread we should be able to have Application::idle run at start(0) in @@ -2456,30 +2455,16 @@ void Application::idle(uint64_t now) { _renderedFrameIndex = INVALID_FRAME; } - // Nested ifs are for clarity in the logic. Don't collapse them into a giant single if. // Don't saturate the main thread with rendering, no paint calls until the last one is complete - if (!_pendingPaint) { - // Also no paint calls until the display plugin has increased by at least one frame - // (don't render at 90fps if the display plugin only goes at 60) - if (_renderedFrameIndex == INVALID_FRAME || presentCount > _renderedFrameIndex) { - // Record what present frame we're on - _renderedFrameIndex = presentCount; - // Don't allow paint requests to stack up in the event queue - _pendingPaint = true; - // But when we DO request a paint, get to it as soon as possible: high priority - postEvent(this, new QEvent(static_cast(Paint)), Qt::HighEventPriority); - } - } - - // For the rest of idle, we want to cap at the max sim rate, so we might not call - // the remaining idle work every paint frame, or vice versa - // In theory this means we could call idle processing more often than painting, - // but in practice, when the paintGL calls aren't keeping up, there's no room left - // in the main thread to call idle more often than paint. - // This check is mostly to keep idle from burning up CPU cycles by running at - // hundreds of idles per second when the rendering is that fast - if ((timeSinceLastUpdateUs / USECS_PER_MSEC) < CAPPED_SIM_FRAME_PERIOD_MS) { - // No paint this round, but might be time for a new idle, otherwise return + // Also no paint calls until the display plugin has increased by at least one frame + // (don't render at 90fps if the display plugin only goes at 60) + if (_renderedFrameIndex == INVALID_FRAME || presentCount > _renderedFrameIndex) { + // Record what present frame we're on + _renderedFrameIndex = presentCount; + + // But when we DO request a paint, get to it as soon as possible: high priority + postEvent(this, new QEvent(static_cast(Paint)), Qt::HighEventPriority); + } else { return; } diff --git a/interface/src/Application.h b/interface/src/Application.h index 51b90bcb99..cfa87ea411 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -509,7 +509,6 @@ private: int _avatarAttachmentRequest = 0; bool _settingsLoaded { false }; - bool _pendingPaint { false }; QTimer* _idleTimer { nullptr }; bool _fakedMouseEvent { false }; From 08c16beff26e4eb93b10a7d459309606fa4c389a Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 25 Feb 2016 18:17:42 -0800 Subject: [PATCH 08/12] Application: re-worded presentCount comments --- interface/src/Application.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e74e842f9d..caff5e7e46 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2455,16 +2455,16 @@ void Application::idle(uint64_t now) { _renderedFrameIndex = INVALID_FRAME; } - // Don't saturate the main thread with rendering, no paint calls until the last one is complete - // Also no paint calls until the display plugin has increased by at least one frame - // (don't render at 90fps if the display plugin only goes at 60) + // Don't saturate the main thread with rendering and simulation, + // unless display plugin has increased by at least one frame if (_renderedFrameIndex == INVALID_FRAME || presentCount > _renderedFrameIndex) { // Record what present frame we're on _renderedFrameIndex = presentCount; - // But when we DO request a paint, get to it as soon as possible: high priority + // request a paint, get to it as soon as possible: high priority postEvent(this, new QEvent(static_cast(Paint)), Qt::HighEventPriority); } else { + // there's no use in simulating or rendering faster then the present rate. return; } From e5c81f66a54c8c9603fa03bd5e822d8aa67de055 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 25 Feb 2016 18:20:43 -0800 Subject: [PATCH 09/12] Application: removed threadID and milliseconds from logging. --- interface/src/Application.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index caff5e7e46..283b66b29e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -315,9 +315,6 @@ bool setupEssentials(int& argc, char** argv) { Setting::preInit(); - LogHandler::getInstance().setShouldDisplayMilliseconds(true); - LogHandler::getInstance().setShouldOutputThreadID(true); - CrashHandler::checkForAndHandleCrash(); CrashHandler::writeRunningMarkerFiler(); qAddPostRoutine(CrashHandler::deleteRunningMarkerFile); From bf0fb7258a49f59b29a5df740d49026e4f9e32c5 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 25 Feb 2016 22:01:10 -0800 Subject: [PATCH 10/12] CR feedback --- interface/src/Application.cpp | 7 ++++--- interface/src/ui/OverlayConductor.cpp | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b072867400..64a9ef2029 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -818,7 +818,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : auto oldPos = _compositor.getReticlePosition(); _compositor.setReticlePosition({ oldPos.x, oldPos.y + state }); } else if (action == controller::toInt(controller::Action::TOGGLE_OVERLAY)) { - _overlayConductor.setEnabled(!_overlayConductor.getEnabled()); + toggleOverlays(); } } }); @@ -3003,8 +3003,9 @@ void Application::updateThreads(float deltaTime) { } void Application::toggleOverlays() { - auto overlaysVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays); - _overlayConductor.setEnabled(overlaysVisible); + auto newOverlaysVisible = !_overlayConductor.getEnabled(); + Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, newOverlaysVisible); + _overlayConductor.setEnabled(newOverlaysVisible); } void Application::setOverlaysVisible(bool visible) { diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 324ec8583b..113dad1ab5 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -114,17 +114,8 @@ void OverlayConductor::setEnabled(bool enabled) { _enabled = enabled; // set the new value - if (!_enabled) { - // alpha fadeOut the overlay mesh. - qApp->getApplicationCompositor().fadeOut(); - - // disable mouse clicks from script - qApp->getOverlays().disable(); - - // disable QML events - auto offscreenUi = DependencyManager::get(); - offscreenUi->getRootItem()->setEnabled(false); - } else { + // if the new state is visible/enabled... + if (_enabled) { // alpha fadeIn the overlay mesh. qApp->getApplicationCompositor().fadeIn(); @@ -144,6 +135,16 @@ void OverlayConductor::setEnabled(bool enabled) { t.setRotation(glm::quat_cast(camMat)); qApp->getApplicationCompositor().setModelTransform(t); } + } else { // other wise, if the new state is hidden/not enabled + // alpha fadeOut the overlay mesh. + qApp->getApplicationCompositor().fadeOut(); + + // disable mouse clicks from script + qApp->getOverlays().disable(); + + // disable QML events + auto offscreenUi = DependencyManager::get(); + offscreenUi->getRootItem()->setEnabled(false); } } From 6b427e59ae34be73a149ecdd18bc4b3eecd6ccae Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 26 Feb 2016 10:12:23 -0800 Subject: [PATCH 11/12] show the overlays when the context menu is shown --- libraries/ui/src/OffscreenUi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 1c41827795..999f9ef2f7 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -460,6 +460,7 @@ void OffscreenUi::unfocusWindows() { } void OffscreenUi::toggleMenu(const QPoint& screenPosition) { + emit showDesktop(); // we really only want to do this if you're showing the menu, but for now this works auto virtualPos = mapToVirtualScreen(screenPosition, nullptr); QMetaObject::invokeMethod(_desktop, "toggleMenu", Q_ARG(QVariant, virtualPos)); } From 712cf911b19c5019f743d6ac3232a3887ac84b62 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Fri, 26 Feb 2016 11:06:02 -0800 Subject: [PATCH 12/12] Differentiate global sun and skyStage sun --- libraries/model/src/model/Stage.cpp | 2 ++ .../render-utils/src/DeferredLightingEffect.cpp | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index 6a1e95936b..c976e5c396 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -142,6 +142,8 @@ SunSkyStage::SunSkyStage() : _skybox(std::make_shared()) { _sunLight->setType(Light::SUN); + // Default ambient sphere (for lack of skybox) + _sunLight->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset::OLD_TOWN_SQUARE); setSunIntensity(1.0f); setSunAmbientIntensity(0.5f); diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index e0cbab67bc..c1c7240f20 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -87,14 +87,11 @@ void DeferredLightingEffect::init() { _allocatedLights.push_back(std::make_shared()); model::LightPointer lp = _allocatedLights[0]; + lp->setType(model::Light::SUN); + // Add the global light to the light stage (for later shadow rendering) _lightStage.addLight(lp); - lp->setDirection(-glm::vec3(1.0f, 1.0f, 1.0f)); - lp->setColor(glm::vec3(1.0f)); - lp->setIntensity(1.0f); - lp->setType(model::Light::SUN); - lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset(_ambientLightMode % gpu::SphericalHarmonics::NUM_PRESET)); } void DeferredLightingEffect::addPointLight(const glm::vec3& position, float radius, const glm::vec3& color, @@ -560,7 +557,13 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo } void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) { - _allocatedLights.front() = light; + auto globalLight = _allocatedLights.front(); + globalLight->setDirection(light->getDirection()); + globalLight->setColor(light->getColor()); + globalLight->setIntensity(light->getIntensity()); + globalLight->setAmbientIntensity(light->getAmbientIntensity()); + globalLight->setAmbientSphere(light->getAmbientSphere()); + _skyboxTexture = skyboxTexture; }