History

Merge branch 'master' into midi

burtsloane committed 9 years ago

Commit d4ae2982 parents a960ea5 4a3e3cf783 files · +30471 −12950Browse files

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

Unified · Split

interface/src/Application.cpp+662−423
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <QtCore/QCommandLineParser>
2626 #include <QtCore/QMimeData>
2727 #include <QtCore/QThreadPool>
28+#include <QtConcurrent/QtConcurrentRun>
2829
2930 #include <QtGui/QScreen>
3031 #include <QtGui/QWindow>
@@ -37,8 +38,6 @@ · 6 unmodified lines
3738 #include <QtQml/QQmlEngine>
3839 #include <QtQuick/QQuickWindow>
3940
40−#include <QtWebEngineWidgets/QWebEngineProfile>
41−
4241 #include <QtWidgets/QDesktopWidget>
4342 #include <QtWidgets/QMessageBox>
4443
@@ -50,6 +49,7 @@ · 5 unmodified lines
5049
5150 #include <gl/QOpenGLContextWrapper.h>
5251
52+#include <shared/QtHelpers.h>
5353 #include <shared/GlobalAppProperties.h>
5454 #include <StatTracker.h>
5555 #include <Trace.h>
@@ -70,6 +70,7 @@ · 14 unmodified lines
7070 #include <EntityScriptClient.h>
7171 #include <EntityScriptServerLogClient.h>
7272 #include <EntityScriptingInterface.h>
73+#include <HoverOverlayInterface.h>
7374 #include <ErrorDialog.h>
7475 #include <FileScriptingInterface.h>
7576 #include <Finally.h>
@@ -89,6 +90,7 @@ · 13 unmodified lines
8990 #include <UserActivityLoggerScriptingInterface.h>
9091 #include <LogHandler.h>
9192 #include "LocationBookmarks.h"
93+#include <LocationScriptingInterface.h>
9294 #include <MainWindow.h>
9395 #include <MappingRequest.h>
9496 #include <MessagesClient.h>
@@ -99,8 +101,8 @@ · 4 unmodified lines
99101 #include <OctalCode.h>
100102 #include <OctreeSceneStats.h>
101103 #include <OffscreenUi.h>
102−#include <gl/OffscreenQmlSurfaceCache.h>
103104 #include <gl/OffscreenGLCanvas.h>
105+#include <ui/OffscreenQmlSurfaceCache.h>
104106 #include <PathUtils.h>
105107 #include <PerfStat.h>
106108 #include <PhysicsEngine.h>
@@ -109,13 +111,12 @@ · 2 unmodified lines
109111 #include <plugins/PluginManager.h>
110112 #include <plugins/PluginUtils.h>
111113 #include <plugins/SteamClientPlugin.h>
114+#include <plugins/InputConfiguration.h>
112115 #include <RecordingScriptingInterface.h>
113116 #include <RenderableWebEntityItem.h>
114−#include <RenderShadowTask.h>
115−#include <render/RenderFetchCullSortTask.h>
116−#include <RenderDeferredTask.h>
117−#include <RenderForwardTask.h>
117+#include <UpdateSceneTask.h>
118118 #include <RenderViewTask.h>
119+#include <SecondaryCamera.h>
119120 #include <ResourceCache.h>
120121 #include <ResourceRequest.h>
121122 #include <SandboxUtils.h>
@@ -123,7 +124,8 @@ · 1 unmodified line
123124 #include <ScriptEngines.h>
124125 #include <ScriptCache.h>
125126 #include <SoundCache.h>
126−#include <TabletScriptingInterface.h>
127+#include <ui/TabletScriptingInterface.h>
128+#include <ui/ToolbarScriptingInterface.h>
127129 #include <Tooltip.h>
128130 #include <udt/PacketHeaders.h>
129131 #include <UserActivityLogger.h>
@@ -144,32 +146,30 @@ · 14 unmodified lines
144146 #include "avatar/MyHead.h"
145147 #include "CrashHandler.h"
146148 #include "devices/DdeFaceTracker.h"
147−#include "devices/Leapmotion.h"
148149 #include "DiscoverabilityManager.h"
149150 #include "GLCanvas.h"
150151 #include "InterfaceDynamicFactory.h"
151152 #include "InterfaceLogging.h"
152153 #include "LODManager.h"
153154 #include "ModelPackager.h"
155+#include "scripting/Audio.h"
154156 #include "networking/CloseEventSender.h"
155157 #include "scripting/TestScriptingInterface.h"
156158 #include "scripting/AccountScriptingInterface.h"
157159 #include "scripting/AssetMappingsScriptingInterface.h"
158−#include "scripting/AudioDeviceScriptingInterface.h"
159160 #include "scripting/ClipboardScriptingInterface.h"
160161 #include "scripting/DesktopScriptingInterface.h"
161162 #include "scripting/GlobalServicesScriptingInterface.h"
162163 #include "scripting/HMDScriptingInterface.h"
163−#include "scripting/LocationScriptingInterface.h"
164164 #include "scripting/MenuScriptingInterface.h"
165165 #include "scripting/SettingsScriptingInterface.h"
166166 #include "scripting/WindowScriptingInterface.h"
167167 #include "scripting/ControllerScriptingInterface.h"
168−#include "scripting/ToolbarScriptingInterface.h"
169168 #include "scripting/RatesScriptingInterface.h"
170169 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
171170 #include "SpeechRecognizer.h"
172171 #endif
172+#include "ui/ResourceImageItem.h"
173173 #include "ui/AddressBarDialog.h"
174174 #include "ui/AvatarInputs.h"
175175 #include "ui/DialogsManager.h"
@@ -214,7 +214,7 @@ static QTimer pingTimer; · 38 unmodified lines
214214
215215 static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
216216
217−// For processing on QThreadPool, we target a number of threads after reserving some
217+// For processing on QThreadPool, we target a number of threads after reserving some
218218 // based on how many are being consumed by the application and the display plugin. However,
219219 // we will never drop below the 'min' value
220220 static const int MIN_PROCESSING_THREAD_POOL_SIZE = 1;
@@ -252,6 +252,8 @@ static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com"; · 31 unmodified lines
252252 static const int INTERVAL_TO_CHECK_HMD_WORN_STATUS = 500; // milliseconds
253253 static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop";
254254
255+static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
256+
255257 const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
256258 { SVO_EXTENSION, &Application::importSVOFromURL },
257259 { SVO_JSON_EXTENSION, &Application::importSVOFromURL },
@@ -442,18 +444,62 @@ static const QString STATE_ADVANCED_MOVEMENT_CONTROLS = "AdvancedMovement"; · 184 unmodified lines
442444 static const QString STATE_GROUNDED = "Grounded";
443445 static const QString STATE_NAV_FOCUSED = "NavigationFocused";
444446
447+// Statically provided display and input plugins
448+extern DisplayPluginList getDisplayPlugins();
449+extern InputPluginList getInputPlugins();
450+extern void saveInputPluginSettings(const InputPluginList& plugins);
451+
445452 bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
446453 const char** constArgv = const_cast<const char**>(argv);
454+
455+ // HRS: I could not figure out how to move these any earlier in startup, so when using this option, be sure to also supply
456+ // --allowMultipleInstances
457+ auto reportAndQuit = [&](const char* commandSwitch, std::function<void(FILE* fp)> report) {
458+ const char* reportfile = getCmdOption(argc, constArgv, commandSwitch);
459+ // Reports to the specified file, because stdout is set up to be captured for logging.
460+ if (reportfile) {
461+ FILE* fp = fopen(reportfile, "w");
462+ if (fp) {
463+ report(fp);
464+ fclose(fp);
465+ if (!runningMarkerExisted) { // don't leave ours around
466+ RunningMarker runingMarker(RUNNING_MARKER_FILENAME);
467+ runingMarker.deleteRunningMarkerFile(); // happens in deleter, but making the side-effect explicit.
468+ }
469+ _exit(0);
470+ }
471+ }
472+ };
473+ reportAndQuit("--protocolVersion", [&](FILE* fp) {
474+ DependencyManager::set<AddressManager>();
475+ auto version = DependencyManager::get<AddressManager>()->protocolVersion();
476+ fputs(version.toLatin1().data(), fp);
477+ });
478+ reportAndQuit("--version", [&](FILE* fp) {
479+ fputs(BuildInfo::VERSION.toLatin1().data(), fp);
480+ });
481+
447482 const char* portStr = getCmdOption(argc, constArgv, "--listenPort");
448483 const int listenPort = portStr ? atoi(portStr) : INVALID_PORT;
449484
450485 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
451486 bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);
452487 bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt);
488+ // get dir to use for cache
489+ static const auto CACHE_SWITCH = "--cache";
490+ QString cacheDir = getCmdOption(argc, const_cast<const char**>(argv), CACHE_SWITCH);
491+ if (!cacheDir.isEmpty()) {
492+ qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir);
493+ }
453494
454495 Setting::init();
455496
456− if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
497+ // Tell the plugin manager about our statically linked plugins
498+ auto pluginManager = PluginManager::getInstance();
499+ pluginManager->setInputPluginProvider([] { return getInputPlugins(); });
500+ pluginManager->setDisplayPluginProvider([] { return getDisplayPlugins(); });
501+ pluginManager->setInputPluginSettingsPersister([](const InputPluginList& plugins) { saveInputPluginSettings(plugins); });
502+ if (auto steamClient = pluginManager->getSteamClientPlugin()) {
457503 steamClient->init();
458504 }
459505
@@ -513,6 +559,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 53 unmodified lines
513559 DependencyManager::set<HMDScriptingInterface>();
514560 DependencyManager::set<ResourceScriptingInterface>();
515561 DependencyManager::set<TabletScriptingInterface>();
562+ DependencyManager::set<InputConfiguration>();
516563 DependencyManager::set<ToolbarScriptingInterface>();
517564 DependencyManager::set<UserActivityLoggerScriptingInterface>();
518565 DependencyManager::set<AssetMappingsScriptingInterface>();
@@ -547,6 +594,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 28 unmodified lines
547594 DependencyManager::set<LocationBookmarks>();
548595 DependencyManager::set<Snapshot>();
549596 DependencyManager::set<CloseEventSender>();
597+ DependencyManager::set<ResourceManager>();
598+ DependencyManager::set<HoverOverlayInterface>();
550599
551600 return previousSessionCrashed;
552601 }
@@ -584,7 +633,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 31 unmodified lines
584633 _undoStackScriptingInterface(&_undoStack),
585634 _entitySimulation(new PhysicalEntitySimulation()),
586635 _physicsEngine(new PhysicsEngine(Vectors::ZERO)),
587− _entityClipboardRenderer(false, this, this),
588636 _entityClipboard(new EntityTree()),
589637 _lastQueriedTime(usecTimestampNow()),
590638 _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION),
@@ -687,9 +735,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 96 unmodified lines
687735 updateHeartbeat();
688736
689737 // setup a timer for domain-server check ins
690− QTimer* domainCheckInTimer = new QTimer(nodeList.data());
738+ QTimer* domainCheckInTimer = new QTimer(this);
691739 connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);
692740 domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
741+ connect(this, &QCoreApplication::aboutToQuit, [domainCheckInTimer] {
742+ domainCheckInTimer->stop();
743+ domainCheckInTimer->deleteLater();
744+ });
693745
694746
695747 auto audioIO = DependencyManager::get<AudioClient>();
@@ -717,9 +769,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 21 unmodified lines
717769 recorder->recordFrame(AUDIO_FRAME_TYPE, audio);
718770 }
719771 });
772+ audioIO->startThread();
720773
721− auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>();
722− connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
774+ auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface, scripting::Audio>();
723775 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
724776 connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);
725777 connect(audioIO.data(), &AudioClient::disconnected, audioScriptingInterface.data(), &AudioScriptingInterface::disconnected);
@@ -735,10 +787,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
735787 audioScriptingInterface->environmentMuted();
736788 }
737789 });
790+ connect(this, &Application::activeDisplayPluginChanged,
791+ reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged);
738792
739− audioIO->startThread();
740−
741− ResourceManager::init();
742793 // Make sure we don't time out during slow operations at startup
743794 updateHeartbeat();
744795
@@ -863,6 +914,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 118 unmodified lines
863914 }
864915 ResourceCache::setRequestLimit(concurrentDownloads);
865916
917+ // perhaps override the avatar url. Since we will test later for validity
918+ // we don't need to do so here.
919+ QString avatarURL = getCmdOption(argc, constArgv, "--avatarURL");
920+ _avatarOverrideUrl = QUrl::fromUserInput(avatarURL);
921+
922+ // If someone specifies both --avatarURL and --replaceAvatarURL,
923+ // the replaceAvatarURL wins. So only set the _overrideUrl if this
924+ // does have a non-empty string.
925+ QString replaceURL = getCmdOption(argc, constArgv, "--replaceAvatarURL");
926+ if (!replaceURL.isEmpty()) {
927+ _avatarOverrideUrl = QUrl::fromUserInput(replaceURL);
928+ _saveAvatarOverrideUrl = true;
929+ }
930+
866931 _glWidget = new GLCanvas();
867932 getApplicationCompositor().setRenderingWidget(_glWidget);
868933 _window->setCentralWidget(_glWidget);
@@ -893,58 +958,68 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 24 unmodified lines
893958 // Make sure we don't time out during slow operations at startup
894959 updateHeartbeat();
895960
896−
897− // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
898− // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
899− static const QString TESTER = "HIFI_TESTER";
900− auto gpuIdent = GPUIdent::getInstance();
901− auto glContextData = getGLContextData();
902− QJsonObject properties = {
903− { "version", applicationVersion() },
904− { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
905− { "previousSessionCrashed", _previousSessionCrashed },
906− { "previousSessionRuntime", sessionRunTime.get() },
907− { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
908− { "kernel_type", QSysInfo::kernelType() },
909− { "kernel_version", QSysInfo::kernelVersion() },
910− { "os_type", QSysInfo::productType() },
911− { "os_version", QSysInfo::productVersion() },
912− { "gpu_name", gpuIdent->getName() },
913− { "gpu_driver", gpuIdent->getDriver() },
914− { "gpu_memory", static_cast<qint64>(gpuIdent->getMemory()) },
915− { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) },
916− { "gl_version", glContextData["version"] },
917− { "gl_vender", glContextData["vendor"] },
918− { "gl_sl_version", glContextData["sl_version"] },
919− { "gl_renderer", glContextData["renderer"] },
920− { "ideal_thread_count", QThread::idealThreadCount() }
921− };
922− auto macVersion = QSysInfo::macVersion();
923− if (macVersion != QSysInfo::MV_None) {
924− properties["os_osx_version"] = QSysInfo::macVersion();
925− }
926− auto windowsVersion = QSysInfo::windowsVersion();
927− if (windowsVersion != QSysInfo::WV_None) {
928− properties["os_win_version"] = QSysInfo::windowsVersion();
929− }
930−
931− ProcessorInfo procInfo;
932− if (getProcessorInfo(procInfo)) {
933− properties["processor_core_count"] = procInfo.numProcessorCores;
934− properties["logical_processor_count"] = procInfo.numLogicalProcessors;
935− properties["processor_l1_cache_count"] = procInfo.numProcessorCachesL1;
936− properties["processor_l2_cache_count"] = procInfo.numProcessorCachesL2;
937− properties["processor_l3_cache_count"] = procInfo.numProcessorCachesL3;
938− }
939−
940− // add firstRun flag from settings to launch event
941961 Setting::Handle<bool> firstRun { Settings::firstRun, true };
942− properties["first_run"] = firstRun.get();
943−
944− // add the user's machine ID to the launch event
945− properties["machine_fingerprint"] = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
946962
947− UserActivityLogger::getInstance().logAction("launch", properties);
963+ // once the settings have been loaded, check if we need to flip the default for UserActivityLogger
964+ auto& userActivityLogger = UserActivityLogger::getInstance();
965+ if (!userActivityLogger.isDisabledSettingSet()) {
966+ // the user activity logger is opt-out for Interface
967+ // but it's defaulted to disabled for other targets
968+ // so we need to enable it here if it has never been disabled by the user
969+ userActivityLogger.disable(false);
970+ }
971+
972+ if (userActivityLogger.isEnabled()) {
973+ // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
974+ // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
975+ static const QString TESTER = "HIFI_TESTER";
976+ auto gpuIdent = GPUIdent::getInstance();
977+ auto glContextData = getGLContextData();
978+ QJsonObject properties = {
979+ { "version", applicationVersion() },
980+ { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
981+ { "previousSessionCrashed", _previousSessionCrashed },
982+ { "previousSessionRuntime", sessionRunTime.get() },
983+ { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
984+ { "kernel_type", QSysInfo::kernelType() },
985+ { "kernel_version", QSysInfo::kernelVersion() },
986+ { "os_type", QSysInfo::productType() },
987+ { "os_version", QSysInfo::productVersion() },
988+ { "gpu_name", gpuIdent->getName() },
989+ { "gpu_driver", gpuIdent->getDriver() },
990+ { "gpu_memory", static_cast<qint64>(gpuIdent->getMemory()) },
991+ { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) },
992+ { "gl_version", glContextData["version"] },
993+ { "gl_vender", glContextData["vendor"] },
994+ { "gl_sl_version", glContextData["sl_version"] },
995+ { "gl_renderer", glContextData["renderer"] },
996+ { "ideal_thread_count", QThread::idealThreadCount() }
997+ };
998+ auto macVersion = QSysInfo::macVersion();
999+ if (macVersion != QSysInfo::MV_None) {
1000+ properties["os_osx_version"] = QSysInfo::macVersion();
1001+ }
1002+ auto windowsVersion = QSysInfo::windowsVersion();
1003+ if (windowsVersion != QSysInfo::WV_None) {
1004+ properties["os_win_version"] = QSysInfo::windowsVersion();
1005+ }
1006+
1007+ ProcessorInfo procInfo;
1008+ if (getProcessorInfo(procInfo)) {
1009+ properties["processor_core_count"] = procInfo.numProcessorCores;
1010+ properties["logical_processor_count"] = procInfo.numLogicalProcessors;
1011+ properties["processor_l1_cache_count"] = procInfo.numProcessorCachesL1;
1012+ properties["processor_l2_cache_count"] = procInfo.numProcessorCachesL2;
1013+ properties["processor_l3_cache_count"] = procInfo.numProcessorCachesL3;
1014+ }
1015+
1016+ properties["first_run"] = firstRun.get();
1017+
1018+ // add the user's machine ID to the launch event
1019+ properties["machine_fingerprint"] = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
1020+
1021+ userActivityLogger.logAction("launch", properties);
1022+ }
9481023
9491024 // Tell our entity edit sender about our known jurisdictions
9501025 _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
@@ -959,7 +1034,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 8 unmodified lines
9591034 // Make sure we don't time out during slow operations at startup
9601035 updateHeartbeat();
9611036
962− connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
1037+ connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
9631038
9641039 // hook up bandwidth estimator
9651040 QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
@@ -1127,7 +1202,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 161 unmodified lines
11271202 // force the model the look at the correct directory (weird order of operations issue)
11281203 scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation());
11291204 // do this as late as possible so that all required subsystems are initialized
1130− scriptEngines->loadScripts();
1205+ // If we've overridden the default scripts location, just load default scripts
1206+ // otherwise, load 'em all
1207+
1208+ // we just want to see if --scripts was set, we've already parsed it and done
1209+ // the change in PathUtils. Rather than pass that in the constructor, lets just
1210+ // look (this could be debated)
1211+ QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH);
1212+ QDir defaultScriptsLocation(getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str()));
1213+ if (!defaultScriptsLocation.exists()) {
1214+ scriptEngines->loadDefaultScripts();
1215+ scriptEngines->defaultScriptsLocationOverridden(true);
1216+ } else {
1217+ scriptEngines->loadScripts();
1218+ }
1219+
11311220 // Make sure we don't time out during slow operations at startup
11321221 updateHeartbeat();
11331222
@@ -1142,15 +1231,26 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 8 unmodified lines
11421231 // Make sure we don't time out during slow operations at startup
11431232 updateHeartbeat();
11441233
1145− int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
1146− connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
1147− connect(&_settingsThread, SIGNAL(started()), &_settingsTimer, SLOT(start()));
1148− connect(&_settingsThread, SIGNAL(finished()), &_settingsTimer, SLOT(stop()));
1149− _settingsTimer.moveToThread(&_settingsThread);
1150− _settingsTimer.setSingleShot(false);
1151− _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL); // 10s, Qt::CoarseTimer acceptable
1152− _settingsThread.setPriority(QThread::LowestPriority);
1153− _settingsThread.start();
1234+
1235+ QTimer* settingsTimer = new QTimer();
1236+ moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
1237+ connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer]{
1238+ // Disconnect the signal from the save settings
1239+ QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
1240+ // Stop the settings timer
1241+ settingsTimer->stop();
1242+ // Delete it (this will trigger the thread destruction
1243+ settingsTimer->deleteLater();
1244+ // Mark the settings thread as finished, so we know we can safely save in the main application
1245+ // shutdown code
1246+ _settingsGuard.trigger();
1247+ });
1248+
1249+ int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
1250+ settingsTimer->setSingleShot(false);
1251+ settingsTimer->setInterval(SAVE_SETTINGS_INTERVAL); // 10s, Qt::CoarseTimer acceptable
1252+ QObject::connect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
1253+ }, QThread::LowestPriority);
11541254
11551255 if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) {
11561256 getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); // So that camera doesn't auto-switch to third person.
@@ -1252,7 +1352,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 95 unmodified lines
12521352 // Add periodic checks to send user activity data
12531353 static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000;
12541354 static int NEARBY_AVATAR_RADIUS_METERS = 10;
1255−
1355+
12561356 // setup the stats interval depending on if the 1s faster hearbeat was requested
12571357 static const QString FAST_STATS_ARG = "--fast-heartbeat";
12581358 static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000;
@@ -1375,6 +1475,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 116 unmodified lines
13751475 properties["atp_mapping_requests"] = atpMappingRequests;
13761476
13771477 properties["throttled"] = _displayPlugin ? _displayPlugin->isThrottled() : false;
1478+
1479+ QJsonObject bytesDownloaded;
1480+ bytesDownloaded["atp"] = statTracker->getStat(STAT_ATP_RESOURCE_TOTAL_BYTES).toInt();
1481+ bytesDownloaded["http"] = statTracker->getStat(STAT_HTTP_RESOURCE_TOTAL_BYTES).toInt();
1482+ bytesDownloaded["file"] = statTracker->getStat(STAT_FILE_RESOURCE_TOTAL_BYTES).toInt();
1483+ bytesDownloaded["total"] = bytesDownloaded["atp"].toInt() + bytesDownloaded["http"].toInt()
1484+ + bytesDownloaded["file"].toInt();
1485+ properties["bytesDownloaded"] = bytesDownloaded;
13781486
13791487 auto myAvatar = getMyAvatar();
13801488 glm::vec3 avatarPosition = myAvatar->getPosition();
@@ -1402,10 +1510,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 21 unmodified lines
14021510
14031511 _autoSwitchDisplayModeSupportedHMDPlugin = nullptr;
14041512 foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
1405− if (displayPlugin->isHmd() &&
1513+ if (displayPlugin->isHmd() &&
14061514 displayPlugin->getSupportsAutoSwitch()) {
14071515 _autoSwitchDisplayModeSupportedHMDPlugin = displayPlugin;
1408− _autoSwitchDisplayModeSupportedHMDPluginName =
1516+ _autoSwitchDisplayModeSupportedHMDPluginName =
14091517 _autoSwitchDisplayModeSupportedHMDPlugin->getName();
14101518 _previousHMDWornStatus =
14111519 _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible();
@@ -1453,7 +1561,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 41 unmodified lines
14531561 });
14541562 sendStatsTimer->start();
14551563
1456−
14571564 // Periodically check for count of nearby avatars
14581565 static int lastCountOfNearbyAvatars = -1;
14591566 QTimer* checkNearbyAvatarsTimer = new QTimer(this);
@@ -1579,7 +1686,7 @@ QString Application::getUserAgent() { · 119 unmodified lines
15791686 if (QThread::currentThread() != thread()) {
15801687 QString userAgent;
15811688
1582− QMetaObject::invokeMethod(this, "getUserAgent", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, userAgent));
1689+ BLOCKING_INVOKE_METHOD(this, "getUserAgent", Q_RETURN_ARG(QString, userAgent));
15831690
15841691 return userAgent;
15851692 }
@@ -1611,12 +1718,10 @@ QString Application::getUserAgent() { · 25 unmodified lines
16111718 return userAgent;
16121719 }
16131720
1614−void Application::toggleTabletUI() const {
1721+void Application::toggleTabletUI(bool shouldOpen) const {
16151722 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
16161723 auto hmd = DependencyManager::get<HMDScriptingInterface>();
1617− TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
1618− bool messageOpen = tablet->isMessageDialogOpen();
1619− if (!messageOpen || (messageOpen && !hmd->getShouldShowTablet())) {
1724+ if (!(shouldOpen && hmd->getShouldShowTablet())) {
16201725 auto HMD = DependencyManager::get<HMDScriptingInterface>();
16211726 HMD->toggleShouldShowTablet();
16221727 }
@@ -1648,7 +1753,7 @@ void Application::updateHeartbeat() const { · 25 unmodified lines
16481753 static_cast<DeadlockWatchdogThread*>(_deadlockWatchdogThread)->updateHeartbeat();
16491754 }
16501755
1651−void Application::aboutToQuit() {
1756+void Application::onAboutToQuit() {
16521757 emit beforeAboutToQuit();
16531758
16541759 foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
@@ -1658,7 +1763,7 @@ void Application::aboutToQuit() { · 3 unmodified lines
16581763 }
16591764
16601765 getActiveDisplayPlugin()->deactivate();
1661− if (_autoSwitchDisplayModeSupportedHMDPlugin
1766+ if (_autoSwitchDisplayModeSupportedHMDPlugin
16621767 && _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {
16631768 _autoSwitchDisplayModeSupportedHMDPlugin->endSession();
16641769 }
@@ -1727,8 +1832,8 @@ void Application::cleanupBeforeQuit() { · 62 unmodified lines
17271832
17281833 // Cleanup all overlays after the scripts, as scripts might add more
17291834 _overlays.cleanupAllOverlays();
1730− // The cleanup process enqueues the transactions but does not process them. Calling this here will force the actual
1731− // removal of the items.
1835+ // The cleanup process enqueues the transactions but does not process them. Calling this here will force the actual
1836+ // removal of the items.
17321837 // See https://highfidelity.fogbugz.com/f/cases/5328
17331838 _main3DScene->processTransactionQueue();
17341839
@@ -1737,11 +1842,13 @@ void Application::cleanupBeforeQuit() { · 2 unmodified lines
17371842 locationUpdateTimer.stop();
17381843 identityPacketTimer.stop();
17391844 pingTimer.stop();
1740− QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
17411845
1742− // save state
1743− _settingsThread.quit();
1744− saveSettings();
1846+ // Wait for the settings thread to shut down, and save the settings one last time when it's safe
1847+ if (_settingsGuard.wait()) {
1848+ // save state
1849+ saveSettings();
1850+ }
1851+
17451852 _window->saveGeometry();
17461853
17471854 // Destroy third party processes after scripts have finished using them.
@@ -1753,6 +1860,8 @@ void Application::cleanupBeforeQuit() { · 5 unmodified lines
17531860 #endif
17541861
17551862 // stop QML
1863+ DependencyManager::destroy<TabletScriptingInterface>();
1864+ DependencyManager::destroy<ToolbarScriptingInterface>();
17561865 DependencyManager::destroy<OffscreenUi>();
17571866
17581867 DependencyManager::destroy<OffscreenQmlSurfaceCache>();
@@ -1763,8 +1872,7 @@ void Application::cleanupBeforeQuit() { · 4 unmodified lines
17631872
17641873 // FIXME: something else is holding a reference to AudioClient,
17651874 // so it must be explicitly synchronously stopped here
1766− QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
1767− "cleanupBeforeQuit", Qt::BlockingQueuedConnection);
1875+ DependencyManager::get<AudioClient>()->cleanupBeforeQuit();
17681876
17691877 // destroy Audio so it and its threads have a chance to go down safely
17701878 // this must happen after QML, as there are unexplained audio crashes originating in qtwebengine
@@ -1814,13 +1922,11 @@ Application::~Application() { · 43 unmodified lines
18141922 DependencyManager::destroy<SoundCache>();
18151923 DependencyManager::destroy<OctreeStatsProvider>();
18161924
1817− ResourceManager::cleanup();
1925+ DependencyManager::get<ResourceManager>()->cleanup();
18181926
18191927 // remove the NodeList from the DependencyManager
18201928 DependencyManager::destroy<NodeList>();
18211929
1822− Leapmotion::destroy();
1823−
18241930 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
18251931 steamClient->shutdown();
18261932 }
@@ -1879,6 +1985,8 @@ void Application::initializeGL() { · 52 unmodified lines
18791985 render::CullFunctor cullFunctor = LODManager::shouldRender;
18801986 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
18811987 bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
1988+ _renderEngine->addJob<UpdateSceneTask>("UpdateScene");
1989+ _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor);
18821990 _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
18831991 _renderEngine->load();
18841992 _renderEngine->registerScene(_main3DScene);
@@ -1926,6 +2034,7 @@ void Application::initializeUi() { · 41 unmodified lines
19262034 LoginDialog::registerType();
19272035 Tooltip::registerType();
19282036 UpdateDialog::registerType();
2037+ qmlRegisterType<ResourceImageItem>("Hifi", 1, 0, "ResourceImageItem");
19292038 qmlRegisterType<Preference>("Hifi", 1, 0, "Preference");
19302039
19312040 auto offscreenUi = DependencyManager::get<OffscreenUi>();
@@ -1993,7 +2102,6 @@ void Application::initializeUi() { · 61 unmodified lines
19932102 surfaceContext->setContextProperty("Stats", Stats::getInstance());
19942103 surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
19952104 surfaceContext->setContextProperty("ScriptDiscoveryService", DependencyManager::get<ScriptEngines>().data());
1996− surfaceContext->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance());
19972105 surfaceContext->setContextProperty("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
19982106 surfaceContext->setContextProperty("LocationBookmarks", DependencyManager::get<LocationBookmarks>().data());
19992107
@@ -2002,6 +2110,7 @@ void Application::initializeUi() { · 2 unmodified lines
20022110 surfaceContext->setContextProperty("TextureCache", DependencyManager::get<TextureCache>().data());
20032111 surfaceContext->setContextProperty("ModelCache", DependencyManager::get<ModelCache>().data());
20042112 surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data());
2113+ surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
20052114
20062115 surfaceContext->setContextProperty("Account", AccountScriptingInterface::getInstance());
20072116 surfaceContext->setContextProperty("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
@@ -2021,6 +2130,7 @@ void Application::initializeUi() { · 13 unmodified lines
20212130 surfaceContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
20222131
20232132 surfaceContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance());
2133+ surfaceContext->setContextProperty("HoverOverlay", DependencyManager::get<HoverOverlayInterface>().data());
20242134
20252135 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
20262136 surfaceContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get()));
@@ -2086,48 +2196,74 @@ void Application::paintGL() { · 59 unmodified lines
20862196 return;
20872197 }
20882198
2089− auto displayPlugin = getActiveDisplayPlugin();
2090− // FIXME not needed anymore?
2091− _offscreenContext->makeCurrent();
2199+ DisplayPluginPointer displayPlugin;
2200+ {
2201+ PROFILE_RANGE(render, "/getActiveDisplayPlugin");
2202+ displayPlugin = getActiveDisplayPlugin();
2203+ }
20922204
2093− // If a display plugin loses it's underlying support, it
2094− // needs to be able to signal us to not use it
2095− if (!displayPlugin->beginFrameRender(_frameCount)) {
2096− _inPaint = false;
2097− updateDisplayMode();
2098− return;
2205+ {
2206+ PROFILE_RANGE(render, "/offscreenMakeCurrent");
2207+ // FIXME not needed anymore?
2208+ _offscreenContext->makeCurrent();
2209+ }
2210+
2211+ {
2212+ PROFILE_RANGE(render, "/pluginBeginFrameRender");
2213+ // If a display plugin loses it's underlying support, it
2214+ // needs to be able to signal us to not use it
2215+ if (!displayPlugin->beginFrameRender(_frameCount)) {
2216+ _inPaint = false;
2217+ updateDisplayMode();
2218+ return;
2219+ }
20992220 }
21002221
21012222 // update the avatar with a fresh HMD pose
2102− getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose());
2223+ {
2224+ PROFILE_RANGE(render, "/updateAvatar");
2225+ getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose());
2226+ }
21032227
21042228 auto lodManager = DependencyManager::get<LODManager>();
21052229
2230+ RenderArgs renderArgs;
21062231 {
2107− QMutexLocker viewLocker(&_viewMutex);
2108− _viewFrustum.calculate();
2232+ PROFILE_RANGE(render, "/buildFrustrumAndArgs");
2233+ {
2234+ QMutexLocker viewLocker(&_viewMutex);
2235+ _viewFrustum.calculate();
2236+ }
2237+ renderArgs = RenderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(),
2238+ lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
2239+ RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
2240+ {
2241+ QMutexLocker viewLocker(&_viewMutex);
2242+ renderArgs.setViewFrustum(_viewFrustum);
2243+ }
21092244 }
2110− RenderArgs renderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(),
2111− lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
2112− RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
2245+
21132246 {
2114− QMutexLocker viewLocker(&_viewMutex);
2115− renderArgs.setViewFrustum(_viewFrustum);
2247+ PROFILE_RANGE(render, "/resizeGL");
2248+ PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
2249+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2250+ PerformanceWarning warn(showWarnings, "Application::paintGL()");
2251+ resizeGL();
21162252 }
21172253
2118− PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
2119− bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2120− PerformanceWarning warn(showWarnings, "Application::paintGL()");
2121− resizeGL();
2254+ {
2255+ PROFILE_RANGE(render, "/gpuContextReset");
2256+ _gpuContext->beginFrame(getHMDSensorPose());
2257+ // Reset the gpu::Context Stages
2258+ // Back to the default framebuffer;
2259+ gpu::doInBatch(_gpuContext, [&](gpu::Batch& batch) {
2260+ batch.resetStages();
2261+ });
2262+ }
21222263
2123− _gpuContext->beginFrame(getHMDSensorPose());
2124− // Reset the gpu::Context Stages
2125− // Back to the default framebuffer;
2126− gpu::doInBatch(_gpuContext, [&](gpu::Batch& batch) {
2127− batch.resetStages();
2128− });
21292264
21302265 {
2266+ PROFILE_RANGE(render, "/renderOverlay");
21312267 PerformanceTimer perfTimer("renderOverlay");
21322268 // NOTE: There is no batch associated with this renderArgs
21332269 // the ApplicationOverlay class assumes it's viewport is setup to be the device size
@@ -2138,114 +2274,127 @@ void Application::paintGL() { · 4 unmodified lines
21382274
21392275 glm::vec3 boomOffset;
21402276 {
2141− PerformanceTimer perfTimer("CameraUpdates");
2277+ PROFILE_RANGE(render, "/updateCamera");
2278+ {
2279+ PerformanceTimer perfTimer("CameraUpdates");
21422280
2143− auto myAvatar = getMyAvatar();
2144− boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
2281+ auto myAvatar = getMyAvatar();
2282+ boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
21452283
2146− if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2147− Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
2148− Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
2149− cameraMenuChanged();
2150− }
2284+ if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2285+ Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
2286+ Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
2287+ cameraMenuChanged();
2288+ }
21512289
2152− // The render mode is default or mirror if the camera is in mirror mode, assigned further below
2153− renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
2290+ // The render mode is default or mirror if the camera is in mirror mode, assigned further below
2291+ renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
21542292
2155− // Always use the default eye position, not the actual head eye position.
2156− // Using the latter will cause the camera to wobble with idle animations,
2157− // or with changes from the face tracker
2158− if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
2159− if (isHMDMode()) {
2160− mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2161− _myCamera.setPosition(extractTranslation(camMat));
2162− _myCamera.setOrientation(glm::quat_cast(camMat));
2163− } else {
2164− _myCamera.setPosition(myAvatar->getDefaultEyePosition());
2165− _myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation());
2166− }
2167− } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2168− if (isHMDMode()) {
2169− auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2170− _myCamera.setOrientation(glm::normalize(glm::quat_cast(hmdWorldMat)));
2171− _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2172− myAvatar->getOrientation() * boomOffset);
2173− } else {
2174− _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
2175− if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
2176− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2177− + _myCamera.getOrientation() * boomOffset);
2293+ // Always use the default eye position, not the actual head eye position.
2294+ // Using the latter will cause the camera to wobble with idle animations,
2295+ // or with changes from the face tracker
2296+ if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
2297+ if (isHMDMode()) {
2298+ mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2299+ _myCamera.setPosition(extractTranslation(camMat));
2300+ _myCamera.setOrientation(glm::quat_cast(camMat));
21782301 } else {
2179− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2180− + myAvatar->getOrientation() * boomOffset);
2302+ _myCamera.setPosition(myAvatar->getDefaultEyePosition());
2303+ _myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation());
21812304 }
2182− }
2183− } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2184− if (isHMDMode()) {
2185− auto mirrorBodyOrientation = myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
2186−
2187− glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2188− // Mirror HMD yaw and roll
2189− glm::vec3 mirrorHmdEulers = glm::eulerAngles(hmdRotation);
2190− mirrorHmdEulers.y = -mirrorHmdEulers.y;
2191− mirrorHmdEulers.z = -mirrorHmdEulers.z;
2192− glm::quat mirrorHmdRotation = glm::quat(mirrorHmdEulers);
2305+ } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2306+ if (isHMDMode()) {
2307+ auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2308+ _myCamera.setOrientation(glm::normalize(glm::quat_cast(hmdWorldMat)));
2309+ _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2310+ myAvatar->getOrientation() * boomOffset);
2311+ } else {
2312+ _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
2313+ if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
2314+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2315+ + _myCamera.getOrientation() * boomOffset);
2316+ } else {
2317+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2318+ + myAvatar->getOrientation() * boomOffset);
2319+ }
2320+ }
2321+ } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2322+ if (isHMDMode()) {
2323+ auto mirrorBodyOrientation = myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
21932324
2194− glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation;
2325+ glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2326+ // Mirror HMD yaw and roll
2327+ glm::vec3 mirrorHmdEulers = glm::eulerAngles(hmdRotation);
2328+ mirrorHmdEulers.y = -mirrorHmdEulers.y;
2329+ mirrorHmdEulers.z = -mirrorHmdEulers.z;
2330+ glm::quat mirrorHmdRotation = glm::quat(mirrorHmdEulers);
21952331
2196− _myCamera.setOrientation(worldMirrorRotation);
2332+ glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation;
21972333
2198− glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2199− // Mirror HMD lateral offsets
2200− hmdOffset.x = -hmdOffset.x;
2334+ _myCamera.setOrientation(worldMirrorRotation);
22012335
2202− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2203− + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2204− + mirrorBodyOrientation * glm::vec3(0.0f, 0.0f, 1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
2205− + mirrorBodyOrientation * hmdOffset);
2206− } else {
2207− _myCamera.setOrientation(myAvatar->getWorldAlignedOrientation()
2208− * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
2209− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2210− + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2211− + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
2212− glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
2213− }
2214− renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
2215− } else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) {
2216− EntityItemPointer cameraEntity = _myCamera.getCameraEntityPointer();
2217− if (cameraEntity != nullptr) {
2218− if (isHMDMode()) {
2219− glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2220− _myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
22212336 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2222− _myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
2337+ // Mirror HMD lateral offsets
2338+ hmdOffset.x = -hmdOffset.x;
2339+
2340+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2341+ + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2342+ + mirrorBodyOrientation * glm::vec3(0.0f, 0.0f, 1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
2343+ + mirrorBodyOrientation * hmdOffset);
22232344 } else {
2224− _myCamera.setOrientation(cameraEntity->getRotation());
2225− _myCamera.setPosition(cameraEntity->getPosition());
2345+ _myCamera.setOrientation(myAvatar->getWorldAlignedOrientation()
2346+ * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
2347+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2348+ + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2349+ + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
2350+ glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
2351+ }
2352+ renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
2353+ } else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) {
2354+ EntityItemPointer cameraEntity = _myCamera.getCameraEntityPointer();
2355+ if (cameraEntity != nullptr) {
2356+ if (isHMDMode()) {
2357+ glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2358+ _myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
2359+ glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2360+ _myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
2361+ } else {
2362+ _myCamera.setOrientation(cameraEntity->getRotation());
2363+ _myCamera.setPosition(cameraEntity->getPosition());
2364+ }
22262365 }
22272366 }
2228− }
2229− // Update camera position
2230− if (!isHMDMode()) {
2231− _myCamera.update(1.0f / _frameCounter.rate());
2367+ // Update camera position
2368+ if (!isHMDMode()) {
2369+ _myCamera.update(1.0f / _frameCounter.rate());
2370+ }
22322371 }
22332372 }
22342373
2235− getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform());
2374+ {
2375+ PROFILE_RANGE(render, "/updateCompositor");
2376+ getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform());
2377+ }
22362378
2237− // Primary rendering pass
2238− auto framebufferCache = DependencyManager::get<FramebufferCache>();
2239− const QSize size = framebufferCache->getFrameBufferSize();
2240− // Final framebuffer that will be handled to the display-plugin
2241− auto finalFramebuffer = framebufferCache->getFramebuffer();
2379+ gpu::FramebufferPointer finalFramebuffer;
2380+ QSize finalFramebufferSize;
2381+ {
2382+ PROFILE_RANGE(render, "/getOutputFramebuffer");
2383+ // Primary rendering pass
2384+ auto framebufferCache = DependencyManager::get<FramebufferCache>();
2385+ finalFramebufferSize = framebufferCache->getFrameBufferSize();
2386+ // Final framebuffer that will be handled to the display-plugin
2387+ finalFramebuffer = framebufferCache->getFramebuffer();
2388+ }
22422389
22432390 {
22442391 PROFILE_RANGE(render, "/mainRender");
22452392 PerformanceTimer perfTimer("mainRender");
22462393 renderArgs._boomOffset = boomOffset;
2394+ // FIXME is this ever going to be different from the size previously set in the render args
2395+ // in the overlay render?
22472396 // Viewport is assigned to the size of the framebuffer
2248− renderArgs._viewport = ivec4(0, 0, size.width(), size.height());
2397+ renderArgs._viewport = ivec4(0, 0, finalFramebufferSize.width(), finalFramebufferSize.height());
22492398 if (displayPlugin->isStereo()) {
22502399 // Stereo modes will typically have a larger projection matrix overall,
22512400 // so we ask for the 'mono' projection matrix, which for stereo and HMD
@@ -2322,12 +2471,6 @@ void Application::runTests() { · 70 unmodified lines
23222471 runUnitTests();
23232472 }
23242473
2325−void Application::audioMuteToggled() const {
2326− QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio);
2327− Q_CHECK_PTR(muteAction);
2328− muteAction->setChecked(DependencyManager::get<AudioClient>()->isMuted());
2329−}
2330−
23312474 void Application::faceTrackerMuteToggled() {
23322475
23332476 QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteFaceTracking);
@@ -2397,7 +2540,7 @@ void Application::showHelp() { · 63 unmodified lines
23972540 queryString.addQueryItem("handControllerName", handControllerName);
23982541 queryString.addQueryItem("defaultTab", defaultTab);
23992542 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
2400− TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
2543+ TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
24012544 tablet->gotoWebScreen(INFO_HELP_PATH + "?" + queryString.toString());
24022545 //InfoView::show(INFO_HELP_PATH, false, queryString.toString());
24032546 }
@@ -2490,8 +2633,11 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 86 unmodified lines
24902633 Setting::Handle<bool> tutorialComplete{ "tutorialComplete", false };
24912634 Setting::Handle<bool> firstRun{ Settings::firstRun, true };
24922635
2636+ const QString HIFI_SKIP_TUTORIAL_COMMAND_LINE_KEY = "--skipTutorial";
2637+ // Skips tutorial/help behavior, and does NOT clear firstRun setting.
2638+ bool skipTutorial = arguments().contains(HIFI_SKIP_TUTORIAL_COMMAND_LINE_KEY);
24932639 bool isTutorialComplete = tutorialComplete.get();
2494− bool shouldGoToTutorial = isUsingHMDAndHandControllers && hasTutorialContent && !isTutorialComplete;
2640+ bool shouldGoToTutorial = isUsingHMDAndHandControllers && hasTutorialContent && !isTutorialComplete && !skipTutorial;
24952641
24962642 qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMDAndHandControllers;
24972643 qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent <<
@@ -2534,14 +2680,9 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 36 unmodified lines
25342680 }
25352681 } else {
25362682
2537− bool isFirstRun = firstRun.get();
2538−
2539− if (isFirstRun) {
2540− showHelp();
2541− }
2542−
25432683 // If this is a first run we short-circuit the address passed in
2544− if (isFirstRun) {
2684+ if (firstRun.get() && !skipTutorial) {
2685+ showHelp();
25452686 if (isUsingHMDAndHandControllers) {
25462687 if (sandboxIsRunning) {
25472688 qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
@@ -2579,7 +2720,9 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 31 unmodified lines
25792720 _connectionMonitor.init();
25802721
25812722 // After all of the constructor is completed, then set firstRun to false.
2582− firstRun.set(false);
2723+ if (!skipTutorial) {
2724+ firstRun.set(false);
2725+ }
25832726 }
25842727
25852728 bool Application::importJSONFromURL(const QString& urlString) {
@@ -2601,56 +2744,53 @@ bool Application::importSVOFromURL(const QString& urlString) { · 15 unmodified lines
26012744 return true;
26022745 }
26032746
2747+bool _renderRequested { false };
2748+
26042749 bool Application::event(QEvent* event) {
26052750 if (!Menu::getInstance()) {
26062751 return false;
26072752 }
26082753
2609− // Presentation/painting logic
2610− // TODO: Decouple presentation and painting loops
2611− static bool isPaintingThrottled = false;
2612− if ((int)event->type() == (int)Present) {
2613− if (isPaintingThrottled) {
2614− // If painting (triggered by presentation) is hogging the main thread,
2615− // repost as low priority to avoid hanging the GUI.
2616− // This has the effect of allowing presentation to exceed the paint budget by X times and
2617− // only dropping every (1/X) frames, instead of every ceil(X) frames
2618− // (e.g. at a 60FPS target, painting for 17us would fall to 58.82FPS instead of 30FPS).
2619− removePostedEvents(this, Present);
2620− postEvent(this, new QEvent(static_cast<QEvent::Type>(Present)), Qt::LowEventPriority);
2621− isPaintingThrottled = false;
2754+ int type = event->type();
2755+ switch (type) {
2756+ case Event::Lambda:
2757+ static_cast<LambdaEvent*>(event)->call();
26222758 return true;
2623− }
2624−
2625− float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed();
2626− if (shouldPaint(nsecsElapsed)) {
2627− _lastTimeUpdated.start();
2628− idle(nsecsElapsed);
2629− postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority);
2630− }
2631− isPaintingThrottled = true;
2632−
2633− return true;
2634− } else if ((int)event->type() == (int)Paint) {
2635− // NOTE: This must be updated as close to painting as possible,
2636− // or AvatarInputs will mysteriously move to the bottom-right
2637− AvatarInputs::getInstance()->update();
2638−
2639− paintGL();
26402759
2641− isPaintingThrottled = false;
2760+ // Explicit idle keeps the idle running at a lower interval, but without any rendering
2761+ // see (windowMinimizedChanged)
2762+ case Event::Idle:
2763+ {
2764+ float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed();
2765+ _lastTimeUpdated.start();
2766+ idle(nsecsElapsed);
2767+ }
2768+ return true;
26422769
2643− return true;
2644− } else if ((int)event->type() == (int)Idle) {
2645− float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed();
2646− idle(nsecsElapsed);
2770+ case Event::Present:
2771+ if (!_renderRequested) {
2772+ float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed();
2773+ if (shouldPaint(nsecsElapsed)) {
2774+ _renderRequested = true;
2775+ _lastTimeUpdated.start();
2776+ idle(nsecsElapsed);
2777+ postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority);
2778+ }
2779+ }
2780+ return true;
26472781
2648− return true;
2649− }
2782+ case Event::Paint:
2783+ // NOTE: This must be updated as close to painting as possible,
2784+ // or AvatarInputs will mysteriously move to the bottom-right
2785+ AvatarInputs::getInstance()->update();
2786+ paintGL();
2787+ // wait for the next present event before starting idle / paint again
2788+ removePostedEvents(this, Present);
2789+ _renderRequested = false;
2790+ return true;
26502791
2651− if ((int)event->type() == (int)Lambda) {
2652− static_cast<LambdaEvent*>(event)->call();
2653− return true;
2792+ default:
2793+ break;
26542794 }
26552795
26562796 {
@@ -2853,7 +2993,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 196 unmodified lines
28532993 if (isShifted && isMeta) {
28542994 auto offscreenUi = DependencyManager::get<OffscreenUi>();
28552995 offscreenUi->togglePinned();
2856− //offscreenUi->getRootContext()->engine()->clearComponentCache();
2996+ //offscreenUi->getSurfaceContext()->engine()->clearComponentCache();
28572997 //OffscreenUi::information("Debugging", "Component cache cleared");
28582998 // placeholder for dialogs being converted to QML.
28592999 }
@@ -2894,6 +3034,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 34 unmodified lines
28943034 Menu::getInstance()->triggerOption(MenuOption::DefaultSkybox);
28953035 break;
28963036
3037+ case Qt::Key_M:
3038+ if (isMeta) {
3039+ DependencyManager::get<AudioClient>()->toggleMute();
3040+ }
3041+ break;
3042+
28973043 case Qt::Key_N:
28983044 if (!isOption && !isShifted && isMeta) {
28993045 DependencyManager::get<NodeList>()->toggleIgnoreRadius();
@@ -3032,59 +3178,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 132 unmodified lines
30323178 break;
30333179 #endif
30343180
3035− case Qt::Key_H: {
3036− // whenever switching to/from full screen mirror from the keyboard, remember
3037− // the state you were in before full screen mirror, and return to that.
3038− auto previousMode = _myCamera.getMode();
3039− if (previousMode != CAMERA_MODE_MIRROR) {
3040− switch (previousMode) {
3041− case CAMERA_MODE_FIRST_PERSON:
3042− _returnFromFullScreenMirrorTo = MenuOption::FirstPerson;
3043− break;
3044− case CAMERA_MODE_THIRD_PERSON:
3045− _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
3046− break;
3047−
3048− // FIXME - it's not clear that these modes make sense to return to...
3049− case CAMERA_MODE_INDEPENDENT:
3050− _returnFromFullScreenMirrorTo = MenuOption::IndependentMode;
3051− break;
3052− case CAMERA_MODE_ENTITY:
3053− _returnFromFullScreenMirrorTo = MenuOption::CameraEntityMode;
3054− break;
3055−
3056− default:
3057− _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
3058− break;
3059− }
3060− }
3061−
3062− bool isMirrorChecked = Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror);
3063− Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, !isMirrorChecked);
3064− if (isMirrorChecked) {
3065−
3066− // if we got here without coming in from a non-Full Screen mirror case, then our
3067− // _returnFromFullScreenMirrorTo is unknown. In that case we'll go to the old
3068− // behavior of returning to ThirdPerson
3069− if (_returnFromFullScreenMirrorTo.isEmpty()) {
3070− _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
3071− }
3072− Menu::getInstance()->setIsOptionChecked(_returnFromFullScreenMirrorTo, true);
3073− }
3074− cameraMenuChanged();
3075− break;
3076− }
3077−
3078− case Qt::Key_P: {
3079− if (!(isShifted || isMeta || isOption)) {
3080− bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson);
3081− Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !isFirstPersonChecked);
3082− Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, isFirstPersonChecked);
3083− cameraMenuChanged();
3084− }
3085− break;
3086− }
3087−
30883181 case Qt::Key_Slash:
30893182 Menu::getInstance()->triggerOption(MenuOption::Stats);
30903183 break;
@@ -3545,6 +3638,133 @@ bool Application::shouldPaint(float nsecsElapsed) { · 454 unmodified lines
35453638 #include <TCHAR.h>
35463639 #include <pdh.h>
35473640 #pragma comment(lib, "pdh.lib")
3641+#pragma comment(lib, "ntdll.lib")
3642+
3643+extern "C" {
3644+ enum SYSTEM_INFORMATION_CLASS {
3645+ SystemBasicInformation = 0,
3646+ SystemProcessorPerformanceInformation = 8,
3647+ };
3648+
3649+ struct SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
3650+ LARGE_INTEGER IdleTime;
3651+ LARGE_INTEGER KernelTime;
3652+ LARGE_INTEGER UserTime;
3653+ LARGE_INTEGER DpcTime;
3654+ LARGE_INTEGER InterruptTime;
3655+ ULONG InterruptCount;
3656+ };
3657+
3658+ struct SYSTEM_BASIC_INFORMATION {
3659+ ULONG Reserved;
3660+ ULONG TimerResolution;
3661+ ULONG PageSize;
3662+ ULONG NumberOfPhysicalPages;
3663+ ULONG LowestPhysicalPageNumber;
3664+ ULONG HighestPhysicalPageNumber;
3665+ ULONG AllocationGranularity;
3666+ ULONG_PTR MinimumUserModeAddress;
3667+ ULONG_PTR MaximumUserModeAddress;
3668+ ULONG_PTR ActiveProcessorsAffinityMask;
3669+ CCHAR NumberOfProcessors;
3670+ };
3671+
3672+ NTSYSCALLAPI NTSTATUS NTAPI NtQuerySystemInformation(
3673+ _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
3674+ _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
3675+ _In_ ULONG SystemInformationLength,
3676+ _Out_opt_ PULONG ReturnLength
3677+ );
3678+
3679+}
3680+template <typename T>
3681+NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, T& t) {
3682+ return NtQuerySystemInformation(SystemInformationClass, &t, (ULONG)sizeof(T), nullptr);
3683+}
3684+
3685+template <typename T>
3686+NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, std::vector<T>& t) {
3687+ return NtQuerySystemInformation(SystemInformationClass, t.data(), (ULONG)(sizeof(T) * t.size()), nullptr);
3688+}
3689+
3690+
3691+template <typename T>
3692+void updateValueAndDelta(std::pair<T, T>& pair, T newValue) {
3693+ auto& value = pair.first;
3694+ auto& delta = pair.second;
3695+ delta = (value != 0) ? newValue - value : 0;
3696+ value = newValue;
3697+}
3698+
3699+struct MyCpuInfo {
3700+ using ValueAndDelta = std::pair<LONGLONG, LONGLONG>;
3701+ std::string name;
3702+ ValueAndDelta kernel { 0, 0 };
3703+ ValueAndDelta user { 0, 0 };
3704+ ValueAndDelta idle { 0, 0 };
3705+ float kernelUsage { 0.0f };
3706+ float userUsage { 0.0f };
3707+
3708+ void update(const SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION& cpuInfo) {
3709+ updateValueAndDelta(kernel, cpuInfo.KernelTime.QuadPart);
3710+ updateValueAndDelta(user, cpuInfo.UserTime.QuadPart);
3711+ updateValueAndDelta(idle, cpuInfo.IdleTime.QuadPart);
3712+ auto totalTime = kernel.second + user.second + idle.second;
3713+ if (totalTime != 0) {
3714+ kernelUsage = (FLOAT)kernel.second / totalTime;
3715+ userUsage = (FLOAT)user.second / totalTime;
3716+ } else {
3717+ kernelUsage = userUsage = 0.0f;
3718+ }
3719+ }
3720+};
3721+
3722+void updateCpuInformation() {
3723+ static std::once_flag once;
3724+ static SYSTEM_BASIC_INFORMATION systemInfo {};
3725+ static SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION cpuTotals;
3726+ static std::vector<SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION> cpuInfos;
3727+ static std::vector<MyCpuInfo> myCpuInfos;
3728+ static MyCpuInfo myCpuTotals;
3729+ std::call_once(once, [&] {
3730+ NtQuerySystemInformation( SystemBasicInformation, systemInfo);
3731+ cpuInfos.resize(systemInfo.NumberOfProcessors);
3732+ myCpuInfos.resize(systemInfo.NumberOfProcessors);
3733+ for (size_t i = 0; i < systemInfo.NumberOfProcessors; ++i) {
3734+ myCpuInfos[i].name = "cpu." + std::to_string(i);
3735+ }
3736+ myCpuTotals.name = "cpu.total";
3737+ });
3738+ NtQuerySystemInformation(SystemProcessorPerformanceInformation, cpuInfos);
3739+
3740+ // Zero the CPU totals.
3741+ memset(&cpuTotals, 0, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION));
3742+ for (size_t i = 0; i < systemInfo.NumberOfProcessors; ++i) {
3743+ auto& cpuInfo = cpuInfos[i];
3744+ // KernelTime includes IdleTime.
3745+ cpuInfo.KernelTime.QuadPart -= cpuInfo.IdleTime.QuadPart;
3746+
3747+ // Update totals
3748+ cpuTotals.IdleTime.QuadPart += cpuInfo.IdleTime.QuadPart;
3749+ cpuTotals.KernelTime.QuadPart += cpuInfo.KernelTime.QuadPart;
3750+ cpuTotals.UserTime.QuadPart += cpuInfo.UserTime.QuadPart;
3751+
3752+ // Update friendly structure
3753+ auto& myCpuInfo = myCpuInfos[i];
3754+ myCpuInfo.update(cpuInfo);
3755+ PROFILE_COUNTER(app, myCpuInfo.name.c_str(), {
3756+ { "kernel", myCpuInfo.kernelUsage },
3757+ { "user", myCpuInfo.userUsage }
3758+ });
3759+ }
3760+
3761+ myCpuTotals.update(cpuTotals);
3762+ PROFILE_COUNTER(app, myCpuTotals.name.c_str(), {
3763+ { "kernel", myCpuTotals.kernelUsage },
3764+ { "user", myCpuTotals.userUsage }
3765+ });
3766+}
3767+
35483768
35493769 static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
35503770 static int numProcessors;
@@ -3597,6 +3817,26 @@ void getCpuUsage(vec3& systemAndUser) { · 46 unmodified lines
35973817 systemAndUser.z = (float)counterVal.doubleValue;
35983818 }
35993819
3820+void setupCpuMonitorThread() {
3821+ initCpuUsage();
3822+ auto cpuMonitorThread = QThread::currentThread();
3823+
3824+ QTimer* timer = new QTimer();
3825+ timer->setInterval(50);
3826+ QObject::connect(timer, &QTimer::timeout, [] {
3827+ updateCpuInformation();
3828+ vec3 kernelUserAndSystem;
3829+ getCpuUsage(kernelUserAndSystem);
3830+ PROFILE_COUNTER(app, "cpuProcess", { { "system", kernelUserAndSystem.x }, { "user", kernelUserAndSystem.y } });
3831+ PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } });
3832+ });
3833+ QObject::connect(cpuMonitorThread, &QThread::finished, [=] {
3834+ timer->deleteLater();
3835+ cpuMonitorThread->deleteLater();
3836+ });
3837+ timer->start();
3838+}
3839+
36003840 #endif
36013841
36023842
@@ -3617,15 +3857,17 @@ void Application::idle(float nsecsElapsed) { · 14 unmodified lines
36173857 }
36183858
36193859 #ifdef Q_OS_WIN
3860+ // If tracing is enabled then monitor the CPU in a separate thread
36203861 static std::once_flag once;
3621− std::call_once(once, [] {
3622− initCpuUsage();
3862+ std::call_once(once, [&] {
3863+ if (trace_app().isDebugEnabled()) {
3864+ QThread* cpuMonitorThread = new QThread(qApp);
3865+ cpuMonitorThread->setObjectName("cpuMonitorThread");
3866+ QObject::connect(cpuMonitorThread, &QThread::started, [this] { setupCpuMonitorThread(); });
3867+ QObject::connect(qApp, &QCoreApplication::aboutToQuit, cpuMonitorThread, &QThread::quit);
3868+ cpuMonitorThread->start();
3869+ }
36233870 });
3624−
3625− vec3 kernelUserAndSystem;
3626− getCpuUsage(kernelUserAndSystem);
3627− PROFILE_COUNTER(app, "cpuProcess", { { "system", kernelUserAndSystem.x }, { "user", kernelUserAndSystem.y } });
3628− PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } });
36293871 #endif
36303872
36313873
@@ -3987,17 +4229,10 @@ void Application::init() { · 355 unmodified lines
39874229
39884230 qCDebug(interfaceapp) << "Loaded settings";
39894231
3990− Leapmotion::init();
3991−
39924232 // fire off an immediate domain-server check in now that settings are loaded
39934233 DependencyManager::get<NodeList>()->sendDomainServerCheckIn();
39944234
39954235 getEntities()->init();
3996− {
3997− QMutexLocker viewLocker(&_viewMutex);
3998− getEntities()->setViewFrustum(_viewFrustum);
3999− }
4000−
40014236 getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) {
40024237 auto dims = item.getDimensions();
40034238 auto maxSize = glm::compMax(dims);
@@ -4027,19 +4262,15 @@ void Application::init() { · 23 unmodified lines
40274262 // of events related clicking, hovering over, and entering entities
40284263 getEntities()->connectSignalsToSlots(entityScriptingInterface.data());
40294264
4030− _entityClipboardRenderer.init();
4031− {
4032− QMutexLocker viewLocker(&_viewMutex);
4033− _entityClipboardRenderer.setViewFrustum(_viewFrustum);
4034− }
4035− _entityClipboardRenderer.setTree(_entityClipboard);
4036−
40374265 // Make sure any new sounds are loaded as soon as know about them.
40384266 connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) {
40394267 EntityTreePointer tree = getEntities()->getTree();
40404268 if (auto entity = tree->findEntityByEntityItemID(id)) {
40414269 auto sound = DependencyManager::get<SoundCache>()->getSound(newURL);
4042− entity->setCollisionSound(sound);
4270+ auto renderable = entity->getRenderableInterface();
4271+ if (renderable) {
4272+ renderable->setCollisionSound(sound);
4273+ }
40434274 }
40444275 }, Qt::QueuedConnection);
40454276 connect(getMyAvatar().get(), &MyAvatar::newCollisionSoundURL, this, [this](QUrl newURL) {
@@ -4461,7 +4692,6 @@ void Application::update(float deltaTime) { · 415 unmodified lines
44614692
44624693 {
44634694 PerformanceTimer perfTimer("devices");
4464− DeviceTracker::updateAll();
44654695
44664696 FaceTracker* tracker = getSelectedFaceTracker();
44674697 if (tracker && Menu::getInstance()->isOptionChecked(MenuOption::MuteFaceTracking) != tracker->isMuted()) {
@@ -4478,10 +4708,11 @@ void Application::update(float deltaTime) { · 10 unmodified lines
44784708 } else {
44794709 const quint64 MUTE_MICROPHONE_AFTER_USECS = 5000000; //5 secs
44804710 Menu* menu = Menu::getInstance();
4481− if (menu->isOptionChecked(MenuOption::AutoMuteAudio) && !menu->isOptionChecked(MenuOption::MuteAudio)) {
4711+ auto audioClient = DependencyManager::get<AudioClient>();
4712+ if (menu->isOptionChecked(MenuOption::AutoMuteAudio) && !audioClient->isMuted()) {
44824713 if (_lastFaceTrackerUpdate > 0
44834714 && ((usecTimestampNow() - _lastFaceTrackerUpdate) > MUTE_MICROPHONE_AFTER_USECS)) {
4484− menu->triggerOption(MenuOption::MuteAudio);
4715+ audioClient->toggleMute();
44854716 _lastFaceTrackerUpdate = 0;
44864717 }
44874718 } else {
@@ -4529,8 +4760,6 @@ void Application::update(float deltaTime) { · 41 unmodified lines
45294760 keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData);
45304761 }
45314762
4532− _controllerScriptingInterface->updateInputControllers();
4533−
45344763 // Transfer the user inputs to the driveKeys
45354764 // FIXME can we drop drive keys and just have the avatar read the action states directly?
45364765 myAvatar->clearDriveKeys();
@@ -4555,6 +4784,31 @@ void Application::update(float deltaTime) { · 18 unmodified lines
45554784 auto avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
45564785 myAvatar->setHandControllerPosesInSensorFrame(leftHandPose.transform(avatarToSensorMatrix), rightHandPose.transform(avatarToSensorMatrix));
45574786
4787+ // If have previously done finger poses or there are new valid finger poses, update finger pose values. This so that if
4788+ // fingers are not being controlled, finger joints are not updated in MySkeletonModel.
4789+ // Assumption: Finger poses are either all present and valid or not present at all; thus can test just one joint.
4790+ MyAvatar::FingerPosesMap leftHandFingerPoses;
4791+ if (myAvatar->getLeftHandFingerControllerPosesInSensorFrame().size() > 0
4792+ || userInputMapper->getPoseState(controller::Action::LEFT_HAND_THUMB1).isValid()) {
4793+ for (int i = (int)controller::Action::LEFT_HAND_THUMB1; i <= (int)controller::Action::LEFT_HAND_PINKY4; i++) {
4794+ leftHandFingerPoses[i] = {
4795+ userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),
4796+ userInputMapper->getActionName((controller::Action)i)
4797+ };
4798+ }
4799+ }
4800+ MyAvatar::FingerPosesMap rightHandFingerPoses;
4801+ if (myAvatar->getRightHandFingerControllerPosesInSensorFrame().size() > 0
4802+ || userInputMapper->getPoseState(controller::Action::RIGHT_HAND_THUMB1).isValid()) {
4803+ for (int i = (int)controller::Action::RIGHT_HAND_THUMB1; i <= (int)controller::Action::RIGHT_HAND_PINKY4; i++) {
4804+ rightHandFingerPoses[i] = {
4805+ userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),
4806+ userInputMapper->getActionName((controller::Action)i)
4807+ };
4808+ }
4809+ }
4810+ myAvatar->setFingerControllerPosesInSensorFrame(leftHandFingerPoses, rightHandFingerPoses);
4811+
45584812 controller::Pose leftFootPose = userInputMapper->getPoseState(controller::Action::LEFT_FOOT);
45594813 controller::Pose rightFootPose = userInputMapper->getPoseState(controller::Action::RIGHT_FOOT);
45604814 myAvatar->setFootControllerPosesInSensorFrame(leftFootPose.transform(avatarToSensorMatrix), rightFootPose.transform(avatarToSensorMatrix));
@@ -5025,9 +5279,6 @@ QRect Application::getDesirableApplicationGeometry() const { · 464 unmodified lines
50255279 return applicationGeometry;
50265280 }
50275281
5028−// FIXME, preprocessor guard this check to occur only in DEBUG builds
5029−static QThread * activeRenderingThread = nullptr;
5030−
50315282 PickRay Application::computePickRay(float x, float y) const {
50325283 vec2 pickPoint { x, y };
50335284 PickRay result;
@@ -5086,7 +5337,7 @@ namespace render { · 52 unmodified lines
50865337
50875338 auto& batch = *args->_batch;
50885339 DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch);
5089− renderWorldBox(batch);
5340+ renderWorldBox(args, batch);
50905341 }
50915342 }
50925343 }
@@ -5098,7 +5349,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 5 unmodified lines
50985349 auto myAvatar = getMyAvatar();
50995350 myAvatar->preDisplaySide(renderArgs);
51005351
5101− activeRenderingThread = QThread::currentThread();
51025352 PROFILE_RANGE(render, __FUNCTION__);
51035353 PerformanceTimer perfTimer("display");
51045354 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
@@ -5150,10 +5400,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 45 unmodified lines
51505400 }
51515401
51525402 {
5153− PerformanceTimer perfTimer("SceneProcessTransaction");
51545403 _main3DScene->enqueueTransaction(transaction);
5155−
5156− _main3DScene->processTransactionQueue();
51575404 }
51585405
51595406 // For now every frame pass the renderContext
@@ -5171,8 +5418,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 11 unmodified lines
51715418 // Before the deferred pass, let's try to use the render engine
51725419 _renderEngine->run();
51735420 }
5174−
5175− activeRenderingThread = nullptr;
51765421 }
51775422
51785423 void Application::resetSensors(bool andReload) {
@@ -5209,6 +5454,10 @@ void Application::updateWindowTitle() const { · 30 unmodified lines
52095454 qCDebug(interfaceapp, "Application title set to: %s", title.toStdString().c_str());
52105455 #endif
52115456 _window->setWindowTitle(title);
5457+
5458+ // updateTitleWindow gets called whenever there's a change regarding the domain, so rather
5459+ // than placing this within domainChanged, it's placed here to cover the other potential cases.
5460+ DependencyManager::get< MessagesClient >()->sendLocalMessage("Toolbar-DomainChanged", "");
52125461 }
52135462
52145463 void Application::clearDomainOctreeDetails() {
@@ -5239,7 +5488,7 @@ void Application::clearDomainOctreeDetails() { · 24 unmodified lines
52395488 skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
52405489
52415490 _recentlyClearedDomain = true;
5242−
5491+
52435492 DependencyManager::get<AnimationCache>()->clearUnusedResources();
52445493 DependencyManager::get<ModelCache>()->clearUnusedResources();
52455494 DependencyManager::get<SoundCache>()->clearUnusedResources();
@@ -5303,6 +5552,10 @@ void Application::nodeActivated(SharedNodePointer node) { · 57 unmodified lines
53035552 if (node->getType() == NodeType::AvatarMixer) {
53045553 // new avatar mixer, send off our identity packet on next update loop
53055554 // Reset skeletonModelUrl if the last server modified our choice.
5555+ // Override the avatar url (but not model name) here too.
5556+ if (_avatarOverrideUrl.isValid()) {
5557+ getMyAvatar()->useFullAvatarURL(_avatarOverrideUrl);
5558+ }
53065559 static const QUrl empty{};
53075560 if (getMyAvatar()->getFullAvatarURLFromPreferences() != getMyAvatar()->cannonicalSkeletonModelURL(empty)) {
53085561 getMyAvatar()->resetFullAvatarURL();
@@ -5508,8 +5761,16 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 199 unmodified lines
55085761
55095762 scriptEngine->registerGlobalObject("OffscreenFlags", DependencyManager::get<OffscreenUi>()->getFlags());
55105763 scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
5764+
5765+ qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<ToolbarProxy>, wrapperFromScriptValue<ToolbarProxy>);
5766+ qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<ToolbarButtonProxy>, wrapperFromScriptValue<ToolbarButtonProxy>);
55115767 scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data());
55125768
5769+ qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<TabletProxy>, wrapperFromScriptValue<TabletProxy>);
5770+ qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<TabletButtonProxy>, wrapperFromScriptValue<TabletButtonProxy>);
5771+ scriptEngine->registerGlobalObject("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
5772+
5773+
55135774 DependencyManager::get<TabletScriptingInterface>().data()->setToolbarScriptingInterface(DependencyManager::get<ToolbarScriptingInterface>().data());
55145775
55155776 scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
@@ -5527,7 +5788,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 11 unmodified lines
55275788 scriptEngine->registerGlobalObject("Stats", Stats::getInstance());
55285789 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
55295790 scriptEngine->registerGlobalObject("Snapshot", DependencyManager::get<Snapshot>().data());
5530− scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
55315791 scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
55325792 scriptEngine->registerGlobalObject("AudioScope", DependencyManager::get<AudioScope>().data());
55335793 scriptEngine->registerGlobalObject("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
@@ -5583,7 +5843,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 49 unmodified lines
55835843 auto entityScriptServerLog = DependencyManager::get<EntityScriptServerLogClient>();
55845844 scriptEngine->registerGlobalObject("EntityScriptServerLog", entityScriptServerLog.data());
55855845 scriptEngine->registerGlobalObject("AvatarInputs", AvatarInputs::getInstance());
5586−
5846+ scriptEngine->registerGlobalObject("HoverOverlay", DependencyManager::get<HoverOverlayInterface>().data());
55875847
55885848 qScriptRegisterMetaType(scriptEngine, OverlayIDtoScriptValue, OverlayIDfromScriptValue);
55895849
@@ -5592,6 +5852,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 2 unmodified lines
55925852 connect(scriptEngine, &ScriptEngine::errorMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onErrorMessage);
55935853 connect(scriptEngine, &ScriptEngine::warningMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onWarningMessage);
55945854 connect(scriptEngine, &ScriptEngine::infoMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onInfoMessage);
5855+ connect(scriptEngine, &ScriptEngine::clearDebugWindow, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onClearDebugWindow);
5856+
55955857 }
55965858
55975859 bool Application::canAcceptURL(const QString& urlString) const {
@@ -5806,43 +6068,29 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) · 208 unmodified lines
58066068 }
58076069 }
58086070
5809−void Application::toggleRunningScriptsWidget() const {
5810− auto scriptEngines = DependencyManager::get<ScriptEngines>();
5811− bool scriptsRunning = !scriptEngines->getRunningScripts().isEmpty();
5812− auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
5813− auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6071+void Application::showDialog(const QUrl& widgetUrl, const QUrl& tabletUrl, const QString& name) const {
6072+ auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet(SYSTEM_TABLET);
6073+ auto hmd = DependencyManager::get<HMDScriptingInterface>();
6074+ bool onTablet = false;
58146075
5815− if (tablet->getToolbarMode() || false == scriptsRunning) {
5816− static const QUrl url("hifi/dialogs/RunningScripts.qml");
5817− DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
5818− } else {
5819− auto hmd = DependencyManager::get<HMDScriptingInterface>();
5820− if (!hmd->getShouldShowTablet() && !isHMDMode()) {
5821− static const QUrl url("hifi/dialogs/RunningScripts.qml");
5822− DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
5823− } else {
5824− static const QUrl url("../../hifi/dialogs/TabletRunningScripts.qml");
5825− tablet->pushOntoStack(url);
6076+ if (!tablet->getToolbarMode()) {
6077+ onTablet = tablet->pushOntoStack(tabletUrl);
6078+ if (onTablet) {
6079+ toggleTabletUI(true);
58266080 }
58276081 }
5828− //DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
5829− //if (_runningScriptsWidget->isVisible()) {
5830− // if (_runningScriptsWidget->hasFocus()) {
5831− // _runningScriptsWidget->hide();
5832− // } else {
5833− // _runningScriptsWidget->raise();
5834− // setActiveWindow(_runningScriptsWidget);
5835− // _runningScriptsWidget->setFocus();
5836− // }
5837− //} else {
5838− // _runningScriptsWidget->show();
5839− // _runningScriptsWidget->setFocus();
5840− //}
6082+
6083+ if (!onTablet) {
6084+ DependencyManager::get<OffscreenUi>()->show(widgetUrl, name);
6085+ }
6086+ if (tablet->getToolbarMode()) {
6087+ DependencyManager::get<OffscreenUi>()->show(widgetUrl, name);
6088+ }
58416089 }
58426090
58436091 void Application::showScriptLogs() {
58446092 auto scriptEngines = DependencyManager::get<ScriptEngines>();
5845− QUrl defaultScriptsLoc = defaultScriptsLocation();
6093+ QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
58466094 defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js");
58476095 scriptEngines->loadScript(defaultScriptsLoc.toString());
58486096 }
@@ -5859,7 +6107,7 @@ void Application::showAssetServerWidget(QString filePath) { · 10 unmodified lines
58596107 }
58606108 };
58616109 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
5862− auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6110+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
58636111 auto hmd = DependencyManager::get<HMDScriptingInterface>();
58646112 if (tablet->getToolbarMode()) {
58656113 DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
@@ -5889,26 +6137,11 @@ void Application::addAssetToWorldFromURL(QString url) { · 23 unmodified lines
58896137
58906138 addAssetToWorldInfo(filename, "Downloading model file " + filename + ".");
58916139
5892− auto request = ResourceManager::createResourceRequest(nullptr, QUrl(url));
6140+ auto request = DependencyManager::get<ResourceManager>()->createResourceRequest(nullptr, QUrl(url));
58936141 connect(request, &ResourceRequest::finished, this, &Application::addAssetToWorldFromURLRequestFinished);
58946142 request->send();
58956143 }
58966144
5897−void Application::showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const {
5898− auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
5899− auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
5900− auto hmd = DependencyManager::get<HMDScriptingInterface>();
5901− if (tablet->getToolbarMode()) {
5902− DependencyManager::get<OffscreenUi>()->show(desktopURL, name);
5903− } else {
5904− tablet->pushOntoStack(tabletURL);
5905− if (!hmd->getShouldShowTablet() && !isHMDMode()) {
5906− hmd->openTablet();
5907− }
5908−
5909− }
5910−}
5911−
59126145 void Application::addAssetToWorldFromURLRequestFinished() {
59136146 auto request = qobject_cast<ResourceRequest*>(sender());
59146147 auto url = request->getUrl().toString();
@@ -6382,17 +6615,17 @@ void Application::setPreviousScriptLocation(const QString& location) { · 467 unmodified lines
63826615 }
63836616
63846617 void Application::loadScriptURLDialog() const {
6385− auto newScript = OffscreenUi::getText(OffscreenUi::ICON_NONE, "Open and Run Script", "Script URL");
6618+ QString newScript = OffscreenUi::getText(OffscreenUi::ICON_NONE, "Open and Run Script", "Script URL");
63866619 if (QUrl(newScript).scheme() == "atp") {
63876620 OffscreenUi::warning("Error Loading Script", "Cannot load client script over ATP");
63886621 } else if (!newScript.isEmpty()) {
6389− DependencyManager::get<ScriptEngines>()->loadScript(newScript);
6622+ DependencyManager::get<ScriptEngines>()->loadScript(newScript.trimmed());
63906623 }
63916624 }
63926625
63936626 void Application::loadLODToolsDialog() {
63946627 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
6395− auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6628+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
63966629 if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) {
63976630 auto dialogsManager = DependencyManager::get<DialogsManager>();
63986631 dialogsManager->lodTools();
@@ -6404,7 +6637,7 @@ void Application::loadLODToolsDialog() { · 5 unmodified lines
64046637
64056638 void Application::loadEntityStatisticsDialog() {
64066639 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
6407− auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6640+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
64086641 if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) {
64096642 auto dialogsManager = DependencyManager::get<DialogsManager>();
64106643 dialogsManager->octreeStatsDetails();
@@ -6415,7 +6648,7 @@ void Application::loadEntityStatisticsDialog() { · 4 unmodified lines
64156648
64166649 void Application::loadDomainConnectionDialog() {
64176650 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
6418− auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6651+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
64196652 if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) {
64206653 auto dialogsManager = DependencyManager::get<DialogsManager>();
64216654 dialogsManager->showDomainConnectionDialog();
@@ -6863,6 +7096,12 @@ void Application::updateDisplayMode() { · 441 unmodified lines
68637096 // reset the avatar, to set head and hand palms back to a reasonable default pose.
68647097 getMyAvatar()->reset(false);
68657098
7099+ // switch to first person if entering hmd and setting is checked
7100+ if (isHmd && menu->isOptionChecked(MenuOption::FirstPersonHMD)) {
7101+ menu->setIsOptionChecked(MenuOption::FirstPerson, true);
7102+ cameraMenuChanged();
7103+ }
7104+
68667105 Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
68677106 }
68687107
@@ -7072,11 +7311,6 @@ void Application::updateSystemTabletMode() { · 203 unmodified lines
70727311 }
70737312 }
70747313
7075−void Application::toggleMuteAudio() {
7076− auto menu = Menu::getInstance();
7077− menu->setIsOptionChecked(MenuOption::MuteAudio, !menu->isOptionChecked(MenuOption::MuteAudio));
7078−}
7079−
70807314 OverlayID Application::getTabletScreenID() const {
70817315 auto HMD = DependencyManager::get<HMDScriptingInterface>();
70827316 return HMD->getCurrentTabletScreenID();
@@ -7091,3 +7325,8 @@ QUuid Application::getTabletFrameID() const { · 8 unmodified lines
70917325 auto HMD = DependencyManager::get<HMDScriptingInterface>();
70927326 return HMD->getCurrentTabletFrameID();
70937327 }
7328+
7329+void Application::setAvatarOverrideUrl(const QUrl& url, bool save) {
7330+ _avatarOverrideUrl = url;
7331+ _saveAvatarOverrideUrl = save;
7332+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t