History

Merge branch 'master' of https://github.com/highfidelity/hifi into sendDataDescription

ZappoMan committed 8 years ago

Commit cb01bd12 parents 4ad5d34 7c09b21565 files · +16152 −7946Browse files

Showing the changes to interface/src/Application.cpp (1 of 565 files). Show all

Unified · Split

interface/src/Application.cpp+205−73
@@ -14,17 +14,20 @@ · 13 unmodified lines
1414 #include <chrono>
1515 #include <thread>
1616
17−#include <gl/Config.h>
1817 #include <glm/glm.hpp>
1918 #include <glm/gtx/component_wise.hpp>
2019 #include <glm/gtx/quaternion.hpp>
2120 #include <glm/gtx/vector_angle.hpp>
2221 #include <glm/gtc/type_ptr.hpp>
2322
23+#include <gl/Config.h>
24+
25+#include <QtCore/QResource>
2426 #include <QtCore/QAbstractNativeEventFilter>
2527 #include <QtCore/QCommandLineParser>
2628 #include <QtCore/QMimeData>
2729 #include <QtCore/QThreadPool>
30+#include <QtCore/QFileSelector>
2831 #include <QtConcurrent/QtConcurrentRun>
2932
3033 #include <QtGui/QScreen>
@@ -49,6 +52,7 @@ · 18 unmodified lines
4952
5053 #include <gl/QOpenGLContextWrapper.h>
5154
55+#include <shared/FileUtils.h>
5256 #include <shared/QtHelpers.h>
5357 #include <shared/GlobalAppProperties.h>
5458 #include <StatTracker.h>
@@ -157,7 +161,7 @@ · 102 unmodified lines
157161 #include "scripting/AssetMappingsScriptingInterface.h"
158162 #include "scripting/ClipboardScriptingInterface.h"
159163 #include "scripting/DesktopScriptingInterface.h"
160−#include "scripting/GlobalServicesScriptingInterface.h"
164+#include "scripting/AccountServicesScriptingInterface.h"
161165 #include "scripting/HMDScriptingInterface.h"
162166 #include "scripting/MenuScriptingInterface.h"
163167 #include "scripting/SettingsScriptingInterface.h"
@@ -209,9 +213,8 @@ · 45 unmodified lines
209213 #include "commerce/QmlCommerce.h"
210214
211215 #include "webbrowser/WebBrowserSuggestionsEngine.h"
216+#include <DesktopPreviewProvider.h>
212217
213−// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
214−// FIXME seems to be broken.
215218 #if defined(Q_OS_WIN)
216219 #include <VersionHelpers.h>
217220
@@ -226,11 +229,17 @@ · 8 unmodified lines
226229 #undef QT_BOOTSTRAPPED
227230 #endif
228231
232+// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
233+// FIXME seems to be broken.
229234 extern "C" {
230235 _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
231236 }
232237 #endif
233238
239+#if defined(Q_OS_ANDROID)
240+#include <android/log.h>
241+#endif
242+
234243 enum ApplicationEvent {
235244 // Execute a lambda function
236245 Lambda = QEvent::User + 1,
@@ -240,7 +249,6 @@ enum ApplicationEvent { · 3 unmodified lines
240249 Idle,
241250 };
242251
243−
244252 class RenderEventHandler : public QObject {
245253 using Parent = QObject;
246254 Q_OBJECT
@@ -304,9 +312,19 @@ static QTimer locationUpdateTimer; · 57 unmodified lines
304312 static QTimer identityPacketTimer;
305313 static QTimer pingTimer;
306314
307−static const QString DISABLE_WATCHDOG_FLAG("HIFI_DISABLE_WATCHDOG");
315+#if defined(Q_OS_ANDROID)
316+static bool DISABLE_WATCHDOG = true;
317+#else
318+static const QString DISABLE_WATCHDOG_FLAG{ "HIFI_DISABLE_WATCHDOG" };
308319 static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);
320+#endif
309321
322+#if defined(USE_GLES)
323+static bool DISABLE_DEFERRED = true;
324+#else
325+static const QString RENDER_FORWARD{ "HIFI_RENDER_FORWARD" };
326+static bool DISABLE_DEFERRED = QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
327+#endif
310328
311329 static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
312330
@@ -333,7 +351,7 @@ static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f; · 20 unmodified lines
333351 static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND;
334352
335353 static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html";
336−static const QString INFO_HELP_PATH = "../../../html/tabletHelp.html";
354+static const QString INFO_HELP_PATH = "html/tabletHelp.html";
337355
338356 static const unsigned int THROTTLED_SIM_FRAMERATE = 15;
339357 static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE;
@@ -503,7 +521,13 @@ public: · 163 unmodified lines
503521 }
504522
505523 if (message->message == WM_DEVICECHANGE) {
506− Midi::USBchanged(); // re-scan the MIDI bus
524+ const float MIN_DELTA_SECONDS = 2.0f; // de-bounce signal
525+ static float lastTriggerTime = 0.0f;
526+ const float deltaSeconds = secTimestampNow() - lastTriggerTime;
527+ lastTriggerTime = secTimestampNow();
528+ if (deltaSeconds > MIN_DELTA_SECONDS) {
529+ Midi::USBchanged(); // re-scan the MIDI bus
530+ }
507531 }
508532 }
509533 return false;
@@ -530,6 +554,26 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 20 unmodified lines
530554 #ifdef Q_OS_WIN
531555 OutputDebugStringA(logMessage.toLocal8Bit().constData());
532556 OutputDebugStringA("\n");
557+#elif defined Q_OS_ANDROID
558+ const char * local=logMessage.toStdString().c_str();
559+ switch (type) {
560+ case QtDebugMsg:
561+ __android_log_write(ANDROID_LOG_DEBUG,"Interface",local);
562+ break;
563+ case QtInfoMsg:
564+ __android_log_write(ANDROID_LOG_INFO,"Interface",local);
565+ break;
566+ case QtWarningMsg:
567+ __android_log_write(ANDROID_LOG_WARN,"Interface",local);
568+ break;
569+ case QtCriticalMsg:
570+ __android_log_write(ANDROID_LOG_ERROR,"Interface",local);
571+ break;
572+ case QtFatalMsg:
573+ default:
574+ __android_log_write(ANDROID_LOG_FATAL,"Interface",local);
575+ abort();
576+ }
533577 #endif
534578 qApp->getLogger()->addMessage(qPrintable(logMessage + "\n"));
535579 }
@@ -573,8 +617,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 37 unmodified lines
573617 }
574618 };
575619 reportAndQuit("--protocolVersion", [&](FILE* fp) {
576− DependencyManager::set<AddressManager>();
577− auto version = DependencyManager::get<AddressManager>()->protocolVersion();
620+ auto version = protocolVersionsSignatureBase64();
578621 fputs(version.toLatin1().data(), fp);
579622 });
580623 reportAndQuit("--version", [&](FILE* fp) {
@@ -594,6 +637,24 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 13 unmodified lines
594637 qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir);
595638 }
596639
640+ // FIXME fix the OSX installer to install the resources.rcc binary instead of resource files and remove
641+ // this conditional exclusion
642+#if !defined(Q_OS_OSX)
643+ {
644+#if defined(Q_OS_ANDROID)
645+ const QString resourcesBinaryFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/resources.rcc";
646+#else
647+ const QString resourcesBinaryFile = QCoreApplication::applicationDirPath() + "/resources.rcc";
648+#endif
649+ if (!QFile::exists(resourcesBinaryFile)) {
650+ throw std::runtime_error("Unable to find primary resources");
651+ }
652+ if (!QResource::registerResource(resourcesBinaryFile)) {
653+ throw std::runtime_error("Unable to load primary resources");
654+ }
655+ }
656+#endif
657+
597658 Setting::init();
598659
599660 // Tell the plugin manager about our statically linked plugins
@@ -632,15 +693,16 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 32 unmodified lines
632693 DependencyManager::set<PointerScriptingInterface>();
633694 DependencyManager::set<PickScriptingInterface>();
634695 DependencyManager::set<Cursor::Manager>();
696+ DependencyManager::set<DesktopPreviewProvider>();
635697 DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp));
636698 DependencyManager::set<StatTracker>();
637699 DependencyManager::set<ScriptEngines>(ScriptEngine::CLIENT_SCRIPT);
638700 DependencyManager::set<Preferences>();
639− DependencyManager::set<recording::ClipCache>();
640701 DependencyManager::set<recording::Deck>();
641702 DependencyManager::set<recording::Recorder>();
642703 DependencyManager::set<AddressManager>();
643704 DependencyManager::set<NodeList>(NodeType::Agent, listenPort);
705+ DependencyManager::set<recording::ClipCache>();
644706 DependencyManager::set<GeometryCache>();
645707 DependencyManager::set<ModelCache>();
646708 DependencyManager::set<ScriptCache>();
@@ -729,8 +791,10 @@ OverlayID _keyboardFocusHighlightID{ UNKNOWN_OVERLAY_ID }; · 82 unmodified lines
729791 //
730792 // So instead we create a new offscreen context to share with the QGLWidget,
731793 // and manually set THAT to be the shared context for the Chromium helper
794+#if !defined(DISABLE_QML)
732795 OffscreenGLCanvas* _chromiumShareContext { nullptr };
733796 Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
797+#endif
734798
735799 Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 };
736800
@@ -776,6 +840,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 39 unmodified lines
776840 _sampleSound(nullptr)
777841
778842 {
843+
779844 auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
780845 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
781846 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
@@ -996,8 +1061,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 214 unmodified lines
9961061 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
9971062
9981063 // Inititalize sample before registering
999− QFileInfo infSample = QFileInfo(PathUtils::resourcesPath() + "sounds/sample.wav");
1000− _sampleSound = DependencyManager::get<SoundCache>()->getSound(QUrl::fromLocalFile(infSample.absoluteFilePath()));
1064+ _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav"));
10011065
10021066 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
10031067 scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){
@@ -1082,9 +1146,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 78 unmodified lines
10821146 // Make sure we don't time out during slow operations at startup
10831147 updateHeartbeat();
10841148
1085− // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success.
1086− DependencyManager::get<GeometryCache>()->initializeShapePipelines();
1087−
10881149 // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
10891150 // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
10901151 static const QString TESTER = "HIFI_TESTER";
@@ -1731,7 +1792,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 640 unmodified lines
17311792 static int lastCountOfNearbyAvatars = -1;
17321793 QTimer* checkNearbyAvatarsTimer = new QTimer(this);
17331794 checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok
1734− connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
1795+ connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, []() {
17351796 auto avatarManager = DependencyManager::get<AvatarManager>();
17361797 int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(),
17371798 NEARBY_AVATAR_RADIUS_METERS) - 1;
@@ -1770,9 +1831,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 32 unmodified lines
17701831 PROFILE_RANGE(render, "Process Default Skybox");
17711832 auto textureCache = DependencyManager::get<TextureCache>();
17721833
1773− auto skyboxUrl = PathUtils::resourcesPath().toStdString() + "images/Default-Sky-9-cubemap.ktx";
1834+ QFileSelector fileSelector;
1835+ fileSelector.setExtraSelectors(FileUtils::getFileSelectors());
1836+ auto skyboxUrl = fileSelector.select(PathUtils::resourcesPath() + "images/Default-Sky-9-cubemap.ktx");
17741837
1775− _defaultSkyboxTexture = gpu::Texture::unserialize(skyboxUrl);
1838+ _defaultSkyboxTexture = gpu::Texture::unserialize(skyboxUrl.toStdString());
17761839 _defaultSkyboxAmbientTexture = _defaultSkyboxTexture;
17771840
17781841 _defaultSkybox->setCubemap(_defaultSkyboxTexture);
@@ -1783,8 +1846,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 4 unmodified lines
17831846 return entityServerNode && !isPhysicsEnabled();
17841847 });
17851848
1786− QFileInfo infSnap = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
1787− _snapshotSound = DependencyManager::get<SoundCache>()->getSound(QUrl::fromLocalFile(infSnap.absoluteFilePath()));
1849+ _snapshotSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/snap.wav"));
17881850
17891851 QVariant testProperty = property(hifi::properties::TEST);
17901852 qDebug() << testProperty;
@@ -1852,6 +1914,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 61 unmodified lines
18521914 DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](unsigned int rayPickID, bool value) {
18531915 DependencyManager::get<PickManager>()->setPrecisionPicking(rayPickID, value);
18541916 });
1917+ EntityTreeRenderer::setRenderDebugHullsOperator([] {
1918+ return Menu::getInstance()->isOptionChecked(MenuOption::PhysicsShowHulls);
1919+ });
18551920
18561921 // Preload Tablet sounds
18571922 DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
@@ -2091,6 +2156,11 @@ void Application::cleanupBeforeQuit() { · 233 unmodified lines
20912156 DependencyManager::destroy<AudioInjectorManager>();
20922157 DependencyManager::destroy<AudioScriptingInterface>();
20932158
2159+ // The PointerManager must be destroyed before the PickManager because when a Pointer is deleted,
2160+ // it accesses the PickManager to delete its associated Pick
2161+ DependencyManager::destroy<PointerManager>();
2162+ DependencyManager::destroy<PickManager>();
2163+
20942164 qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
20952165 }
20962166
@@ -2174,11 +2244,16 @@ void Application::initializeGL() { · 77 unmodified lines
21742244 }
21752245
21762246 _glWidget->makeCurrent();
2177− _chromiumShareContext = new OffscreenGLCanvas();
2178− _chromiumShareContext->setObjectName("ChromiumShareContext");
2179− _chromiumShareContext->create(_glWidget->qglContext());
2180− _chromiumShareContext->makeCurrent();
2181− qt_gl_set_global_share_context(_chromiumShareContext->getContext());
2247+
2248+#if !defined(DISABLE_QML)
2249+ if (!nsightActive()) {
2250+ _chromiumShareContext = new OffscreenGLCanvas();
2251+ _chromiumShareContext->setObjectName("ChromiumShareContext");
2252+ _chromiumShareContext->create(_glWidget->qglContext());
2253+ _chromiumShareContext->makeCurrent();
2254+ qt_gl_set_global_share_context(_chromiumShareContext->getContext());
2255+ }
2256+#endif
21822257
21832258 _glWidget->makeCurrent();
21842259 gpu::Context::init<gpu::gl::GLBackend>();
@@ -2195,13 +2270,17 @@ void Application::initializeGL() { · 10 unmodified lines
21952270 // Set up the render engine
21962271 render::CullFunctor cullFunctor = LODManager::shouldRender;
21972272 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
2198− bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
21992273 _renderEngine->addJob<UpdateSceneTask>("UpdateScene");
2200− _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor);
2201− _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
2274+#ifndef Q_OS_ANDROID
2275+ _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor, !DISABLE_DEFERRED);
2276+#endif
2277+ _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, !DISABLE_DEFERRED);
22022278 _renderEngine->load();
22032279 _renderEngine->registerScene(_main3DScene);
22042280
2281+ // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success.
2282+ DependencyManager::get<GeometryCache>()->initializeShapePipelines();
2283+
22052284 _offscreenContext = new OffscreenGLCanvas();
22062285 _offscreenContext->setObjectName("MainThreadContext");
22072286 _offscreenContext->create(_glWidget->qglContext());
@@ -2285,7 +2364,7 @@ void Application::initializeUi() { · 77 unmodified lines
22852364 QUrl{ "hifi/commerce/wallet/SecurityImageChange.qml" },
22862365 QUrl{ "hifi/commerce/wallet/SecurityImageModel.qml" },
22872366 QUrl{ "hifi/commerce/wallet/SecurityImageSelection.qml" },
2288− QUrl{ "hifi/commerce/wallet/SendMoney.qml" },
2367+ QUrl{ "hifi/commerce/wallet/sendMoney/SendMoney.qml" },
22892368 QUrl{ "hifi/commerce/wallet/Wallet.qml" },
22902369 QUrl{ "hifi/commerce/wallet/WalletHome.qml" },
22912370 QUrl{ "hifi/commerce/wallet/WalletSetup.qml" },
@@ -2306,8 +2385,7 @@ void Application::initializeUi() { · 14 unmodified lines
23062385 offscreenUi->setProxyWindow(_window->windowHandle());
23072386 // OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
23082387 // support the window management and scripting proxies for VR use
2309− offscreenUi->createDesktop(QString("hifi/Desktop.qml"));
2310−
2388+ offscreenUi->createDesktop(PathUtils::qmlUrl("hifi/Desktop.qml"));
23112389 // FIXME either expose so that dialogs can set this themselves or
23122390 // do better detection in the offscreen UI of what has focus
23132391 offscreenUi->setNavigationFocused(false);
@@ -2374,9 +2452,11 @@ void Application::initializeUi() { · 60 unmodified lines
23742452 surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data());
23752453 surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
23762454
2377− surfaceContext->setContextProperty("Account", GlobalServicesScriptingInterface::getInstance());
2455+ surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
2456+ surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
2457+ surfaceContext->setContextProperty("AccountServices", AccountServicesScriptingInterface::getInstance());
2458+
23782459 surfaceContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface);
2379− surfaceContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance());
23802460 surfaceContext->setContextProperty("FaceTracker", DependencyManager::get<DdeFaceTracker>().data());
23812461 surfaceContext->setContextProperty("AvatarManager", DependencyManager::get<AvatarManager>().data());
23822462 surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface);
@@ -2442,7 +2522,7 @@ void Application::initializeUi() { · 59 unmodified lines
24422522 offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2);
24432523 }
24442524
2445−void Application::updateCamera(RenderArgs& renderArgs) {
2525+void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
24462526 PROFILE_RANGE(render, __FUNCTION__);
24472527 PerformanceTimer perfTimer("updateCamera");
24482528
@@ -2457,6 +2537,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 8 unmodified lines
24572537 // Using the latter will cause the camera to wobble with idle animations,
24582538 // or with changes from the face tracker
24592539 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
2540+ _thirdPersonHMDCameraBoomValid= false;
24602541 if (isHMDMode()) {
24612542 mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
24622543 _myCamera.setPosition(extractTranslation(camMat));
@@ -2469,12 +2550,25 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 6 unmodified lines
24692550 }
24702551 else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
24712552 if (isHMDMode()) {
2472− auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2473− _myCamera.setOrientation(glm::normalize(glmExtractRotation(hmdWorldMat)));
2474− _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2475− myAvatar->getWorldOrientation() * boomOffset);
2553+
2554+ if (!_thirdPersonHMDCameraBoomValid) {
2555+ const glm::vec3 CAMERA_OFFSET = glm::vec3(0.0f, 0.0f, 0.7f);
2556+ _thirdPersonHMDCameraBoom = cancelOutRollAndPitch(myAvatar->getHMDSensorOrientation()) * CAMERA_OFFSET;
2557+ _thirdPersonHMDCameraBoomValid = true;
2558+ }
2559+
2560+ glm::mat4 thirdPersonCameraSensorToWorldMatrix = myAvatar->getSensorToWorldMatrix();
2561+
2562+ const glm::vec3 cameraPos = myAvatar->getHMDSensorPosition() + _thirdPersonHMDCameraBoom * myAvatar->getBoomLength();
2563+ glm::mat4 sensorCameraMat = createMatFromQuatAndPos(myAvatar->getHMDSensorOrientation(), cameraPos);
2564+ glm::mat4 worldCameraMat = thirdPersonCameraSensorToWorldMatrix * sensorCameraMat;
2565+
2566+ _myCamera.setOrientation(glm::normalize(glmExtractRotation(worldCameraMat)));
2567+ _myCamera.setPosition(extractTranslation(worldCameraMat));
24762568 }
24772569 else {
2570+ _thirdPersonHMDCameraBoomValid = false;
2571+
24782572 _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
24792573 if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
24802574 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
@@ -2487,6 +2581,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 6 unmodified lines
24872581 }
24882582 }
24892583 else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2584+ _thirdPersonHMDCameraBoomValid= false;
24902585 if (isHMDMode()) {
24912586 auto mirrorBodyOrientation = myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
24922587
@@ -2521,6 +2616,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 28 unmodified lines
25212616 renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
25222617 }
25232618 else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) {
2619+ _thirdPersonHMDCameraBoomValid= false;
25242620 EntityItemPointer cameraEntity = _myCamera.getCameraEntityPointer();
25252621 if (cameraEntity != nullptr) {
25262622 if (isHMDMode()) {
@@ -2628,7 +2724,8 @@ void Application::showHelp() { · 101 unmodified lines
26282724 queryString.addQueryItem("defaultTab", defaultTab);
26292725 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
26302726 TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
2631− tablet->gotoWebScreen(INFO_HELP_PATH + "?" + queryString.toString());
2727+ tablet->gotoWebScreen(PathUtils::resourcesPath() + INFO_HELP_PATH + "?" + queryString.toString());
2728+ DependencyManager::get<HMDScriptingInterface>()->openTablet();
26322729 //InfoView::show(INFO_HELP_PATH, false, queryString.toString());
26332730 }
26342731
@@ -3884,12 +3981,18 @@ void Application::idle() { · 1249 unmodified lines
38843981 PROFILE_COUNTER_IF_CHANGED(app, "pendingProcessing", int, DependencyManager::get<StatTracker>()->getStat("PendingProcessing").toInt());
38853982 auto renderConfig = _renderEngine->getConfiguration();
38863983 PROFILE_COUNTER_IF_CHANGED(render, "gpuTime", float, (float)_gpuContext->getFrameTimerGPUAverage());
3984+ auto opaqueRangeTimer = renderConfig->getConfig("OpaqueRangeTimer");
3985+ auto linearDepth = renderConfig->getConfig("LinearDepth");
3986+ auto surfaceGeometry = renderConfig->getConfig("SurfaceGeometry");
3987+ auto renderDeferred = renderConfig->getConfig("RenderDeferred");
3988+ auto toneAndPostRangeTimer = renderConfig->getConfig("ToneAndPostRangeTimer");
3989+
38873990 PROFILE_COUNTER(render_detail, "gpuTimes", {
3888− { "OpaqueRangeTimer", renderConfig->getConfig("OpaqueRangeTimer")->property("gpuRunTime") },
3889− { "LinearDepth", renderConfig->getConfig("LinearDepth")->property("gpuRunTime") },
3890− { "SurfaceGeometry", renderConfig->getConfig("SurfaceGeometry")->property("gpuRunTime") },
3891− { "RenderDeferred", renderConfig->getConfig("RenderDeferred")->property("gpuRunTime") },
3892− { "ToneAndPostRangeTimer", renderConfig->getConfig("ToneAndPostRangeTimer")->property("gpuRunTime") }
3991+ { "OpaqueRangeTimer", opaqueRangeTimer ? opaqueRangeTimer->property("gpuRunTime") : 0 },
3992+ { "LinearDepth", linearDepth ? linearDepth->property("gpuRunTime") : 0 },
3993+ { "SurfaceGeometry", surfaceGeometry ? surfaceGeometry->property("gpuRunTime") : 0 },
3994+ { "RenderDeferred", renderDeferred ? renderDeferred->property("gpuRunTime") : 0 },
3995+ { "ToneAndPostRangeTimer", toneAndPostRangeTimer ? toneAndPostRangeTimer->property("gpuRunTime") : 0 }
38933996 });
38943997
38953998 PROFILE_RANGE(app, __FUNCTION__);
@@ -4254,9 +4357,9 @@ void Application::init() { · 358 unmodified lines
42544357
42554358 // Make sure Login state is up to date
42564359 DependencyManager::get<DialogsManager>()->toggleLoginDialog();
4257−
4258− DependencyManager::get<DeferredLightingEffect>()->init();
4259−
4360+ if (!DISABLE_DEFERRED) {
4361+ DependencyManager::get<DeferredLightingEffect>()->init();
4362+ }
42604363 DependencyManager::get<AvatarManager>()->init();
42614364
42624365 _timerStart.start();
@@ -4331,8 +4434,9 @@ void Application::updateLOD(float deltaTime) const { · 68 unmodified lines
43314434 float presentTime = getActiveDisplayPlugin()->getAveragePresentTime();
43324435 float engineRunTime = (float)(_renderEngine->getConfiguration().get()->getCPURunTime());
43334436 float gpuTime = getGPUContext()->getFrameTimerGPUAverage();
4334− float maxRenderTime = glm::max(gpuTime, glm::max(presentTime, engineRunTime));
4335− DependencyManager::get<LODManager>()->autoAdjustLOD(maxRenderTime, deltaTime);
4437+ auto lodManager = DependencyManager::get<LODManager>();
4438+ lodManager->setRenderTimes(presentTime, engineRunTime, gpuTime);
4439+ lodManager->autoAdjustLOD(deltaTime);
43364440 } else {
43374441 DependencyManager::get<LODManager>()->resetLODAdjust();
43384442 }
@@ -5005,8 +5109,6 @@ void Application::update(float deltaTime) { · 666 unmodified lines
50055109 }
50065110 }
50075111
5008− PerformanceTimer perfTimer("misc");
5009−
50105112 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
50115113 PerformanceWarning warn(showWarnings, "Application::update()");
50125114
@@ -5015,11 +5117,13 @@ void Application::update(float deltaTime) { · 2 unmodified lines
50155117 // TODO: break these out into distinct perfTimers when they prove interesting
50165118 {
50175119 PROFILE_RANGE(app, "PickManager");
5120+ PerformanceTimer perfTimer("pickManager");
50185121 DependencyManager::get<PickManager>()->update();
50195122 }
50205123
50215124 {
50225125 PROFILE_RANGE(app, "PointerManager");
5126+ PerformanceTimer perfTimer("pointerManager");
50235127 DependencyManager::get<PointerManager>()->update();
50245128 }
50255129
@@ -5045,8 +5149,8 @@ void Application::update(float deltaTime) { · 19 unmodified lines
50455149 // Update my voxel servers with my current voxel query...
50465150 {
50475151 PROFILE_RANGE_EX(app, "QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount());
5048− QMutexLocker viewLocker(&_viewMutex);
50495152 PerformanceTimer perfTimer("queryOctree");
5153+ QMutexLocker viewLocker(&_viewMutex);
50505154 quint64 sinceLastQuery = now - _lastQueriedTime;
50515155 const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND;
50525156 bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY;
@@ -5082,12 +5186,14 @@ void Application::update(float deltaTime) { · 29 unmodified lines
50825186 }
50835187 }
50845188
5085− avatarManager->postUpdate(deltaTime, getMain3DScene());
5086−
5087−
50885189 {
5089− PROFILE_RANGE_EX(app, "PreRenderLambdas", 0xffff0000, (uint64_t)0);
5190+ PerformanceTimer perfTimer("avatarManager/postUpdate");
5191+ avatarManager->postUpdate(deltaTime, getMain3DScene());
5192+ }
50905193
5194+ {
5195+ PROFILE_RANGE_EX(app, "PostUpdateLambdas", 0xffff0000, (uint64_t)0);
5196+ PerformanceTimer perfTimer("postUpdateLambdas");
50915197 std::unique_lock<std::mutex> guard(_postUpdateLambdasLock);
50925198 for (auto& iter : _postUpdateLambdas) {
50935199 iter.second();
@@ -5095,7 +5201,9 @@ void Application::update(float deltaTime) { · 1 unmodified line
50955201 _postUpdateLambdas.clear();
50965202 }
50975203
5098− editRenderArgs([this](AppRenderArgs& appRenderArgs) {
5204+
5205+ editRenderArgs([this, deltaTime](AppRenderArgs& appRenderArgs) {
5206+ PerformanceTimer perfTimer("editRenderArgs");
50995207 appRenderArgs._headPose= getHMDSensorPose();
51005208
51015209 auto myAvatar = getMyAvatar();
@@ -5141,7 +5249,7 @@ void Application::update(float deltaTime) { · 39 unmodified lines
51415249 resizeGL();
51425250 }
51435251
5144− this->updateCamera(appRenderArgs._renderArgs);
5252+ this->updateCamera(appRenderArgs._renderArgs, deltaTime);
51455253 appRenderArgs._eyeToWorld = _myCamera.getTransform();
51465254 appRenderArgs._isStereo = false;
51475255
@@ -5209,12 +5317,20 @@ void Application::update(float deltaTime) { · 61 unmodified lines
52095317 }
52105318 });
52115319
5212− AnimDebugDraw::getInstance().update();
5320+ {
5321+ PerformanceTimer perfTimer("limitless");
5322+ AnimDebugDraw::getInstance().update();
5323+ }
52135324
5214− DependencyManager::get<LimitlessVoiceRecognitionScriptingInterface>()->update();
5325+ {
5326+ PerformanceTimer perfTimer("limitless");
5327+ DependencyManager::get<LimitlessVoiceRecognitionScriptingInterface>()->update();
5328+ }
52155329
5216− // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over
5217− getMain3DScene()->enqueueFrame();
5330+ { // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over
5331+ PerformanceTimer perfTimer("enqueueFrame");
5332+ getMain3DScene()->enqueueFrame();
5333+ }
52185334 }
52195335
52205336 void Application::sendAvatarViewFrustum() {
@@ -5435,7 +5551,7 @@ void Application::clearDomainOctreeDetails() { · 214 unmodified lines
54355551
54365552 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
54375553
5438− skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
5554+ skyStage->setBackgroundMode(graphics::SunSkyStage::SKY_DEFAULT);
54395555
54405556 DependencyManager::get<AnimationCache>()->clearUnusedResources();
54415557 DependencyManager::get<ModelCache>()->clearUnusedResources();
@@ -5722,10 +5838,13 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 280 unmodified lines
57225838 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
57235839 LocationScriptingInterface::locationSetter);
57245840
5841+#if !defined(Q_OS_ANDROID)
57255842 scriptEngine->registerFunction("OverlayWebWindow", QmlWebWindowClass::constructor);
5843+#endif
57265844 scriptEngine->registerFunction("OverlayWindow", QmlWindowClass::constructor);
57275845
57285846 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
5847+ scriptEngine->registerGlobalObject("DesktopPreviewProvider", DependencyManager::get<DesktopPreviewProvider>().data());
57295848 scriptEngine->registerGlobalObject("Stats", Stats::getInstance());
57305849 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
57315850 scriptEngine->registerGlobalObject("Snapshot", DependencyManager::get<Snapshot>().data());
@@ -5745,10 +5864,11 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 13 unmodified lines
57455864 scriptEngine->registerGlobalObject("ModelCache", DependencyManager::get<ModelCache>().data());
57465865 scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
57475866
5748− scriptEngine->registerGlobalObject("Account", GlobalServicesScriptingInterface::getInstance());
57495867 scriptEngine->registerGlobalObject("DialogsManager", _dialogsManagerScriptingInterface);
57505868
5751− scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance());
5869+ scriptEngine->registerGlobalObject("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
5870+ scriptEngine->registerGlobalObject("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
5871+ scriptEngine->registerGlobalObject("AccountServices", AccountServicesScriptingInterface::getInstance());
57525872 qScriptRegisterMetaType(scriptEngine.data(), DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue);
57535873
57545874 scriptEngine->registerGlobalObject("FaceTracker", DependencyManager::get<DdeFaceTracker>().data());
@@ -6148,7 +6268,7 @@ void Application::showAssetServerWidget(QString filePath) { · 393 unmodified lines
61486268 if (!hmd->getShouldShowTablet() && !isHMDMode()) {
61496269 DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
61506270 } else {
6151− static const QUrl url("hifi/dialogs/TabletAssetServer.qml");
6271+ static const QUrl url("../dialogs/TabletAssetServer.qml");
61526272 tablet->pushOntoStack(url);
61536273 }
61546274 }
@@ -6777,6 +6897,15 @@ void Application::loadAddAvatarBookmarkDialog() const { · 622 unmodified lines
67776897 avatarBookmarks->addBookmark();
67786898 }
67796899
6900+void Application::loadAvatarBrowser() const {
6901+ auto tablet = dynamic_cast<TabletProxy*>(DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"));
6902+ // construct the url to the marketplace item
6903+ QString url = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/marketplace?category=avatars";
6904+ QString MARKETPLACES_INJECT_SCRIPT_PATH = "file:///" + qApp->applicationDirPath() + "/scripts/system/html/js/marketplacesInject.js";
6905+ tablet->gotoWebScreen(url, MARKETPLACES_INJECT_SCRIPT_PATH);
6906+ DependencyManager::get<HMDScriptingInterface>()->openTablet();
6907+}
6908+
67806909 void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) {
67816910 postLambdaEvent([notify, includeAnimated, aspectRatio, this] {
67826911 // Get a screenshot and save it
@@ -6794,7 +6923,8 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa · 11 unmodified lines
67946923
67956924 void Application::takeSecondaryCameraSnapshot() {
67966925 postLambdaEvent([this] {
6797− Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot());
6926+ QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot());
6927+ emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);
67986928 });
67996929 }
68006930
@@ -7358,11 +7488,13 @@ void Application::updateThreadPoolCount() const { · 557 unmodified lines
73587488 }
73597489
73607490 void Application::updateSystemTabletMode() {
7361− qApp->setProperty(hifi::properties::HMD, isHMDMode());
7362− if (isHMDMode()) {
7363− DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getHmdTabletBecomesToolbarSetting());
7364− } else {
7365− DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getDesktopTabletBecomesToolbarSetting());
7491+ if (_settingsLoaded) {
7492+ qApp->setProperty(hifi::properties::HMD, isHMDMode());
7493+ if (isHMDMode()) {
7494+ DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getHmdTabletBecomesToolbarSetting());
7495+ } else {
7496+ DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getDesktopTabletBecomesToolbarSetting());
7497+ }
73667498 }
73677499 }
73687500