Showing the changes to interface/src/Application.cpp (1 of 783 files). Show all
Unified · Split
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <QtCore/QCommandLineParser> |
| 26 | 26 | #include <QtCore/QMimeData> |
| 27 | 27 | #include <QtCore/QThreadPool> |
| 28 | +#include <QtConcurrent/QtConcurrentRun> | |
| 28 | 29 | |
| 29 | 30 | #include <QtGui/QScreen> |
| 30 | 31 | #include <QtGui/QWindow> |
| @@ -37,8 +38,6 @@ · 6 unmodified lines | ||
| 37 | 38 | #include <QtQml/QQmlEngine> |
| 38 | 39 | #include <QtQuick/QQuickWindow> |
| 39 | 40 | |
| 40 | −#include <QtWebEngineWidgets/QWebEngineProfile> | |
| 41 | − | |
| 42 | 41 | #include <QtWidgets/QDesktopWidget> |
| 43 | 42 | #include <QtWidgets/QMessageBox> |
| 44 | 43 | |
| @@ -50,6 +49,7 @@ · 5 unmodified lines | ||
| 50 | 49 | |
| 51 | 50 | #include <gl/QOpenGLContextWrapper.h> |
| 52 | 51 | |
| 52 | +#include <shared/QtHelpers.h> | |
| 53 | 53 | #include <shared/GlobalAppProperties.h> |
| 54 | 54 | #include <StatTracker.h> |
| 55 | 55 | #include <Trace.h> |
| @@ -70,6 +70,7 @@ · 14 unmodified lines | ||
| 70 | 70 | #include <EntityScriptClient.h> |
| 71 | 71 | #include <EntityScriptServerLogClient.h> |
| 72 | 72 | #include <EntityScriptingInterface.h> |
| 73 | +#include <HoverOverlayInterface.h> | |
| 73 | 74 | #include <ErrorDialog.h> |
| 74 | 75 | #include <FileScriptingInterface.h> |
| 75 | 76 | #include <Finally.h> |
| @@ -89,6 +90,7 @@ · 13 unmodified lines | ||
| 89 | 90 | #include <UserActivityLoggerScriptingInterface.h> |
| 90 | 91 | #include <LogHandler.h> |
| 91 | 92 | #include "LocationBookmarks.h" |
| 93 | +#include <LocationScriptingInterface.h> | |
| 92 | 94 | #include <MainWindow.h> |
| 93 | 95 | #include <MappingRequest.h> |
| 94 | 96 | #include <MessagesClient.h> |
| @@ -99,8 +101,8 @@ · 4 unmodified lines | ||
| 99 | 101 | #include <OctalCode.h> |
| 100 | 102 | #include <OctreeSceneStats.h> |
| 101 | 103 | #include <OffscreenUi.h> |
| 102 | −#include <gl/OffscreenQmlSurfaceCache.h> | |
| 103 | 104 | #include <gl/OffscreenGLCanvas.h> |
| 105 | +#include <ui/OffscreenQmlSurfaceCache.h> | |
| 104 | 106 | #include <PathUtils.h> |
| 105 | 107 | #include <PerfStat.h> |
| 106 | 108 | #include <PhysicsEngine.h> |
| @@ -109,13 +111,12 @@ · 2 unmodified lines | ||
| 109 | 111 | #include <plugins/PluginManager.h> |
| 110 | 112 | #include <plugins/PluginUtils.h> |
| 111 | 113 | #include <plugins/SteamClientPlugin.h> |
| 114 | +#include <plugins/InputConfiguration.h> | |
| 112 | 115 | #include <RecordingScriptingInterface.h> |
| 113 | 116 | #include <RenderableWebEntityItem.h> |
| 114 | −#include <RenderShadowTask.h> | |
| 115 | −#include <render/RenderFetchCullSortTask.h> | |
| 116 | −#include <RenderDeferredTask.h> | |
| 117 | −#include <RenderForwardTask.h> | |
| 117 | +#include <UpdateSceneTask.h> | |
| 118 | 118 | #include <RenderViewTask.h> |
| 119 | +#include <SecondaryCamera.h> | |
| 119 | 120 | #include <ResourceCache.h> |
| 120 | 121 | #include <ResourceRequest.h> |
| 121 | 122 | #include <SandboxUtils.h> |
| @@ -123,7 +124,8 @@ · 1 unmodified line | ||
| 123 | 124 | #include <ScriptEngines.h> |
| 124 | 125 | #include <ScriptCache.h> |
| 125 | 126 | #include <SoundCache.h> |
| 126 | −#include <TabletScriptingInterface.h> | |
| 127 | +#include <ui/TabletScriptingInterface.h> | |
| 128 | +#include <ui/ToolbarScriptingInterface.h> | |
| 127 | 129 | #include <Tooltip.h> |
| 128 | 130 | #include <udt/PacketHeaders.h> |
| 129 | 131 | #include <UserActivityLogger.h> |
| @@ -144,32 +146,30 @@ · 14 unmodified lines | ||
| 144 | 146 | #include "avatar/MyHead.h" |
| 145 | 147 | #include "CrashHandler.h" |
| 146 | 148 | #include "devices/DdeFaceTracker.h" |
| 147 | −#include "devices/Leapmotion.h" | |
| 148 | 149 | #include "DiscoverabilityManager.h" |
| 149 | 150 | #include "GLCanvas.h" |
| 150 | 151 | #include "InterfaceDynamicFactory.h" |
| 151 | 152 | #include "InterfaceLogging.h" |
| 152 | 153 | #include "LODManager.h" |
| 153 | 154 | #include "ModelPackager.h" |
| 155 | +#include "scripting/Audio.h" | |
| 154 | 156 | #include "networking/CloseEventSender.h" |
| 155 | 157 | #include "scripting/TestScriptingInterface.h" |
| 156 | 158 | #include "scripting/AccountScriptingInterface.h" |
| 157 | 159 | #include "scripting/AssetMappingsScriptingInterface.h" |
| 158 | −#include "scripting/AudioDeviceScriptingInterface.h" | |
| 159 | 160 | #include "scripting/ClipboardScriptingInterface.h" |
| 160 | 161 | #include "scripting/DesktopScriptingInterface.h" |
| 161 | 162 | #include "scripting/GlobalServicesScriptingInterface.h" |
| 162 | 163 | #include "scripting/HMDScriptingInterface.h" |
| 163 | −#include "scripting/LocationScriptingInterface.h" | |
| 164 | 164 | #include "scripting/MenuScriptingInterface.h" |
| 165 | 165 | #include "scripting/SettingsScriptingInterface.h" |
| 166 | 166 | #include "scripting/WindowScriptingInterface.h" |
| 167 | 167 | #include "scripting/ControllerScriptingInterface.h" |
| 168 | −#include "scripting/ToolbarScriptingInterface.h" | |
| 169 | 168 | #include "scripting/RatesScriptingInterface.h" |
| 170 | 169 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 171 | 170 | #include "SpeechRecognizer.h" |
| 172 | 171 | #endif |
| 172 | +#include "ui/ResourceImageItem.h" | |
| 173 | 173 | #include "ui/AddressBarDialog.h" |
| 174 | 174 | #include "ui/AvatarInputs.h" |
| 175 | 175 | #include "ui/DialogsManager.h" |
| @@ -214,7 +214,7 @@ static QTimer pingTimer; · 38 unmodified lines | ||
| 214 | 214 | |
| 215 | 215 | static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; |
| 216 | 216 | |
| 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 | |
| 218 | 218 | // based on how many are being consumed by the application and the display plugin. However, |
| 219 | 219 | // we will never drop below the 'min' value |
| 220 | 220 | 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 | ||
| 252 | 252 | static const int INTERVAL_TO_CHECK_HMD_WORN_STATUS = 500; // milliseconds |
| 253 | 253 | static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop"; |
| 254 | 254 | |
| 255 | +static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system"; | |
| 256 | + | |
| 255 | 257 | const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions { |
| 256 | 258 | { SVO_EXTENSION, &Application::importSVOFromURL }, |
| 257 | 259 | { SVO_JSON_EXTENSION, &Application::importSVOFromURL }, |
| @@ -442,18 +444,62 @@ static const QString STATE_ADVANCED_MOVEMENT_CONTROLS = "AdvancedMovement"; · 184 unmodified lines | ||
| 442 | 444 | static const QString STATE_GROUNDED = "Grounded"; |
| 443 | 445 | static const QString STATE_NAV_FOCUSED = "NavigationFocused"; |
| 444 | 446 | |
| 447 | +// Statically provided display and input plugins | |
| 448 | +extern DisplayPluginList getDisplayPlugins(); | |
| 449 | +extern InputPluginList getInputPlugins(); | |
| 450 | +extern void saveInputPluginSettings(const InputPluginList& plugins); | |
| 451 | + | |
| 445 | 452 | bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { |
| 446 | 453 | 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 | + | |
| 447 | 482 | const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); |
| 448 | 483 | const int listenPort = portStr ? atoi(portStr) : INVALID_PORT; |
| 449 | 484 | |
| 450 | 485 | static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; |
| 451 | 486 | bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET); |
| 452 | 487 | 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 | + } | |
| 453 | 494 | |
| 454 | 495 | Setting::init(); |
| 455 | 496 | |
| 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()) { | |
| 457 | 503 | steamClient->init(); |
| 458 | 504 | } |
| 459 | 505 | |
| @@ -513,6 +559,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 53 unmodified lines | ||
| 513 | 559 | DependencyManager::set<HMDScriptingInterface>(); |
| 514 | 560 | DependencyManager::set<ResourceScriptingInterface>(); |
| 515 | 561 | DependencyManager::set<TabletScriptingInterface>(); |
| 562 | + DependencyManager::set<InputConfiguration>(); | |
| 516 | 563 | DependencyManager::set<ToolbarScriptingInterface>(); |
| 517 | 564 | DependencyManager::set<UserActivityLoggerScriptingInterface>(); |
| 518 | 565 | DependencyManager::set<AssetMappingsScriptingInterface>(); |
| @@ -547,6 +594,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 28 unmodified lines | ||
| 547 | 594 | DependencyManager::set<LocationBookmarks>(); |
| 548 | 595 | DependencyManager::set<Snapshot>(); |
| 549 | 596 | DependencyManager::set<CloseEventSender>(); |
| 597 | + DependencyManager::set<ResourceManager>(); | |
| 598 | + DependencyManager::set<HoverOverlayInterface>(); | |
| 550 | 599 | |
| 551 | 600 | return previousSessionCrashed; |
| 552 | 601 | } |
| @@ -584,7 +633,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 31 unmodified lines | ||
| 584 | 633 | _undoStackScriptingInterface(&_undoStack), |
| 585 | 634 | _entitySimulation(new PhysicalEntitySimulation()), |
| 586 | 635 | _physicsEngine(new PhysicsEngine(Vectors::ZERO)), |
| 587 | − _entityClipboardRenderer(false, this, this), | |
| 588 | 636 | _entityClipboard(new EntityTree()), |
| 589 | 637 | _lastQueriedTime(usecTimestampNow()), |
| 590 | 638 | _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), |
| @@ -687,9 +735,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 96 unmodified lines | ||
| 687 | 735 | updateHeartbeat(); |
| 688 | 736 | |
| 689 | 737 | // setup a timer for domain-server check ins |
| 690 | − QTimer* domainCheckInTimer = new QTimer(nodeList.data()); | |
| 738 | + QTimer* domainCheckInTimer = new QTimer(this); | |
| 691 | 739 | connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn); |
| 692 | 740 | domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); |
| 741 | + connect(this, &QCoreApplication::aboutToQuit, [domainCheckInTimer] { | |
| 742 | + domainCheckInTimer->stop(); | |
| 743 | + domainCheckInTimer->deleteLater(); | |
| 744 | + }); | |
| 693 | 745 | |
| 694 | 746 | |
| 695 | 747 | auto audioIO = DependencyManager::get<AudioClient>(); |
| @@ -717,9 +769,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 21 unmodified lines | ||
| 717 | 769 | recorder->recordFrame(AUDIO_FRAME_TYPE, audio); |
| 718 | 770 | } |
| 719 | 771 | }); |
| 772 | + audioIO->startThread(); | |
| 720 | 773 | |
| 721 | − auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>(); | |
| 722 | − connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled); | |
| 774 | + auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface, scripting::Audio>(); | |
| 723 | 775 | connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer); |
| 724 | 776 | connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket); |
| 725 | 777 | 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 | ||
| 735 | 787 | audioScriptingInterface->environmentMuted(); |
| 736 | 788 | } |
| 737 | 789 | }); |
| 790 | + connect(this, &Application::activeDisplayPluginChanged, | |
| 791 | + reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged); | |
| 738 | 792 | |
| 739 | − audioIO->startThread(); | |
| 740 | − | |
| 741 | − ResourceManager::init(); | |
| 742 | 793 | // Make sure we don't time out during slow operations at startup |
| 743 | 794 | updateHeartbeat(); |
| 744 | 795 | |
| @@ -863,6 +914,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 118 unmodified lines | ||
| 863 | 914 | } |
| 864 | 915 | ResourceCache::setRequestLimit(concurrentDownloads); |
| 865 | 916 | |
| 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 | + | |
| 866 | 931 | _glWidget = new GLCanvas(); |
| 867 | 932 | getApplicationCompositor().setRenderingWidget(_glWidget); |
| 868 | 933 | _window->setCentralWidget(_glWidget); |
| @@ -893,58 +958,68 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 24 unmodified lines | ||
| 893 | 958 | // Make sure we don't time out during slow operations at startup |
| 894 | 959 | updateHeartbeat(); |
| 895 | 960 | |
| 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 | |
| 941 | 961 | 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()); | |
| 946 | 962 | |
| 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 | + } | |
| 948 | 1023 | |
| 949 | 1024 | // Tell our entity edit sender about our known jurisdictions |
| 950 | 1025 | _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions); |
| @@ -959,7 +1034,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 8 unmodified lines | ||
| 959 | 1034 | // Make sure we don't time out during slow operations at startup |
| 960 | 1035 | updateHeartbeat(); |
| 961 | 1036 | |
| 962 | − connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); | |
| 1037 | + connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit())); | |
| 963 | 1038 | |
| 964 | 1039 | // hook up bandwidth estimator |
| 965 | 1040 | QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>(); |
| @@ -1127,7 +1202,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 161 unmodified lines | ||
| 1127 | 1202 | // force the model the look at the correct directory (weird order of operations issue) |
| 1128 | 1203 | scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation()); |
| 1129 | 1204 | // 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 | + | |
| 1131 | 1220 | // Make sure we don't time out during slow operations at startup |
| 1132 | 1221 | updateHeartbeat(); |
| 1133 | 1222 | |
| @@ -1142,15 +1231,26 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 8 unmodified lines | ||
| 1142 | 1231 | // Make sure we don't time out during slow operations at startup |
| 1143 | 1232 | updateHeartbeat(); |
| 1144 | 1233 | |
| 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); | |
| 1154 | 1254 | |
| 1155 | 1255 | if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { |
| 1156 | 1256 | 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 | ||
| 1252 | 1352 | // Add periodic checks to send user activity data |
| 1253 | 1353 | static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000; |
| 1254 | 1354 | static int NEARBY_AVATAR_RADIUS_METERS = 10; |
| 1255 | − | |
| 1355 | + | |
| 1256 | 1356 | // setup the stats interval depending on if the 1s faster hearbeat was requested |
| 1257 | 1357 | static const QString FAST_STATS_ARG = "--fast-heartbeat"; |
| 1258 | 1358 | 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 | ||
| 1375 | 1475 | properties["atp_mapping_requests"] = atpMappingRequests; |
| 1376 | 1476 | |
| 1377 | 1477 | 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; | |
| 1378 | 1486 | |
| 1379 | 1487 | auto myAvatar = getMyAvatar(); |
| 1380 | 1488 | glm::vec3 avatarPosition = myAvatar->getPosition(); |
| @@ -1402,10 +1510,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 21 unmodified lines | ||
| 1402 | 1510 | |
| 1403 | 1511 | _autoSwitchDisplayModeSupportedHMDPlugin = nullptr; |
| 1404 | 1512 | foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) { |
| 1405 | − if (displayPlugin->isHmd() && | |
| 1513 | + if (displayPlugin->isHmd() && | |
| 1406 | 1514 | displayPlugin->getSupportsAutoSwitch()) { |
| 1407 | 1515 | _autoSwitchDisplayModeSupportedHMDPlugin = displayPlugin; |
| 1408 | − _autoSwitchDisplayModeSupportedHMDPluginName = | |
| 1516 | + _autoSwitchDisplayModeSupportedHMDPluginName = | |
| 1409 | 1517 | _autoSwitchDisplayModeSupportedHMDPlugin->getName(); |
| 1410 | 1518 | _previousHMDWornStatus = |
| 1411 | 1519 | _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible(); |
| @@ -1453,7 +1561,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 41 unmodified lines | ||
| 1453 | 1561 | }); |
| 1454 | 1562 | sendStatsTimer->start(); |
| 1455 | 1563 | |
| 1456 | − | |
| 1457 | 1564 | // Periodically check for count of nearby avatars |
| 1458 | 1565 | static int lastCountOfNearbyAvatars = -1; |
| 1459 | 1566 | QTimer* checkNearbyAvatarsTimer = new QTimer(this); |
| @@ -1579,7 +1686,7 @@ QString Application::getUserAgent() { · 119 unmodified lines | ||
| 1579 | 1686 | if (QThread::currentThread() != thread()) { |
| 1580 | 1687 | QString userAgent; |
| 1581 | 1688 | |
| 1582 | − QMetaObject::invokeMethod(this, "getUserAgent", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, userAgent)); | |
| 1689 | + BLOCKING_INVOKE_METHOD(this, "getUserAgent", Q_RETURN_ARG(QString, userAgent)); | |
| 1583 | 1690 | |
| 1584 | 1691 | return userAgent; |
| 1585 | 1692 | } |
| @@ -1611,12 +1718,10 @@ QString Application::getUserAgent() { · 25 unmodified lines | ||
| 1611 | 1718 | return userAgent; |
| 1612 | 1719 | } |
| 1613 | 1720 | |
| 1614 | −void Application::toggleTabletUI() const { | |
| 1721 | +void Application::toggleTabletUI(bool shouldOpen) const { | |
| 1615 | 1722 | auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>(); |
| 1616 | 1723 | 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())) { | |
| 1620 | 1725 | auto HMD = DependencyManager::get<HMDScriptingInterface>(); |
| 1621 | 1726 | HMD->toggleShouldShowTablet(); |
| 1622 | 1727 | } |
| @@ -1648,7 +1753,7 @@ void Application::updateHeartbeat() const { · 25 unmodified lines | ||
| 1648 | 1753 | static_cast<DeadlockWatchdogThread*>(_deadlockWatchdogThread)->updateHeartbeat(); |
| 1649 | 1754 | } |
| 1650 | 1755 | |
| 1651 | −void Application::aboutToQuit() { | |
| 1756 | +void Application::onAboutToQuit() { | |
| 1652 | 1757 | emit beforeAboutToQuit(); |
| 1653 | 1758 | |
| 1654 | 1759 | foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) { |
| @@ -1658,7 +1763,7 @@ void Application::aboutToQuit() { · 3 unmodified lines | ||
| 1658 | 1763 | } |
| 1659 | 1764 | |
| 1660 | 1765 | getActiveDisplayPlugin()->deactivate(); |
| 1661 | − if (_autoSwitchDisplayModeSupportedHMDPlugin | |
| 1766 | + if (_autoSwitchDisplayModeSupportedHMDPlugin | |
| 1662 | 1767 | && _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) { |
| 1663 | 1768 | _autoSwitchDisplayModeSupportedHMDPlugin->endSession(); |
| 1664 | 1769 | } |
| @@ -1727,8 +1832,8 @@ void Application::cleanupBeforeQuit() { · 62 unmodified lines | ||
| 1727 | 1832 | |
| 1728 | 1833 | // Cleanup all overlays after the scripts, as scripts might add more |
| 1729 | 1834 | _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. | |
| 1732 | 1837 | // See https://highfidelity.fogbugz.com/f/cases/5328 |
| 1733 | 1838 | _main3DScene->processTransactionQueue(); |
| 1734 | 1839 | |
| @@ -1737,11 +1842,13 @@ void Application::cleanupBeforeQuit() { · 2 unmodified lines | ||
| 1737 | 1842 | locationUpdateTimer.stop(); |
| 1738 | 1843 | identityPacketTimer.stop(); |
| 1739 | 1844 | pingTimer.stop(); |
| 1740 | − QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection); | |
| 1741 | 1845 | |
| 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 | + | |
| 1745 | 1852 | _window->saveGeometry(); |
| 1746 | 1853 | |
| 1747 | 1854 | // Destroy third party processes after scripts have finished using them. |
| @@ -1753,6 +1860,8 @@ void Application::cleanupBeforeQuit() { · 5 unmodified lines | ||
| 1753 | 1860 | #endif |
| 1754 | 1861 | |
| 1755 | 1862 | // stop QML |
| 1863 | + DependencyManager::destroy<TabletScriptingInterface>(); | |
| 1864 | + DependencyManager::destroy<ToolbarScriptingInterface>(); | |
| 1756 | 1865 | DependencyManager::destroy<OffscreenUi>(); |
| 1757 | 1866 | |
| 1758 | 1867 | DependencyManager::destroy<OffscreenQmlSurfaceCache>(); |
| @@ -1763,8 +1872,7 @@ void Application::cleanupBeforeQuit() { · 4 unmodified lines | ||
| 1763 | 1872 | |
| 1764 | 1873 | // FIXME: something else is holding a reference to AudioClient, |
| 1765 | 1874 | // so it must be explicitly synchronously stopped here |
| 1766 | − QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), | |
| 1767 | − "cleanupBeforeQuit", Qt::BlockingQueuedConnection); | |
| 1875 | + DependencyManager::get<AudioClient>()->cleanupBeforeQuit(); | |
| 1768 | 1876 | |
| 1769 | 1877 | // destroy Audio so it and its threads have a chance to go down safely |
| 1770 | 1878 | // this must happen after QML, as there are unexplained audio crashes originating in qtwebengine |
| @@ -1814,13 +1922,11 @@ Application::~Application() { · 43 unmodified lines | ||
| 1814 | 1922 | DependencyManager::destroy<SoundCache>(); |
| 1815 | 1923 | DependencyManager::destroy<OctreeStatsProvider>(); |
| 1816 | 1924 | |
| 1817 | − ResourceManager::cleanup(); | |
| 1925 | + DependencyManager::get<ResourceManager>()->cleanup(); | |
| 1818 | 1926 | |
| 1819 | 1927 | // remove the NodeList from the DependencyManager |
| 1820 | 1928 | DependencyManager::destroy<NodeList>(); |
| 1821 | 1929 | |
| 1822 | − Leapmotion::destroy(); | |
| 1823 | − | |
| 1824 | 1930 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { |
| 1825 | 1931 | steamClient->shutdown(); |
| 1826 | 1932 | } |
| @@ -1879,6 +1985,8 @@ void Application::initializeGL() { · 52 unmodified lines | ||
| 1879 | 1985 | render::CullFunctor cullFunctor = LODManager::shouldRender; |
| 1880 | 1986 | static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD"; |
| 1881 | 1987 | bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD); |
| 1988 | + _renderEngine->addJob<UpdateSceneTask>("UpdateScene"); | |
| 1989 | + _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor); | |
| 1882 | 1990 | _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred); |
| 1883 | 1991 | _renderEngine->load(); |
| 1884 | 1992 | _renderEngine->registerScene(_main3DScene); |
| @@ -1926,6 +2034,7 @@ void Application::initializeUi() { · 41 unmodified lines | ||
| 1926 | 2034 | LoginDialog::registerType(); |
| 1927 | 2035 | Tooltip::registerType(); |
| 1928 | 2036 | UpdateDialog::registerType(); |
| 2037 | + qmlRegisterType<ResourceImageItem>("Hifi", 1, 0, "ResourceImageItem"); | |
| 1929 | 2038 | qmlRegisterType<Preference>("Hifi", 1, 0, "Preference"); |
| 1930 | 2039 | |
| 1931 | 2040 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| @@ -1993,7 +2102,6 @@ void Application::initializeUi() { · 61 unmodified lines | ||
| 1993 | 2102 | surfaceContext->setContextProperty("Stats", Stats::getInstance()); |
| 1994 | 2103 | surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance()); |
| 1995 | 2104 | surfaceContext->setContextProperty("ScriptDiscoveryService", DependencyManager::get<ScriptEngines>().data()); |
| 1996 | − surfaceContext->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); | |
| 1997 | 2105 | surfaceContext->setContextProperty("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data()); |
| 1998 | 2106 | surfaceContext->setContextProperty("LocationBookmarks", DependencyManager::get<LocationBookmarks>().data()); |
| 1999 | 2107 | |
| @@ -2002,6 +2110,7 @@ void Application::initializeUi() { · 2 unmodified lines | ||
| 2002 | 2110 | surfaceContext->setContextProperty("TextureCache", DependencyManager::get<TextureCache>().data()); |
| 2003 | 2111 | surfaceContext->setContextProperty("ModelCache", DependencyManager::get<ModelCache>().data()); |
| 2004 | 2112 | surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data()); |
| 2113 | + surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data()); | |
| 2005 | 2114 | |
| 2006 | 2115 | surfaceContext->setContextProperty("Account", AccountScriptingInterface::getInstance()); |
| 2007 | 2116 | surfaceContext->setContextProperty("Tablet", DependencyManager::get<TabletScriptingInterface>().data()); |
| @@ -2021,6 +2130,7 @@ void Application::initializeUi() { · 13 unmodified lines | ||
| 2021 | 2130 | surfaceContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor()); |
| 2022 | 2131 | |
| 2023 | 2132 | surfaceContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); |
| 2133 | + surfaceContext->setContextProperty("HoverOverlay", DependencyManager::get<HoverOverlayInterface>().data()); | |
| 2024 | 2134 | |
| 2025 | 2135 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { |
| 2026 | 2136 | surfaceContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get())); |
| @@ -2086,48 +2196,74 @@ void Application::paintGL() { · 59 unmodified lines | ||
| 2086 | 2196 | return; |
| 2087 | 2197 | } |
| 2088 | 2198 | |
| 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 | + } | |
| 2092 | 2204 | |
| 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 | + } | |
| 2099 | 2220 | } |
| 2100 | 2221 | |
| 2101 | 2222 | // update the avatar with a fresh HMD pose |
| 2102 | − getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose()); | |
| 2223 | + { | |
| 2224 | + PROFILE_RANGE(render, "/updateAvatar"); | |
| 2225 | + getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose()); | |
| 2226 | + } | |
| 2103 | 2227 | |
| 2104 | 2228 | auto lodManager = DependencyManager::get<LODManager>(); |
| 2105 | 2229 | |
| 2230 | + RenderArgs renderArgs; | |
| 2106 | 2231 | { |
| 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 | + } | |
| 2109 | 2244 | } |
| 2110 | − RenderArgs renderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(), | |
| 2111 | − lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE, | |
| 2112 | − RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); | |
| 2245 | + | |
| 2113 | 2246 | { |
| 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(); | |
| 2116 | 2252 | } |
| 2117 | 2253 | |
| 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 | + } | |
| 2122 | 2263 | |
| 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 | − }); | |
| 2129 | 2264 | |
| 2130 | 2265 | { |
| 2266 | + PROFILE_RANGE(render, "/renderOverlay"); | |
| 2131 | 2267 | PerformanceTimer perfTimer("renderOverlay"); |
| 2132 | 2268 | // NOTE: There is no batch associated with this renderArgs |
| 2133 | 2269 | // the ApplicationOverlay class assumes it's viewport is setup to be the device size |
| @@ -2138,114 +2274,127 @@ void Application::paintGL() { · 4 unmodified lines | ||
| 2138 | 2274 | |
| 2139 | 2275 | glm::vec3 boomOffset; |
| 2140 | 2276 | { |
| 2141 | − PerformanceTimer perfTimer("CameraUpdates"); | |
| 2277 | + PROFILE_RANGE(render, "/updateCamera"); | |
| 2278 | + { | |
| 2279 | + PerformanceTimer perfTimer("CameraUpdates"); | |
| 2142 | 2280 | |
| 2143 | − auto myAvatar = getMyAvatar(); | |
| 2144 | − boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD; | |
| 2281 | + auto myAvatar = getMyAvatar(); | |
| 2282 | + boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD; | |
| 2145 | 2283 | |
| 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 | + } | |
| 2151 | 2289 | |
| 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; | |
| 2154 | 2292 | |
| 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)); | |
| 2178 | 2301 | } else { |
| 2179 | − _myCamera.setPosition(myAvatar->getDefaultEyePosition() | |
| 2180 | − + myAvatar->getOrientation() * boomOffset); | |
| 2302 | + _myCamera.setPosition(myAvatar->getDefaultEyePosition()); | |
| 2303 | + _myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation()); | |
| 2181 | 2304 | } |
| 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)); | |
| 2193 | 2324 | |
| 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); | |
| 2195 | 2331 | |
| 2196 | − _myCamera.setOrientation(worldMirrorRotation); | |
| 2332 | + glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation; | |
| 2197 | 2333 | |
| 2198 | − glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix()); | |
| 2199 | − // Mirror HMD lateral offsets | |
| 2200 | − hmdOffset.x = -hmdOffset.x; | |
| 2334 | + _myCamera.setOrientation(worldMirrorRotation); | |
| 2201 | 2335 | |
| 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); | |
| 2221 | 2336 | 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); | |
| 2223 | 2344 | } 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 | + } | |
| 2226 | 2365 | } |
| 2227 | 2366 | } |
| 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 | + } | |
| 2232 | 2371 | } |
| 2233 | 2372 | } |
| 2234 | 2373 | |
| 2235 | − getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform()); | |
| 2374 | + { | |
| 2375 | + PROFILE_RANGE(render, "/updateCompositor"); | |
| 2376 | + getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform()); | |
| 2377 | + } | |
| 2236 | 2378 | |
| 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 | + } | |
| 2242 | 2389 | |
| 2243 | 2390 | { |
| 2244 | 2391 | PROFILE_RANGE(render, "/mainRender"); |
| 2245 | 2392 | PerformanceTimer perfTimer("mainRender"); |
| 2246 | 2393 | 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? | |
| 2247 | 2396 | // 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()); | |
| 2249 | 2398 | if (displayPlugin->isStereo()) { |
| 2250 | 2399 | // Stereo modes will typically have a larger projection matrix overall, |
| 2251 | 2400 | // so we ask for the 'mono' projection matrix, which for stereo and HMD |
| @@ -2322,12 +2471,6 @@ void Application::runTests() { · 70 unmodified lines | ||
| 2322 | 2471 | runUnitTests(); |
| 2323 | 2472 | } |
| 2324 | 2473 | |
| 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 | − | |
| 2331 | 2474 | void Application::faceTrackerMuteToggled() { |
| 2332 | 2475 | |
| 2333 | 2476 | QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteFaceTracking); |
| @@ -2397,7 +2540,7 @@ void Application::showHelp() { · 63 unmodified lines | ||
| 2397 | 2540 | queryString.addQueryItem("handControllerName", handControllerName); |
| 2398 | 2541 | queryString.addQueryItem("defaultTab", defaultTab); |
| 2399 | 2542 | 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)); | |
| 2401 | 2544 | tablet->gotoWebScreen(INFO_HELP_PATH + "?" + queryString.toString()); |
| 2402 | 2545 | //InfoView::show(INFO_HELP_PATH, false, queryString.toString()); |
| 2403 | 2546 | } |
| @@ -2490,8 +2633,11 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 86 unmodified lines | ||
| 2490 | 2633 | Setting::Handle<bool> tutorialComplete{ "tutorialComplete", false }; |
| 2491 | 2634 | Setting::Handle<bool> firstRun{ Settings::firstRun, true }; |
| 2492 | 2635 | |
| 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); | |
| 2493 | 2639 | bool isTutorialComplete = tutorialComplete.get(); |
| 2494 | − bool shouldGoToTutorial = isUsingHMDAndHandControllers && hasTutorialContent && !isTutorialComplete; | |
| 2640 | + bool shouldGoToTutorial = isUsingHMDAndHandControllers && hasTutorialContent && !isTutorialComplete && !skipTutorial; | |
| 2495 | 2641 | |
| 2496 | 2642 | qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMDAndHandControllers; |
| 2497 | 2643 | qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << |
| @@ -2534,14 +2680,9 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 36 unmodified lines | ||
| 2534 | 2680 | } |
| 2535 | 2681 | } else { |
| 2536 | 2682 | |
| 2537 | − bool isFirstRun = firstRun.get(); | |
| 2538 | − | |
| 2539 | − if (isFirstRun) { | |
| 2540 | − showHelp(); | |
| 2541 | − } | |
| 2542 | − | |
| 2543 | 2683 | // If this is a first run we short-circuit the address passed in |
| 2544 | − if (isFirstRun) { | |
| 2684 | + if (firstRun.get() && !skipTutorial) { | |
| 2685 | + showHelp(); | |
| 2545 | 2686 | if (isUsingHMDAndHandControllers) { |
| 2546 | 2687 | if (sandboxIsRunning) { |
| 2547 | 2688 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| @@ -2579,7 +2720,9 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 31 unmodified lines | ||
| 2579 | 2720 | _connectionMonitor.init(); |
| 2580 | 2721 | |
| 2581 | 2722 | // After all of the constructor is completed, then set firstRun to false. |
| 2582 | − firstRun.set(false); | |
| 2723 | + if (!skipTutorial) { | |
| 2724 | + firstRun.set(false); | |
| 2725 | + } | |
| 2583 | 2726 | } |
| 2584 | 2727 | |
| 2585 | 2728 | bool Application::importJSONFromURL(const QString& urlString) { |
| @@ -2601,56 +2744,53 @@ bool Application::importSVOFromURL(const QString& urlString) { · 15 unmodified lines | ||
| 2601 | 2744 | return true; |
| 2602 | 2745 | } |
| 2603 | 2746 | |
| 2747 | +bool _renderRequested { false }; | |
| 2748 | + | |
| 2604 | 2749 | bool Application::event(QEvent* event) { |
| 2605 | 2750 | if (!Menu::getInstance()) { |
| 2606 | 2751 | return false; |
| 2607 | 2752 | } |
| 2608 | 2753 | |
| 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(); | |
| 2622 | 2758 | 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(); | |
| 2640 | 2759 | |
| 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; | |
| 2642 | 2769 | |
| 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; | |
| 2647 | 2781 | |
| 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; | |
| 2650 | 2791 | |
| 2651 | − if ((int)event->type() == (int)Lambda) { | |
| 2652 | − static_cast<LambdaEvent*>(event)->call(); | |
| 2653 | − return true; | |
| 2792 | + default: | |
| 2793 | + break; | |
| 2654 | 2794 | } |
| 2655 | 2795 | |
| 2656 | 2796 | { |
| @@ -2853,7 +2993,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 196 unmodified lines | ||
| 2853 | 2993 | if (isShifted && isMeta) { |
| 2854 | 2994 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 2855 | 2995 | offscreenUi->togglePinned(); |
| 2856 | − //offscreenUi->getRootContext()->engine()->clearComponentCache(); | |
| 2996 | + //offscreenUi->getSurfaceContext()->engine()->clearComponentCache(); | |
| 2857 | 2997 | //OffscreenUi::information("Debugging", "Component cache cleared"); |
| 2858 | 2998 | // placeholder for dialogs being converted to QML. |
| 2859 | 2999 | } |
| @@ -2894,6 +3034,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 34 unmodified lines | ||
| 2894 | 3034 | Menu::getInstance()->triggerOption(MenuOption::DefaultSkybox); |
| 2895 | 3035 | break; |
| 2896 | 3036 | |
| 3037 | + case Qt::Key_M: | |
| 3038 | + if (isMeta) { | |
| 3039 | + DependencyManager::get<AudioClient>()->toggleMute(); | |
| 3040 | + } | |
| 3041 | + break; | |
| 3042 | + | |
| 2897 | 3043 | case Qt::Key_N: |
| 2898 | 3044 | if (!isOption && !isShifted && isMeta) { |
| 2899 | 3045 | DependencyManager::get<NodeList>()->toggleIgnoreRadius(); |
| @@ -3032,59 +3178,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 132 unmodified lines | ||
| 3032 | 3178 | break; |
| 3033 | 3179 | #endif |
| 3034 | 3180 | |
| 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 | − | |
| 3088 | 3181 | case Qt::Key_Slash: |
| 3089 | 3182 | Menu::getInstance()->triggerOption(MenuOption::Stats); |
| 3090 | 3183 | break; |
| @@ -3545,6 +3638,133 @@ bool Application::shouldPaint(float nsecsElapsed) { · 454 unmodified lines | ||
| 3545 | 3638 | #include <TCHAR.h> |
| 3546 | 3639 | #include <pdh.h> |
| 3547 | 3640 | #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 | + | |
| 3548 | 3768 | |
| 3549 | 3769 | static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU; |
| 3550 | 3770 | static int numProcessors; |
| @@ -3597,6 +3817,26 @@ void getCpuUsage(vec3& systemAndUser) { · 46 unmodified lines | ||
| 3597 | 3817 | systemAndUser.z = (float)counterVal.doubleValue; |
| 3598 | 3818 | } |
| 3599 | 3819 | |
| 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 | + | |
| 3600 | 3840 | #endif |
| 3601 | 3841 | |
| 3602 | 3842 | |
| @@ -3617,15 +3857,17 @@ void Application::idle(float nsecsElapsed) { · 14 unmodified lines | ||
| 3617 | 3857 | } |
| 3618 | 3858 | |
| 3619 | 3859 | #ifdef Q_OS_WIN |
| 3860 | + // If tracing is enabled then monitor the CPU in a separate thread | |
| 3620 | 3861 | 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 | + } | |
| 3623 | 3870 | }); |
| 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 } }); | |
| 3629 | 3871 | #endif |
| 3630 | 3872 | |
| 3631 | 3873 | |
| @@ -3987,17 +4229,10 @@ void Application::init() { · 355 unmodified lines | ||
| 3987 | 4229 | |
| 3988 | 4230 | qCDebug(interfaceapp) << "Loaded settings"; |
| 3989 | 4231 | |
| 3990 | − Leapmotion::init(); | |
| 3991 | − | |
| 3992 | 4232 | // fire off an immediate domain-server check in now that settings are loaded |
| 3993 | 4233 | DependencyManager::get<NodeList>()->sendDomainServerCheckIn(); |
| 3994 | 4234 | |
| 3995 | 4235 | getEntities()->init(); |
| 3996 | − { | |
| 3997 | − QMutexLocker viewLocker(&_viewMutex); | |
| 3998 | − getEntities()->setViewFrustum(_viewFrustum); | |
| 3999 | − } | |
| 4000 | − | |
| 4001 | 4236 | getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) { |
| 4002 | 4237 | auto dims = item.getDimensions(); |
| 4003 | 4238 | auto maxSize = glm::compMax(dims); |
| @@ -4027,19 +4262,15 @@ void Application::init() { · 23 unmodified lines | ||
| 4027 | 4262 | // of events related clicking, hovering over, and entering entities |
| 4028 | 4263 | getEntities()->connectSignalsToSlots(entityScriptingInterface.data()); |
| 4029 | 4264 | |
| 4030 | − _entityClipboardRenderer.init(); | |
| 4031 | − { | |
| 4032 | − QMutexLocker viewLocker(&_viewMutex); | |
| 4033 | − _entityClipboardRenderer.setViewFrustum(_viewFrustum); | |
| 4034 | − } | |
| 4035 | − _entityClipboardRenderer.setTree(_entityClipboard); | |
| 4036 | − | |
| 4037 | 4265 | // Make sure any new sounds are loaded as soon as know about them. |
| 4038 | 4266 | connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) { |
| 4039 | 4267 | EntityTreePointer tree = getEntities()->getTree(); |
| 4040 | 4268 | if (auto entity = tree->findEntityByEntityItemID(id)) { |
| 4041 | 4269 | auto sound = DependencyManager::get<SoundCache>()->getSound(newURL); |
| 4042 | − entity->setCollisionSound(sound); | |
| 4270 | + auto renderable = entity->getRenderableInterface(); | |
| 4271 | + if (renderable) { | |
| 4272 | + renderable->setCollisionSound(sound); | |
| 4273 | + } | |
| 4043 | 4274 | } |
| 4044 | 4275 | }, Qt::QueuedConnection); |
| 4045 | 4276 | connect(getMyAvatar().get(), &MyAvatar::newCollisionSoundURL, this, [this](QUrl newURL) { |
| @@ -4461,7 +4692,6 @@ void Application::update(float deltaTime) { · 415 unmodified lines | ||
| 4461 | 4692 | |
| 4462 | 4693 | { |
| 4463 | 4694 | PerformanceTimer perfTimer("devices"); |
| 4464 | − DeviceTracker::updateAll(); | |
| 4465 | 4695 | |
| 4466 | 4696 | FaceTracker* tracker = getSelectedFaceTracker(); |
| 4467 | 4697 | if (tracker && Menu::getInstance()->isOptionChecked(MenuOption::MuteFaceTracking) != tracker->isMuted()) { |
| @@ -4478,10 +4708,11 @@ void Application::update(float deltaTime) { · 10 unmodified lines | ||
| 4478 | 4708 | } else { |
| 4479 | 4709 | const quint64 MUTE_MICROPHONE_AFTER_USECS = 5000000; //5 secs |
| 4480 | 4710 | 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()) { | |
| 4482 | 4713 | if (_lastFaceTrackerUpdate > 0 |
| 4483 | 4714 | && ((usecTimestampNow() - _lastFaceTrackerUpdate) > MUTE_MICROPHONE_AFTER_USECS)) { |
| 4484 | − menu->triggerOption(MenuOption::MuteAudio); | |
| 4715 | + audioClient->toggleMute(); | |
| 4485 | 4716 | _lastFaceTrackerUpdate = 0; |
| 4486 | 4717 | } |
| 4487 | 4718 | } else { |
| @@ -4529,8 +4760,6 @@ void Application::update(float deltaTime) { · 41 unmodified lines | ||
| 4529 | 4760 | keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData); |
| 4530 | 4761 | } |
| 4531 | 4762 | |
| 4532 | − _controllerScriptingInterface->updateInputControllers(); | |
| 4533 | − | |
| 4534 | 4763 | // Transfer the user inputs to the driveKeys |
| 4535 | 4764 | // FIXME can we drop drive keys and just have the avatar read the action states directly? |
| 4536 | 4765 | myAvatar->clearDriveKeys(); |
| @@ -4555,6 +4784,31 @@ void Application::update(float deltaTime) { · 18 unmodified lines | ||
| 4555 | 4784 | auto avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix; |
| 4556 | 4785 | myAvatar->setHandControllerPosesInSensorFrame(leftHandPose.transform(avatarToSensorMatrix), rightHandPose.transform(avatarToSensorMatrix)); |
| 4557 | 4786 | |
| 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 | + | |
| 4558 | 4812 | controller::Pose leftFootPose = userInputMapper->getPoseState(controller::Action::LEFT_FOOT); |
| 4559 | 4813 | controller::Pose rightFootPose = userInputMapper->getPoseState(controller::Action::RIGHT_FOOT); |
| 4560 | 4814 | myAvatar->setFootControllerPosesInSensorFrame(leftFootPose.transform(avatarToSensorMatrix), rightFootPose.transform(avatarToSensorMatrix)); |
| @@ -5025,9 +5279,6 @@ QRect Application::getDesirableApplicationGeometry() const { · 464 unmodified lines | ||
| 5025 | 5279 | return applicationGeometry; |
| 5026 | 5280 | } |
| 5027 | 5281 | |
| 5028 | −// FIXME, preprocessor guard this check to occur only in DEBUG builds | |
| 5029 | −static QThread * activeRenderingThread = nullptr; | |
| 5030 | − | |
| 5031 | 5282 | PickRay Application::computePickRay(float x, float y) const { |
| 5032 | 5283 | vec2 pickPoint { x, y }; |
| 5033 | 5284 | PickRay result; |
| @@ -5086,7 +5337,7 @@ namespace render { · 52 unmodified lines | ||
| 5086 | 5337 | |
| 5087 | 5338 | auto& batch = *args->_batch; |
| 5088 | 5339 | DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch); |
| 5089 | − renderWorldBox(batch); | |
| 5340 | + renderWorldBox(args, batch); | |
| 5090 | 5341 | } |
| 5091 | 5342 | } |
| 5092 | 5343 | } |
| @@ -5098,7 +5349,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 5 unmodified lines | ||
| 5098 | 5349 | auto myAvatar = getMyAvatar(); |
| 5099 | 5350 | myAvatar->preDisplaySide(renderArgs); |
| 5100 | 5351 | |
| 5101 | − activeRenderingThread = QThread::currentThread(); | |
| 5102 | 5352 | PROFILE_RANGE(render, __FUNCTION__); |
| 5103 | 5353 | PerformanceTimer perfTimer("display"); |
| 5104 | 5354 | 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 | ||
| 5150 | 5400 | } |
| 5151 | 5401 | |
| 5152 | 5402 | { |
| 5153 | − PerformanceTimer perfTimer("SceneProcessTransaction"); | |
| 5154 | 5403 | _main3DScene->enqueueTransaction(transaction); |
| 5155 | − | |
| 5156 | − _main3DScene->processTransactionQueue(); | |
| 5157 | 5404 | } |
| 5158 | 5405 | |
| 5159 | 5406 | // For now every frame pass the renderContext |
| @@ -5171,8 +5418,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 11 unmodified lines | ||
| 5171 | 5418 | // Before the deferred pass, let's try to use the render engine |
| 5172 | 5419 | _renderEngine->run(); |
| 5173 | 5420 | } |
| 5174 | − | |
| 5175 | − activeRenderingThread = nullptr; | |
| 5176 | 5421 | } |
| 5177 | 5422 | |
| 5178 | 5423 | void Application::resetSensors(bool andReload) { |
| @@ -5209,6 +5454,10 @@ void Application::updateWindowTitle() const { · 30 unmodified lines | ||
| 5209 | 5454 | qCDebug(interfaceapp, "Application title set to: %s", title.toStdString().c_str()); |
| 5210 | 5455 | #endif |
| 5211 | 5456 | _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", ""); | |
| 5212 | 5461 | } |
| 5213 | 5462 | |
| 5214 | 5463 | void Application::clearDomainOctreeDetails() { |
| @@ -5239,7 +5488,7 @@ void Application::clearDomainOctreeDetails() { · 24 unmodified lines | ||
| 5239 | 5488 | skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT); |
| 5240 | 5489 | |
| 5241 | 5490 | _recentlyClearedDomain = true; |
| 5242 | − | |
| 5491 | + | |
| 5243 | 5492 | DependencyManager::get<AnimationCache>()->clearUnusedResources(); |
| 5244 | 5493 | DependencyManager::get<ModelCache>()->clearUnusedResources(); |
| 5245 | 5494 | DependencyManager::get<SoundCache>()->clearUnusedResources(); |
| @@ -5303,6 +5552,10 @@ void Application::nodeActivated(SharedNodePointer node) { · 57 unmodified lines | ||
| 5303 | 5552 | if (node->getType() == NodeType::AvatarMixer) { |
| 5304 | 5553 | // new avatar mixer, send off our identity packet on next update loop |
| 5305 | 5554 | // 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 | + } | |
| 5306 | 5559 | static const QUrl empty{}; |
| 5307 | 5560 | if (getMyAvatar()->getFullAvatarURLFromPreferences() != getMyAvatar()->cannonicalSkeletonModelURL(empty)) { |
| 5308 | 5561 | getMyAvatar()->resetFullAvatarURL(); |
| @@ -5508,8 +5761,16 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 199 unmodified lines | ||
| 5508 | 5761 | |
| 5509 | 5762 | scriptEngine->registerGlobalObject("OffscreenFlags", DependencyManager::get<OffscreenUi>()->getFlags()); |
| 5510 | 5763 | scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data()); |
| 5764 | + | |
| 5765 | + qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<ToolbarProxy>, wrapperFromScriptValue<ToolbarProxy>); | |
| 5766 | + qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<ToolbarButtonProxy>, wrapperFromScriptValue<ToolbarButtonProxy>); | |
| 5511 | 5767 | scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data()); |
| 5512 | 5768 | |
| 5769 | + qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<TabletProxy>, wrapperFromScriptValue<TabletProxy>); | |
| 5770 | + qScriptRegisterMetaType(scriptEngine, wrapperToScriptValue<TabletButtonProxy>, wrapperFromScriptValue<TabletButtonProxy>); | |
| 5771 | + scriptEngine->registerGlobalObject("Tablet", DependencyManager::get<TabletScriptingInterface>().data()); | |
| 5772 | + | |
| 5773 | + | |
| 5513 | 5774 | DependencyManager::get<TabletScriptingInterface>().data()->setToolbarScriptingInterface(DependencyManager::get<ToolbarScriptingInterface>().data()); |
| 5514 | 5775 | |
| 5515 | 5776 | scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data()); |
| @@ -5527,7 +5788,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 11 unmodified lines | ||
| 5527 | 5788 | scriptEngine->registerGlobalObject("Stats", Stats::getInstance()); |
| 5528 | 5789 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 5529 | 5790 | scriptEngine->registerGlobalObject("Snapshot", DependencyManager::get<Snapshot>().data()); |
| 5530 | − scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); | |
| 5531 | 5791 | scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data()); |
| 5532 | 5792 | scriptEngine->registerGlobalObject("AudioScope", DependencyManager::get<AudioScope>().data()); |
| 5533 | 5793 | scriptEngine->registerGlobalObject("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data()); |
| @@ -5583,7 +5843,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 49 unmodified lines | ||
| 5583 | 5843 | auto entityScriptServerLog = DependencyManager::get<EntityScriptServerLogClient>(); |
| 5584 | 5844 | scriptEngine->registerGlobalObject("EntityScriptServerLog", entityScriptServerLog.data()); |
| 5585 | 5845 | scriptEngine->registerGlobalObject("AvatarInputs", AvatarInputs::getInstance()); |
| 5586 | − | |
| 5846 | + scriptEngine->registerGlobalObject("HoverOverlay", DependencyManager::get<HoverOverlayInterface>().data()); | |
| 5587 | 5847 | |
| 5588 | 5848 | qScriptRegisterMetaType(scriptEngine, OverlayIDtoScriptValue, OverlayIDfromScriptValue); |
| 5589 | 5849 | |
| @@ -5592,6 +5852,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 2 unmodified lines | ||
| 5592 | 5852 | connect(scriptEngine, &ScriptEngine::errorMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onErrorMessage); |
| 5593 | 5853 | connect(scriptEngine, &ScriptEngine::warningMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onWarningMessage); |
| 5594 | 5854 | connect(scriptEngine, &ScriptEngine::infoMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onInfoMessage); |
| 5855 | + connect(scriptEngine, &ScriptEngine::clearDebugWindow, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onClearDebugWindow); | |
| 5856 | + | |
| 5595 | 5857 | } |
| 5596 | 5858 | |
| 5597 | 5859 | bool Application::canAcceptURL(const QString& urlString) const { |
| @@ -5806,43 +6068,29 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) · 208 unmodified lines | ||
| 5806 | 6068 | } |
| 5807 | 6069 | } |
| 5808 | 6070 | |
| 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; | |
| 5814 | 6075 | |
| 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); | |
| 5826 | 6080 | } |
| 5827 | 6081 | } |
| 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 | + } | |
| 5841 | 6089 | } |
| 5842 | 6090 | |
| 5843 | 6091 | void Application::showScriptLogs() { |
| 5844 | 6092 | auto scriptEngines = DependencyManager::get<ScriptEngines>(); |
| 5845 | − QUrl defaultScriptsLoc = defaultScriptsLocation(); | |
| 6093 | + QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation(); | |
| 5846 | 6094 | defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js"); |
| 5847 | 6095 | scriptEngines->loadScript(defaultScriptsLoc.toString()); |
| 5848 | 6096 | } |
| @@ -5859,7 +6107,7 @@ void Application::showAssetServerWidget(QString filePath) { · 10 unmodified lines | ||
| 5859 | 6107 | } |
| 5860 | 6108 | }; |
| 5861 | 6109 | 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)); | |
| 5863 | 6111 | auto hmd = DependencyManager::get<HMDScriptingInterface>(); |
| 5864 | 6112 | if (tablet->getToolbarMode()) { |
| 5865 | 6113 | DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload); |
| @@ -5889,26 +6137,11 @@ void Application::addAssetToWorldFromURL(QString url) { · 23 unmodified lines | ||
| 5889 | 6137 | |
| 5890 | 6138 | addAssetToWorldInfo(filename, "Downloading model file " + filename + "."); |
| 5891 | 6139 | |
| 5892 | − auto request = ResourceManager::createResourceRequest(nullptr, QUrl(url)); | |
| 6140 | + auto request = DependencyManager::get<ResourceManager>()->createResourceRequest(nullptr, QUrl(url)); | |
| 5893 | 6141 | connect(request, &ResourceRequest::finished, this, &Application::addAssetToWorldFromURLRequestFinished); |
| 5894 | 6142 | request->send(); |
| 5895 | 6143 | } |
| 5896 | 6144 | |
| 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 | − | |
| 5912 | 6145 | void Application::addAssetToWorldFromURLRequestFinished() { |
| 5913 | 6146 | auto request = qobject_cast<ResourceRequest*>(sender()); |
| 5914 | 6147 | auto url = request->getUrl().toString(); |
| @@ -6382,17 +6615,17 @@ void Application::setPreviousScriptLocation(const QString& location) { · 467 unmodified lines | ||
| 6382 | 6615 | } |
| 6383 | 6616 | |
| 6384 | 6617 | 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"); | |
| 6386 | 6619 | if (QUrl(newScript).scheme() == "atp") { |
| 6387 | 6620 | OffscreenUi::warning("Error Loading Script", "Cannot load client script over ATP"); |
| 6388 | 6621 | } else if (!newScript.isEmpty()) { |
| 6389 | − DependencyManager::get<ScriptEngines>()->loadScript(newScript); | |
| 6622 | + DependencyManager::get<ScriptEngines>()->loadScript(newScript.trimmed()); | |
| 6390 | 6623 | } |
| 6391 | 6624 | } |
| 6392 | 6625 | |
| 6393 | 6626 | void Application::loadLODToolsDialog() { |
| 6394 | 6627 | 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)); | |
| 6396 | 6629 | if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { |
| 6397 | 6630 | auto dialogsManager = DependencyManager::get<DialogsManager>(); |
| 6398 | 6631 | dialogsManager->lodTools(); |
| @@ -6404,7 +6637,7 @@ void Application::loadLODToolsDialog() { · 5 unmodified lines | ||
| 6404 | 6637 | |
| 6405 | 6638 | void Application::loadEntityStatisticsDialog() { |
| 6406 | 6639 | 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)); | |
| 6408 | 6641 | if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { |
| 6409 | 6642 | auto dialogsManager = DependencyManager::get<DialogsManager>(); |
| 6410 | 6643 | dialogsManager->octreeStatsDetails(); |
| @@ -6415,7 +6648,7 @@ void Application::loadEntityStatisticsDialog() { · 4 unmodified lines | ||
| 6415 | 6648 | |
| 6416 | 6649 | void Application::loadDomainConnectionDialog() { |
| 6417 | 6650 | 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)); | |
| 6419 | 6652 | if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { |
| 6420 | 6653 | auto dialogsManager = DependencyManager::get<DialogsManager>(); |
| 6421 | 6654 | dialogsManager->showDomainConnectionDialog(); |
| @@ -6863,6 +7096,12 @@ void Application::updateDisplayMode() { · 441 unmodified lines | ||
| 6863 | 7096 | // reset the avatar, to set head and hand palms back to a reasonable default pose. |
| 6864 | 7097 | getMyAvatar()->reset(false); |
| 6865 | 7098 | |
| 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 | + | |
| 6866 | 7105 | Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); |
| 6867 | 7106 | } |
| 6868 | 7107 | |
| @@ -7072,11 +7311,6 @@ void Application::updateSystemTabletMode() { · 203 unmodified lines | ||
| 7072 | 7311 | } |
| 7073 | 7312 | } |
| 7074 | 7313 | |
| 7075 | −void Application::toggleMuteAudio() { | |
| 7076 | − auto menu = Menu::getInstance(); | |
| 7077 | − menu->setIsOptionChecked(MenuOption::MuteAudio, !menu->isOptionChecked(MenuOption::MuteAudio)); | |
| 7078 | −} | |
| 7079 | − | |
| 7080 | 7314 | OverlayID Application::getTabletScreenID() const { |
| 7081 | 7315 | auto HMD = DependencyManager::get<HMDScriptingInterface>(); |
| 7082 | 7316 | return HMD->getCurrentTabletScreenID(); |
| @@ -7091,3 +7325,8 @@ QUuid Application::getTabletFrameID() const { · 8 unmodified lines | ||
| 7091 | 7325 | auto HMD = DependencyManager::get<HMDScriptingInterface>(); |
| 7092 | 7326 | return HMD->getCurrentTabletFrameID(); |
| 7093 | 7327 | } |
| 7328 | + | |
| 7329 | +void Application::setAvatarOverrideUrl(const QUrl& url, bool save) { | |
| 7330 | + _avatarOverrideUrl = url; | |
| 7331 | + _saveAvatarOverrideUrl = save; | |
| 7332 | +} | |