Showing the changes to interface/src/Application.cpp (1 of 565 files). Show all
Unified · Split
| @@ -14,17 +14,20 @@ · 13 unmodified lines | |||
| 14 | #include <chrono> | 14 | #include <chrono> |
| 15 | #include <thread> | 15 | #include <thread> |
| 16 | 16 | ||
| 17 | #include <gl/Config.h> | ||
| 18 | #include <glm/glm.hpp> | 17 | #include <glm/glm.hpp> |
| 19 | #include <glm/gtx/component_wise.hpp> | 18 | #include <glm/gtx/component_wise.hpp> |
| 20 | #include <glm/gtx/quaternion.hpp> | 19 | #include <glm/gtx/quaternion.hpp> |
| 21 | #include <glm/gtx/vector_angle.hpp> | 20 | #include <glm/gtx/vector_angle.hpp> |
| 22 | #include <glm/gtc/type_ptr.hpp> | 21 | #include <glm/gtc/type_ptr.hpp> |
| 23 | 22 | ||
| 23 | #include <gl/Config.h> | ||
| 24 | |||
| 25 | #include <QtCore/QResource> | ||
| 24 | #include <QtCore/QAbstractNativeEventFilter> | 26 | #include <QtCore/QAbstractNativeEventFilter> |
| 25 | #include <QtCore/QCommandLineParser> | 27 | #include <QtCore/QCommandLineParser> |
| 26 | #include <QtCore/QMimeData> | 28 | #include <QtCore/QMimeData> |
| 27 | #include <QtCore/QThreadPool> | 29 | #include <QtCore/QThreadPool> |
| 30 | #include <QtCore/QFileSelector> | ||
| 28 | #include <QtConcurrent/QtConcurrentRun> | 31 | #include <QtConcurrent/QtConcurrentRun> |
| 29 | 32 | ||
| 30 | #include <QtGui/QScreen> | 33 | #include <QtGui/QScreen> |
| @@ -49,6 +52,7 @@ · 18 unmodified lines | |||
| 49 | 52 | ||
| 50 | #include <gl/QOpenGLContextWrapper.h> | 53 | #include <gl/QOpenGLContextWrapper.h> |
| 51 | 54 | ||
| 55 | #include <shared/FileUtils.h> | ||
| 52 | #include <shared/QtHelpers.h> | 56 | #include <shared/QtHelpers.h> |
| 53 | #include <shared/GlobalAppProperties.h> | 57 | #include <shared/GlobalAppProperties.h> |
| 54 | #include <StatTracker.h> | 58 | #include <StatTracker.h> |
| @@ -157,7 +161,7 @@ · 102 unmodified lines | |||
| 157 | #include "scripting/AssetMappingsScriptingInterface.h" | 161 | #include "scripting/AssetMappingsScriptingInterface.h" |
| 158 | #include "scripting/ClipboardScriptingInterface.h" | 162 | #include "scripting/ClipboardScriptingInterface.h" |
| 159 | #include "scripting/DesktopScriptingInterface.h" | 163 | #include "scripting/DesktopScriptingInterface.h" |
| 160 | #include "scripting/GlobalServicesScriptingInterface.h" | 164 | #include "scripting/AccountServicesScriptingInterface.h" |
| 161 | #include "scripting/HMDScriptingInterface.h" | 165 | #include "scripting/HMDScriptingInterface.h" |
| 162 | #include "scripting/MenuScriptingInterface.h" | 166 | #include "scripting/MenuScriptingInterface.h" |
| 163 | #include "scripting/SettingsScriptingInterface.h" | 167 | #include "scripting/SettingsScriptingInterface.h" |
| @@ -209,9 +213,8 @@ · 45 unmodified lines | |||
| 209 | #include "commerce/QmlCommerce.h" | 213 | #include "commerce/QmlCommerce.h" |
| 210 | 214 | ||
| 211 | #include "webbrowser/WebBrowserSuggestionsEngine.h" | 215 | #include "webbrowser/WebBrowserSuggestionsEngine.h" |
| 216 | #include <DesktopPreviewProvider.h> | ||
| 212 | 217 | ||
| 213 | // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU | ||
| 214 | // FIXME seems to be broken. | ||
| 215 | #if defined(Q_OS_WIN) | 218 | #if defined(Q_OS_WIN) |
| 216 | #include <VersionHelpers.h> | 219 | #include <VersionHelpers.h> |
| 217 | 220 | ||
| @@ -226,11 +229,17 @@ · 8 unmodified lines | |||
| 226 | #undef QT_BOOTSTRAPPED | 229 | #undef QT_BOOTSTRAPPED |
| 227 | #endif | 230 | #endif |
| 228 | 231 | ||
| 232 | // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU | ||
| 233 | // FIXME seems to be broken. | ||
| 229 | extern "C" { | 234 | extern "C" { |
| 230 | _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; | 235 | _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; |
| 231 | } | 236 | } |
| 232 | #endif | 237 | #endif |
| 233 | 238 | ||
| 239 | #if defined(Q_OS_ANDROID) | ||
| 240 | #include <android/log.h> | ||
| 241 | #endif | ||
| 242 | |||
| 234 | enum ApplicationEvent { | 243 | enum ApplicationEvent { |
| 235 | // Execute a lambda function | 244 | // Execute a lambda function |
| 236 | Lambda = QEvent::User + 1, | 245 | Lambda = QEvent::User + 1, |
| @@ -240,7 +249,6 @@ enum ApplicationEvent { · 3 unmodified lines | |||
| 240 | Idle, | 249 | Idle, |
| 241 | }; | 250 | }; |
| 242 | 251 | ||
| 243 | |||
| 244 | class RenderEventHandler : public QObject { | 252 | class RenderEventHandler : public QObject { |
| 245 | using Parent = QObject; | 253 | using Parent = QObject; |
| 246 | Q_OBJECT | 254 | Q_OBJECT |
| @@ -304,9 +312,19 @@ static QTimer locationUpdateTimer; · 57 unmodified lines | |||
| 304 | static QTimer identityPacketTimer; | 312 | static QTimer identityPacketTimer; |
| 305 | static QTimer pingTimer; | 313 | static QTimer pingTimer; |
| 306 | 314 | ||
| 307 | static const QString DISABLE_WATCHDOG_FLAG("HIFI_DISABLE_WATCHDOG"); | 315 | #if defined(Q_OS_ANDROID) |
| 316 | static bool DISABLE_WATCHDOG = true; | ||
| 317 | #else | ||
| 318 | static const QString DISABLE_WATCHDOG_FLAG{ "HIFI_DISABLE_WATCHDOG" }; | ||
| 308 | static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG); | 319 | static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG); |
| 320 | #endif | ||
| 309 | 321 | ||
| 322 | #if defined(USE_GLES) | ||
| 323 | static bool DISABLE_DEFERRED = true; | ||
| 324 | #else | ||
| 325 | static const QString RENDER_FORWARD{ "HIFI_RENDER_FORWARD" }; | ||
| 326 | static bool DISABLE_DEFERRED = QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD); | ||
| 327 | #endif | ||
| 310 | 328 | ||
| 311 | static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; | 329 | static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; |
| 312 | 330 | ||
| @@ -333,7 +351,7 @@ static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f; · 20 unmodified lines | |||
| 333 | static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND; | 351 | static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND; |
| 334 | 352 | ||
| 335 | static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html"; | 353 | static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html"; |
| 336 | static const QString INFO_HELP_PATH = "../../../html/tabletHelp.html"; | 354 | static const QString INFO_HELP_PATH = "html/tabletHelp.html"; |
| 337 | 355 | ||
| 338 | static const unsigned int THROTTLED_SIM_FRAMERATE = 15; | 356 | static const unsigned int THROTTLED_SIM_FRAMERATE = 15; |
| 339 | static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE; | 357 | static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE; |
| @@ -503,7 +521,13 @@ public: · 163 unmodified lines | |||
| 503 | } | 521 | } |
| 504 | 522 | ||
| 505 | if (message->message == WM_DEVICECHANGE) { | 523 | if (message->message == WM_DEVICECHANGE) { |
| 506 | Midi::USBchanged(); // re-scan the MIDI bus | 524 | const float MIN_DELTA_SECONDS = 2.0f; // de-bounce signal |
| 525 | static float lastTriggerTime = 0.0f; | ||
| 526 | const float deltaSeconds = secTimestampNow() - lastTriggerTime; | ||
| 527 | lastTriggerTime = secTimestampNow(); | ||
| 528 | if (deltaSeconds > MIN_DELTA_SECONDS) { | ||
| 529 | Midi::USBchanged(); // re-scan the MIDI bus | ||
| 530 | } | ||
| 507 | } | 531 | } |
| 508 | } | 532 | } |
| 509 | return false; | 533 | return false; |
| @@ -530,6 +554,26 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 20 unmodified lines | |||
| 530 | #ifdef Q_OS_WIN | 554 | #ifdef Q_OS_WIN |
| 531 | OutputDebugStringA(logMessage.toLocal8Bit().constData()); | 555 | OutputDebugStringA(logMessage.toLocal8Bit().constData()); |
| 532 | OutputDebugStringA("\n"); | 556 | OutputDebugStringA("\n"); |
| 557 | #elif defined Q_OS_ANDROID | ||
| 558 | const char * local=logMessage.toStdString().c_str(); | ||
| 559 | switch (type) { | ||
| 560 | case QtDebugMsg: | ||
| 561 | __android_log_write(ANDROID_LOG_DEBUG,"Interface",local); | ||
| 562 | break; | ||
| 563 | case QtInfoMsg: | ||
| 564 | __android_log_write(ANDROID_LOG_INFO,"Interface",local); | ||
| 565 | break; | ||
| 566 | case QtWarningMsg: | ||
| 567 | __android_log_write(ANDROID_LOG_WARN,"Interface",local); | ||
| 568 | break; | ||
| 569 | case QtCriticalMsg: | ||
| 570 | __android_log_write(ANDROID_LOG_ERROR,"Interface",local); | ||
| 571 | break; | ||
| 572 | case QtFatalMsg: | ||
| 573 | default: | ||
| 574 | __android_log_write(ANDROID_LOG_FATAL,"Interface",local); | ||
| 575 | abort(); | ||
| 576 | } | ||
| 533 | #endif | 577 | #endif |
| 534 | qApp->getLogger()->addMessage(qPrintable(logMessage + "\n")); | 578 | qApp->getLogger()->addMessage(qPrintable(logMessage + "\n")); |
| 535 | } | 579 | } |
| @@ -573,8 +617,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 37 unmodified lines | |||
| 573 | } | 617 | } |
| 574 | }; | 618 | }; |
| 575 | reportAndQuit("--protocolVersion", [&](FILE* fp) { | 619 | reportAndQuit("--protocolVersion", [&](FILE* fp) { |
| 576 | DependencyManager::set<AddressManager>(); | 620 | auto version = protocolVersionsSignatureBase64(); |
| 577 | auto version = DependencyManager::get<AddressManager>()->protocolVersion(); | ||
| 578 | fputs(version.toLatin1().data(), fp); | 621 | fputs(version.toLatin1().data(), fp); |
| 579 | }); | 622 | }); |
| 580 | reportAndQuit("--version", [&](FILE* fp) { | 623 | reportAndQuit("--version", [&](FILE* fp) { |
| @@ -594,6 +637,24 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 13 unmodified lines | |||
| 594 | qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir); | 637 | qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir); |
| 595 | } | 638 | } |
| 596 | 639 | ||
| 640 | // FIXME fix the OSX installer to install the resources.rcc binary instead of resource files and remove | ||
| 641 | // this conditional exclusion | ||
| 642 | #if !defined(Q_OS_OSX) | ||
| 643 | { | ||
| 644 | #if defined(Q_OS_ANDROID) | ||
| 645 | const QString resourcesBinaryFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/resources.rcc"; | ||
| 646 | #else | ||
| 647 | const QString resourcesBinaryFile = QCoreApplication::applicationDirPath() + "/resources.rcc"; | ||
| 648 | #endif | ||
| 649 | if (!QFile::exists(resourcesBinaryFile)) { | ||
| 650 | throw std::runtime_error("Unable to find primary resources"); | ||
| 651 | } | ||
| 652 | if (!QResource::registerResource(resourcesBinaryFile)) { | ||
| 653 | throw std::runtime_error("Unable to load primary resources"); | ||
| 654 | } | ||
| 655 | } | ||
| 656 | #endif | ||
| 657 | |||
| 597 | Setting::init(); | 658 | Setting::init(); |
| 598 | 659 | ||
| 599 | // Tell the plugin manager about our statically linked plugins | 660 | // Tell the plugin manager about our statically linked plugins |
| @@ -632,15 +693,16 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 32 unmodified lines | |||
| 632 | DependencyManager::set<PointerScriptingInterface>(); | 693 | DependencyManager::set<PointerScriptingInterface>(); |
| 633 | DependencyManager::set<PickScriptingInterface>(); | 694 | DependencyManager::set<PickScriptingInterface>(); |
| 634 | DependencyManager::set<Cursor::Manager>(); | 695 | DependencyManager::set<Cursor::Manager>(); |
| 696 | DependencyManager::set<DesktopPreviewProvider>(); | ||
| 635 | DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp)); | 697 | DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp)); |
| 636 | DependencyManager::set<StatTracker>(); | 698 | DependencyManager::set<StatTracker>(); |
| 637 | DependencyManager::set<ScriptEngines>(ScriptEngine::CLIENT_SCRIPT); | 699 | DependencyManager::set<ScriptEngines>(ScriptEngine::CLIENT_SCRIPT); |
| 638 | DependencyManager::set<Preferences>(); | 700 | DependencyManager::set<Preferences>(); |
| 639 | DependencyManager::set<recording::ClipCache>(); | ||
| 640 | DependencyManager::set<recording::Deck>(); | 701 | DependencyManager::set<recording::Deck>(); |
| 641 | DependencyManager::set<recording::Recorder>(); | 702 | DependencyManager::set<recording::Recorder>(); |
| 642 | DependencyManager::set<AddressManager>(); | 703 | DependencyManager::set<AddressManager>(); |
| 643 | DependencyManager::set<NodeList>(NodeType::Agent, listenPort); | 704 | DependencyManager::set<NodeList>(NodeType::Agent, listenPort); |
| 705 | DependencyManager::set<recording::ClipCache>(); | ||
| 644 | DependencyManager::set<GeometryCache>(); | 706 | DependencyManager::set<GeometryCache>(); |
| 645 | DependencyManager::set<ModelCache>(); | 707 | DependencyManager::set<ModelCache>(); |
| 646 | DependencyManager::set<ScriptCache>(); | 708 | DependencyManager::set<ScriptCache>(); |
| @@ -729,8 +791,10 @@ OverlayID _keyboardFocusHighlightID{ UNKNOWN_OVERLAY_ID }; · 82 unmodified lines | |||
| 729 | // | 791 | // |
| 730 | // So instead we create a new offscreen context to share with the QGLWidget, | 792 | // So instead we create a new offscreen context to share with the QGLWidget, |
| 731 | // and manually set THAT to be the shared context for the Chromium helper | 793 | // and manually set THAT to be the shared context for the Chromium helper |
| 794 | #if !defined(DISABLE_QML) | ||
| 732 | OffscreenGLCanvas* _chromiumShareContext { nullptr }; | 795 | OffscreenGLCanvas* _chromiumShareContext { nullptr }; |
| 733 | Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context); | 796 | Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context); |
| 797 | #endif | ||
| 734 | 798 | ||
| 735 | Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 }; | 799 | Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 }; |
| 736 | 800 | ||
| @@ -776,6 +840,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 39 unmodified lines | |||
| 776 | _sampleSound(nullptr) | 840 | _sampleSound(nullptr) |
| 777 | 841 | ||
| 778 | { | 842 | { |
| 843 | |||
| 779 | auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); | 844 | auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); |
| 780 | setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); | 845 | setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); |
| 781 | setProperty(hifi::properties::CRASHED, _previousSessionCrashed); | 846 | setProperty(hifi::properties::CRASHED, _previousSessionCrashed); |
| @@ -996,8 +1061,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 214 unmodified lines | |||
| 996 | DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress); | 1061 | DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress); |
| 997 | 1062 | ||
| 998 | // Inititalize sample before registering | 1063 | // Inititalize sample before registering |
| 999 | QFileInfo infSample = QFileInfo(PathUtils::resourcesPath() + "sounds/sample.wav"); | 1064 | _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav")); |
| 1000 | _sampleSound = DependencyManager::get<SoundCache>()->getSound(QUrl::fromLocalFile(infSample.absoluteFilePath())); | ||
| 1001 | 1065 | ||
| 1002 | auto scriptEngines = DependencyManager::get<ScriptEngines>().data(); | 1066 | auto scriptEngines = DependencyManager::get<ScriptEngines>().data(); |
| 1003 | scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){ | 1067 | scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){ |
| @@ -1082,9 +1146,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 78 unmodified lines | |||
| 1082 | // Make sure we don't time out during slow operations at startup | 1146 | // Make sure we don't time out during slow operations at startup |
| 1083 | updateHeartbeat(); | 1147 | updateHeartbeat(); |
| 1084 | 1148 | ||
| 1085 | // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success. | ||
| 1086 | DependencyManager::get<GeometryCache>()->initializeShapePipelines(); | ||
| 1087 | |||
| 1088 | // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value. | 1149 | // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value. |
| 1089 | // The value will be 0 if the user blew away settings this session, which is both a feature and a bug. | 1150 | // The value will be 0 if the user blew away settings this session, which is both a feature and a bug. |
| 1090 | static const QString TESTER = "HIFI_TESTER"; | 1151 | static const QString TESTER = "HIFI_TESTER"; |
| @@ -1731,7 +1792,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 640 unmodified lines | |||
| 1731 | static int lastCountOfNearbyAvatars = -1; | 1792 | static int lastCountOfNearbyAvatars = -1; |
| 1732 | QTimer* checkNearbyAvatarsTimer = new QTimer(this); | 1793 | QTimer* checkNearbyAvatarsTimer = new QTimer(this); |
| 1733 | checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok | 1794 | checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok |
| 1734 | connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() { | 1795 | connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, []() { |
| 1735 | auto avatarManager = DependencyManager::get<AvatarManager>(); | 1796 | auto avatarManager = DependencyManager::get<AvatarManager>(); |
| 1736 | int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(), | 1797 | int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(), |
| 1737 | NEARBY_AVATAR_RADIUS_METERS) - 1; | 1798 | NEARBY_AVATAR_RADIUS_METERS) - 1; |
| @@ -1770,9 +1831,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 32 unmodified lines | |||
| 1770 | PROFILE_RANGE(render, "Process Default Skybox"); | 1831 | PROFILE_RANGE(render, "Process Default Skybox"); |
| 1771 | auto textureCache = DependencyManager::get<TextureCache>(); | 1832 | auto textureCache = DependencyManager::get<TextureCache>(); |
| 1772 | 1833 | ||
| 1773 | auto skyboxUrl = PathUtils::resourcesPath().toStdString() + "images/Default-Sky-9-cubemap.ktx"; | 1834 | QFileSelector fileSelector; |
| 1835 | fileSelector.setExtraSelectors(FileUtils::getFileSelectors()); | ||
| 1836 | auto skyboxUrl = fileSelector.select(PathUtils::resourcesPath() + "images/Default-Sky-9-cubemap.ktx"); | ||
| 1774 | 1837 | ||
| 1775 | _defaultSkyboxTexture = gpu::Texture::unserialize(skyboxUrl); | 1838 | _defaultSkyboxTexture = gpu::Texture::unserialize(skyboxUrl.toStdString()); |
| 1776 | _defaultSkyboxAmbientTexture = _defaultSkyboxTexture; | 1839 | _defaultSkyboxAmbientTexture = _defaultSkyboxTexture; |
| 1777 | 1840 | ||
| 1778 | _defaultSkybox->setCubemap(_defaultSkyboxTexture); | 1841 | _defaultSkybox->setCubemap(_defaultSkyboxTexture); |
| @@ -1783,8 +1846,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 4 unmodified lines | |||
| 1783 | return entityServerNode && !isPhysicsEnabled(); | 1846 | return entityServerNode && !isPhysicsEnabled(); |
| 1784 | }); | 1847 | }); |
| 1785 | 1848 | ||
| 1786 | QFileInfo infSnap = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); | 1849 | _snapshotSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/snap.wav")); |
| 1787 | _snapshotSound = DependencyManager::get<SoundCache>()->getSound(QUrl::fromLocalFile(infSnap.absoluteFilePath())); | ||
| 1788 | 1850 | ||
| 1789 | QVariant testProperty = property(hifi::properties::TEST); | 1851 | QVariant testProperty = property(hifi::properties::TEST); |
| 1790 | qDebug() << testProperty; | 1852 | qDebug() << testProperty; |
| @@ -1852,6 +1914,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 61 unmodified lines | |||
| 1852 | DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](unsigned int rayPickID, bool value) { | 1914 | DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](unsigned int rayPickID, bool value) { |
| 1853 | DependencyManager::get<PickManager>()->setPrecisionPicking(rayPickID, value); | 1915 | DependencyManager::get<PickManager>()->setPrecisionPicking(rayPickID, value); |
| 1854 | }); | 1916 | }); |
| 1917 | EntityTreeRenderer::setRenderDebugHullsOperator([] { | ||
| 1918 | return Menu::getInstance()->isOptionChecked(MenuOption::PhysicsShowHulls); | ||
| 1919 | }); | ||
| 1855 | 1920 | ||
| 1856 | // Preload Tablet sounds | 1921 | // Preload Tablet sounds |
| 1857 | DependencyManager::get<TabletScriptingInterface>()->preloadSounds(); | 1922 | DependencyManager::get<TabletScriptingInterface>()->preloadSounds(); |
| @@ -2091,6 +2156,11 @@ void Application::cleanupBeforeQuit() { · 233 unmodified lines | |||
| 2091 | DependencyManager::destroy<AudioInjectorManager>(); | 2156 | DependencyManager::destroy<AudioInjectorManager>(); |
| 2092 | DependencyManager::destroy<AudioScriptingInterface>(); | 2157 | DependencyManager::destroy<AudioScriptingInterface>(); |
| 2093 | 2158 | ||
| 2159 | // The PointerManager must be destroyed before the PickManager because when a Pointer is deleted, | ||
| 2160 | // it accesses the PickManager to delete its associated Pick | ||
| 2161 | DependencyManager::destroy<PointerManager>(); | ||
| 2162 | DependencyManager::destroy<PickManager>(); | ||
| 2163 | |||
| 2094 | qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; | 2164 | qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; |
| 2095 | } | 2165 | } |
| 2096 | 2166 | ||
| @@ -2174,11 +2244,16 @@ void Application::initializeGL() { · 77 unmodified lines | |||
| 2174 | } | 2244 | } |
| 2175 | 2245 | ||
| 2176 | _glWidget->makeCurrent(); | 2246 | _glWidget->makeCurrent(); |
| 2177 | _chromiumShareContext = new OffscreenGLCanvas(); | 2247 | |
| 2178 | _chromiumShareContext->setObjectName("ChromiumShareContext"); | 2248 | #if !defined(DISABLE_QML) |
| 2179 | _chromiumShareContext->create(_glWidget->qglContext()); | 2249 | if (!nsightActive()) { |
| 2180 | _chromiumShareContext->makeCurrent(); | 2250 | _chromiumShareContext = new OffscreenGLCanvas(); |
| 2181 | qt_gl_set_global_share_context(_chromiumShareContext->getContext()); | 2251 | _chromiumShareContext->setObjectName("ChromiumShareContext"); |
| 2252 | _chromiumShareContext->create(_glWidget->qglContext()); | ||
| 2253 | _chromiumShareContext->makeCurrent(); | ||
| 2254 | qt_gl_set_global_share_context(_chromiumShareContext->getContext()); | ||
| 2255 | } | ||
| 2256 | #endif | ||
| 2182 | 2257 | ||
| 2183 | _glWidget->makeCurrent(); | 2258 | _glWidget->makeCurrent(); |
| 2184 | gpu::Context::init<gpu::gl::GLBackend>(); | 2259 | gpu::Context::init<gpu::gl::GLBackend>(); |
| @@ -2195,13 +2270,17 @@ void Application::initializeGL() { · 10 unmodified lines | |||
| 2195 | // Set up the render engine | 2270 | // Set up the render engine |
| 2196 | render::CullFunctor cullFunctor = LODManager::shouldRender; | 2271 | render::CullFunctor cullFunctor = LODManager::shouldRender; |
| 2197 | static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD"; | 2272 | static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD"; |
| 2198 | bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD); | ||
| 2199 | _renderEngine->addJob<UpdateSceneTask>("UpdateScene"); | 2273 | _renderEngine->addJob<UpdateSceneTask>("UpdateScene"); |
| 2200 | _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor); | 2274 | #ifndef Q_OS_ANDROID |
| 2201 | _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred); | 2275 | _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor, !DISABLE_DEFERRED); |
| 2276 | #endif | ||
| 2277 | _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, !DISABLE_DEFERRED); | ||
| 2202 | _renderEngine->load(); | 2278 | _renderEngine->load(); |
| 2203 | _renderEngine->registerScene(_main3DScene); | 2279 | _renderEngine->registerScene(_main3DScene); |
| 2204 | 2280 | ||
| 2281 | // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success. | ||
| 2282 | DependencyManager::get<GeometryCache>()->initializeShapePipelines(); | ||
| 2283 | |||
| 2205 | _offscreenContext = new OffscreenGLCanvas(); | 2284 | _offscreenContext = new OffscreenGLCanvas(); |
| 2206 | _offscreenContext->setObjectName("MainThreadContext"); | 2285 | _offscreenContext->setObjectName("MainThreadContext"); |
| 2207 | _offscreenContext->create(_glWidget->qglContext()); | 2286 | _offscreenContext->create(_glWidget->qglContext()); |
| @@ -2285,7 +2364,7 @@ void Application::initializeUi() { · 77 unmodified lines | |||
| 2285 | QUrl{ "hifi/commerce/wallet/SecurityImageChange.qml" }, | 2364 | QUrl{ "hifi/commerce/wallet/SecurityImageChange.qml" }, |
| 2286 | QUrl{ "hifi/commerce/wallet/SecurityImageModel.qml" }, | 2365 | QUrl{ "hifi/commerce/wallet/SecurityImageModel.qml" }, |
| 2287 | QUrl{ "hifi/commerce/wallet/SecurityImageSelection.qml" }, | 2366 | QUrl{ "hifi/commerce/wallet/SecurityImageSelection.qml" }, |
| 2288 | QUrl{ "hifi/commerce/wallet/SendMoney.qml" }, | 2367 | QUrl{ "hifi/commerce/wallet/sendMoney/SendMoney.qml" }, |
| 2289 | QUrl{ "hifi/commerce/wallet/Wallet.qml" }, | 2368 | QUrl{ "hifi/commerce/wallet/Wallet.qml" }, |
| 2290 | QUrl{ "hifi/commerce/wallet/WalletHome.qml" }, | 2369 | QUrl{ "hifi/commerce/wallet/WalletHome.qml" }, |
| 2291 | QUrl{ "hifi/commerce/wallet/WalletSetup.qml" }, | 2370 | QUrl{ "hifi/commerce/wallet/WalletSetup.qml" }, |
| @@ -2306,8 +2385,7 @@ void Application::initializeUi() { · 14 unmodified lines | |||
| 2306 | offscreenUi->setProxyWindow(_window->windowHandle()); | 2385 | offscreenUi->setProxyWindow(_window->windowHandle()); |
| 2307 | // OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to | 2386 | // OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to |
| 2308 | // support the window management and scripting proxies for VR use | 2387 | // support the window management and scripting proxies for VR use |
| 2309 | offscreenUi->createDesktop(QString("hifi/Desktop.qml")); | 2388 | offscreenUi->createDesktop(PathUtils::qmlUrl("hifi/Desktop.qml")); |
| 2310 | |||
| 2311 | // FIXME either expose so that dialogs can set this themselves or | 2389 | // FIXME either expose so that dialogs can set this themselves or |
| 2312 | // do better detection in the offscreen UI of what has focus | 2390 | // do better detection in the offscreen UI of what has focus |
| 2313 | offscreenUi->setNavigationFocused(false); | 2391 | offscreenUi->setNavigationFocused(false); |
| @@ -2374,9 +2452,11 @@ void Application::initializeUi() { · 60 unmodified lines | |||
| 2374 | surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data()); | 2452 | surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data()); |
| 2375 | surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data()); | 2453 | surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data()); |
| 2376 | 2454 | ||
| 2377 | surfaceContext->setContextProperty("Account", GlobalServicesScriptingInterface::getInstance()); | 2455 | surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED |
| 2456 | surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED | ||
| 2457 | surfaceContext->setContextProperty("AccountServices", AccountServicesScriptingInterface::getInstance()); | ||
| 2458 | |||
| 2378 | surfaceContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface); | 2459 | surfaceContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface); |
| 2379 | surfaceContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); | ||
| 2380 | surfaceContext->setContextProperty("FaceTracker", DependencyManager::get<DdeFaceTracker>().data()); | 2460 | surfaceContext->setContextProperty("FaceTracker", DependencyManager::get<DdeFaceTracker>().data()); |
| 2381 | surfaceContext->setContextProperty("AvatarManager", DependencyManager::get<AvatarManager>().data()); | 2461 | surfaceContext->setContextProperty("AvatarManager", DependencyManager::get<AvatarManager>().data()); |
| 2382 | surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface); | 2462 | surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface); |
| @@ -2442,7 +2522,7 @@ void Application::initializeUi() { · 59 unmodified lines | |||
| 2442 | offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2); | 2522 | offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2); |
| 2443 | } | 2523 | } |
| 2444 | 2524 | ||
| 2445 | void Application::updateCamera(RenderArgs& renderArgs) { | 2525 | void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) { |
| 2446 | PROFILE_RANGE(render, __FUNCTION__); | 2526 | PROFILE_RANGE(render, __FUNCTION__); |
| 2447 | PerformanceTimer perfTimer("updateCamera"); | 2527 | PerformanceTimer perfTimer("updateCamera"); |
| 2448 | 2528 | ||
| @@ -2457,6 +2537,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 8 unmodified lines | |||
| 2457 | // Using the latter will cause the camera to wobble with idle animations, | 2537 | // Using the latter will cause the camera to wobble with idle animations, |
| 2458 | // or with changes from the face tracker | 2538 | // or with changes from the face tracker |
| 2459 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { | 2539 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 2540 | _thirdPersonHMDCameraBoomValid= false; | ||
| 2460 | if (isHMDMode()) { | 2541 | if (isHMDMode()) { |
| 2461 | mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix(); | 2542 | mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix(); |
| 2462 | _myCamera.setPosition(extractTranslation(camMat)); | 2543 | _myCamera.setPosition(extractTranslation(camMat)); |
| @@ -2469,12 +2550,25 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 6 unmodified lines | |||
| 2469 | } | 2550 | } |
| 2470 | else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | 2551 | else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 2471 | if (isHMDMode()) { | 2552 | if (isHMDMode()) { |
| 2472 | auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix(); | 2553 | |
| 2473 | _myCamera.setOrientation(glm::normalize(glmExtractRotation(hmdWorldMat))); | 2554 | if (!_thirdPersonHMDCameraBoomValid) { |
| 2474 | _myCamera.setPosition(extractTranslation(hmdWorldMat) + | 2555 | const glm::vec3 CAMERA_OFFSET = glm::vec3(0.0f, 0.0f, 0.7f); |
| 2475 | myAvatar->getWorldOrientation() * boomOffset); | 2556 | _thirdPersonHMDCameraBoom = cancelOutRollAndPitch(myAvatar->getHMDSensorOrientation()) * CAMERA_OFFSET; |
| 2557 | _thirdPersonHMDCameraBoomValid = true; | ||
| 2558 | } | ||
| 2559 | |||
| 2560 | glm::mat4 thirdPersonCameraSensorToWorldMatrix = myAvatar->getSensorToWorldMatrix(); | ||
| 2561 | |||
| 2562 | const glm::vec3 cameraPos = myAvatar->getHMDSensorPosition() + _thirdPersonHMDCameraBoom * myAvatar->getBoomLength(); | ||
| 2563 | glm::mat4 sensorCameraMat = createMatFromQuatAndPos(myAvatar->getHMDSensorOrientation(), cameraPos); | ||
| 2564 | glm::mat4 worldCameraMat = thirdPersonCameraSensorToWorldMatrix * sensorCameraMat; | ||
| 2565 | |||
| 2566 | _myCamera.setOrientation(glm::normalize(glmExtractRotation(worldCameraMat))); | ||
| 2567 | _myCamera.setPosition(extractTranslation(worldCameraMat)); | ||
| 2476 | } | 2568 | } |
| 2477 | else { | 2569 | else { |
| 2570 | _thirdPersonHMDCameraBoomValid = false; | ||
| 2571 | |||
| 2478 | _myCamera.setOrientation(myAvatar->getHead()->getOrientation()); | 2572 | _myCamera.setOrientation(myAvatar->getHead()->getOrientation()); |
| 2479 | if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | 2573 | if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { |
| 2480 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() | 2574 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() |
| @@ -2487,6 +2581,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 6 unmodified lines | |||
| 2487 | } | 2581 | } |
| 2488 | } | 2582 | } |
| 2489 | else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 2583 | else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 2584 | _thirdPersonHMDCameraBoomValid= false; | ||
| 2490 | if (isHMDMode()) { | 2585 | if (isHMDMode()) { |
| 2491 | auto mirrorBodyOrientation = myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)); | 2586 | auto mirrorBodyOrientation = myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)); |
| 2492 | 2587 | ||
| @@ -2521,6 +2616,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 28 unmodified lines | |||
| 2521 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; | 2616 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; |
| 2522 | } | 2617 | } |
| 2523 | else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) { | 2618 | else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) { |
| 2619 | _thirdPersonHMDCameraBoomValid= false; | ||
| 2524 | EntityItemPointer cameraEntity = _myCamera.getCameraEntityPointer(); | 2620 | EntityItemPointer cameraEntity = _myCamera.getCameraEntityPointer(); |
| 2525 | if (cameraEntity != nullptr) { | 2621 | if (cameraEntity != nullptr) { |
| 2526 | if (isHMDMode()) { | 2622 | if (isHMDMode()) { |
| @@ -2628,7 +2724,8 @@ void Application::showHelp() { · 101 unmodified lines | |||
| 2628 | queryString.addQueryItem("defaultTab", defaultTab); | 2724 | queryString.addQueryItem("defaultTab", defaultTab); |
| 2629 | auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>(); | 2725 | auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>(); |
| 2630 | TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET)); | 2726 | TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET)); |
| 2631 | tablet->gotoWebScreen(INFO_HELP_PATH + "?" + queryString.toString()); | 2727 | tablet->gotoWebScreen(PathUtils::resourcesPath() + INFO_HELP_PATH + "?" + queryString.toString()); |
| 2728 | DependencyManager::get<HMDScriptingInterface>()->openTablet(); | ||
| 2632 | //InfoView::show(INFO_HELP_PATH, false, queryString.toString()); | 2729 | //InfoView::show(INFO_HELP_PATH, false, queryString.toString()); |
| 2633 | } | 2730 | } |
| 2634 | 2731 | ||
| @@ -3884,12 +3981,18 @@ void Application::idle() { · 1249 unmodified lines | |||
| 3884 | PROFILE_COUNTER_IF_CHANGED(app, "pendingProcessing", int, DependencyManager::get<StatTracker>()->getStat("PendingProcessing").toInt()); | 3981 | PROFILE_COUNTER_IF_CHANGED(app, "pendingProcessing", int, DependencyManager::get<StatTracker>()->getStat("PendingProcessing").toInt()); |
| 3885 | auto renderConfig = _renderEngine->getConfiguration(); | 3982 | auto renderConfig = _renderEngine->getConfiguration(); |
| 3886 | PROFILE_COUNTER_IF_CHANGED(render, "gpuTime", float, (float)_gpuContext->getFrameTimerGPUAverage()); | 3983 | PROFILE_COUNTER_IF_CHANGED(render, "gpuTime", float, (float)_gpuContext->getFrameTimerGPUAverage()); |
| 3984 | auto opaqueRangeTimer = renderConfig->getConfig("OpaqueRangeTimer"); | ||
| 3985 | auto linearDepth = renderConfig->getConfig("LinearDepth"); | ||
| 3986 | auto surfaceGeometry = renderConfig->getConfig("SurfaceGeometry"); | ||
| 3987 | auto renderDeferred = renderConfig->getConfig("RenderDeferred"); | ||
| 3988 | auto toneAndPostRangeTimer = renderConfig->getConfig("ToneAndPostRangeTimer"); | ||
| 3989 | |||
| 3887 | PROFILE_COUNTER(render_detail, "gpuTimes", { | 3990 | PROFILE_COUNTER(render_detail, "gpuTimes", { |
| 3888 | { "OpaqueRangeTimer", renderConfig->getConfig("OpaqueRangeTimer")->property("gpuRunTime") }, | 3991 | { "OpaqueRangeTimer", opaqueRangeTimer ? opaqueRangeTimer->property("gpuRunTime") : 0 }, |
| 3889 | { "LinearDepth", renderConfig->getConfig("LinearDepth")->property("gpuRunTime") }, | 3992 | { "LinearDepth", linearDepth ? linearDepth->property("gpuRunTime") : 0 }, |
| 3890 | { "SurfaceGeometry", renderConfig->getConfig("SurfaceGeometry")->property("gpuRunTime") }, | 3993 | { "SurfaceGeometry", surfaceGeometry ? surfaceGeometry->property("gpuRunTime") : 0 }, |
| 3891 | { "RenderDeferred", renderConfig->getConfig("RenderDeferred")->property("gpuRunTime") }, | 3994 | { "RenderDeferred", renderDeferred ? renderDeferred->property("gpuRunTime") : 0 }, |
| 3892 | { "ToneAndPostRangeTimer", renderConfig->getConfig("ToneAndPostRangeTimer")->property("gpuRunTime") } | 3995 | { "ToneAndPostRangeTimer", toneAndPostRangeTimer ? toneAndPostRangeTimer->property("gpuRunTime") : 0 } |
| 3893 | }); | 3996 | }); |
| 3894 | 3997 | ||
| 3895 | PROFILE_RANGE(app, __FUNCTION__); | 3998 | PROFILE_RANGE(app, __FUNCTION__); |
| @@ -4254,9 +4357,9 @@ void Application::init() { · 358 unmodified lines | |||
| 4254 | 4357 | ||
| 4255 | // Make sure Login state is up to date | 4358 | // Make sure Login state is up to date |
| 4256 | DependencyManager::get<DialogsManager>()->toggleLoginDialog(); | 4359 | DependencyManager::get<DialogsManager>()->toggleLoginDialog(); |
| 4257 | 4360 | if (!DISABLE_DEFERRED) { | |
| 4258 | DependencyManager::get<DeferredLightingEffect>()->init(); | 4361 | DependencyManager::get<DeferredLightingEffect>()->init(); |
| 4259 | 4362 | } | |
| 4260 | DependencyManager::get<AvatarManager>()->init(); | 4363 | DependencyManager::get<AvatarManager>()->init(); |
| 4261 | 4364 | ||
| 4262 | _timerStart.start(); | 4365 | _timerStart.start(); |
| @@ -4331,8 +4434,9 @@ void Application::updateLOD(float deltaTime) const { · 68 unmodified lines | |||
| 4331 | float presentTime = getActiveDisplayPlugin()->getAveragePresentTime(); | 4434 | float presentTime = getActiveDisplayPlugin()->getAveragePresentTime(); |
| 4332 | float engineRunTime = (float)(_renderEngine->getConfiguration().get()->getCPURunTime()); | 4435 | float engineRunTime = (float)(_renderEngine->getConfiguration().get()->getCPURunTime()); |
| 4333 | float gpuTime = getGPUContext()->getFrameTimerGPUAverage(); | 4436 | float gpuTime = getGPUContext()->getFrameTimerGPUAverage(); |
| 4334 | float maxRenderTime = glm::max(gpuTime, glm::max(presentTime, engineRunTime)); | 4437 | auto lodManager = DependencyManager::get<LODManager>(); |
| 4335 | DependencyManager::get<LODManager>()->autoAdjustLOD(maxRenderTime, deltaTime); | 4438 | lodManager->setRenderTimes(presentTime, engineRunTime, gpuTime); |
| 4439 | lodManager->autoAdjustLOD(deltaTime); | ||
| 4336 | } else { | 4440 | } else { |
| 4337 | DependencyManager::get<LODManager>()->resetLODAdjust(); | 4441 | DependencyManager::get<LODManager>()->resetLODAdjust(); |
| 4338 | } | 4442 | } |
| @@ -5005,8 +5109,6 @@ void Application::update(float deltaTime) { · 666 unmodified lines | |||
| 5005 | } | 5109 | } |
| 5006 | } | 5110 | } |
| 5007 | 5111 | ||
| 5008 | PerformanceTimer perfTimer("misc"); | ||
| 5009 | |||
| 5010 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 5112 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 5011 | PerformanceWarning warn(showWarnings, "Application::update()"); | 5113 | PerformanceWarning warn(showWarnings, "Application::update()"); |
| 5012 | 5114 | ||
| @@ -5015,11 +5117,13 @@ void Application::update(float deltaTime) { · 2 unmodified lines | |||
| 5015 | // TODO: break these out into distinct perfTimers when they prove interesting | 5117 | // TODO: break these out into distinct perfTimers when they prove interesting |
| 5016 | { | 5118 | { |
| 5017 | PROFILE_RANGE(app, "PickManager"); | 5119 | PROFILE_RANGE(app, "PickManager"); |
| 5120 | PerformanceTimer perfTimer("pickManager"); | ||
| 5018 | DependencyManager::get<PickManager>()->update(); | 5121 | DependencyManager::get<PickManager>()->update(); |
| 5019 | } | 5122 | } |
| 5020 | 5123 | ||
| 5021 | { | 5124 | { |
| 5022 | PROFILE_RANGE(app, "PointerManager"); | 5125 | PROFILE_RANGE(app, "PointerManager"); |
| 5126 | PerformanceTimer perfTimer("pointerManager"); | ||
| 5023 | DependencyManager::get<PointerManager>()->update(); | 5127 | DependencyManager::get<PointerManager>()->update(); |
| 5024 | } | 5128 | } |
| 5025 | 5129 | ||
| @@ -5045,8 +5149,8 @@ void Application::update(float deltaTime) { · 19 unmodified lines | |||
| 5045 | // Update my voxel servers with my current voxel query... | 5149 | // Update my voxel servers with my current voxel query... |
| 5046 | { | 5150 | { |
| 5047 | PROFILE_RANGE_EX(app, "QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); | 5151 | PROFILE_RANGE_EX(app, "QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); |
| 5048 | QMutexLocker viewLocker(&_viewMutex); | ||
| 5049 | PerformanceTimer perfTimer("queryOctree"); | 5152 | PerformanceTimer perfTimer("queryOctree"); |
| 5153 | QMutexLocker viewLocker(&_viewMutex); | ||
| 5050 | quint64 sinceLastQuery = now - _lastQueriedTime; | 5154 | quint64 sinceLastQuery = now - _lastQueriedTime; |
| 5051 | const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; | 5155 | const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; |
| 5052 | bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY; | 5156 | bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY; |
| @@ -5082,12 +5186,14 @@ void Application::update(float deltaTime) { · 29 unmodified lines | |||
| 5082 | } | 5186 | } |
| 5083 | } | 5187 | } |
| 5084 | 5188 | ||
| 5085 | avatarManager->postUpdate(deltaTime, getMain3DScene()); | ||
| 5086 | |||
| 5087 | |||
| 5088 | { | 5189 | { |
| 5089 | PROFILE_RANGE_EX(app, "PreRenderLambdas", 0xffff0000, (uint64_t)0); | 5190 | PerformanceTimer perfTimer("avatarManager/postUpdate"); |
| 5191 | avatarManager->postUpdate(deltaTime, getMain3DScene()); | ||
| 5192 | } | ||
| 5090 | 5193 | ||
| 5194 | { | ||
| 5195 | PROFILE_RANGE_EX(app, "PostUpdateLambdas", 0xffff0000, (uint64_t)0); | ||
| 5196 | PerformanceTimer perfTimer("postUpdateLambdas"); | ||
| 5091 | std::unique_lock<std::mutex> guard(_postUpdateLambdasLock); | 5197 | std::unique_lock<std::mutex> guard(_postUpdateLambdasLock); |
| 5092 | for (auto& iter : _postUpdateLambdas) { | 5198 | for (auto& iter : _postUpdateLambdas) { |
| 5093 | iter.second(); | 5199 | iter.second(); |
| @@ -5095,7 +5201,9 @@ void Application::update(float deltaTime) { · 1 unmodified line | |||
| 5095 | _postUpdateLambdas.clear(); | 5201 | _postUpdateLambdas.clear(); |
| 5096 | } | 5202 | } |
| 5097 | 5203 | ||
| 5098 | editRenderArgs([this](AppRenderArgs& appRenderArgs) { | 5204 | |
| 5205 | editRenderArgs([this, deltaTime](AppRenderArgs& appRenderArgs) { | ||
| 5206 | PerformanceTimer perfTimer("editRenderArgs"); | ||
| 5099 | appRenderArgs._headPose= getHMDSensorPose(); | 5207 | appRenderArgs._headPose= getHMDSensorPose(); |
| 5100 | 5208 | ||
| 5101 | auto myAvatar = getMyAvatar(); | 5209 | auto myAvatar = getMyAvatar(); |
| @@ -5141,7 +5249,7 @@ void Application::update(float deltaTime) { · 39 unmodified lines | |||
| 5141 | resizeGL(); | 5249 | resizeGL(); |
| 5142 | } | 5250 | } |
| 5143 | 5251 | ||
| 5144 | this->updateCamera(appRenderArgs._renderArgs); | 5252 | this->updateCamera(appRenderArgs._renderArgs, deltaTime); |
| 5145 | appRenderArgs._eyeToWorld = _myCamera.getTransform(); | 5253 | appRenderArgs._eyeToWorld = _myCamera.getTransform(); |
| 5146 | appRenderArgs._isStereo = false; | 5254 | appRenderArgs._isStereo = false; |
| 5147 | 5255 | ||
| @@ -5209,12 +5317,20 @@ void Application::update(float deltaTime) { · 61 unmodified lines | |||
| 5209 | } | 5317 | } |
| 5210 | }); | 5318 | }); |
| 5211 | 5319 | ||
| 5212 | AnimDebugDraw::getInstance().update(); | 5320 | { |
| 5321 | PerformanceTimer perfTimer("limitless"); | ||
| 5322 | AnimDebugDraw::getInstance().update(); | ||
| 5323 | } | ||
| 5213 | 5324 | ||
| 5214 | DependencyManager::get<LimitlessVoiceRecognitionScriptingInterface>()->update(); | 5325 | { |
| 5326 | PerformanceTimer perfTimer("limitless"); | ||
| 5327 | DependencyManager::get<LimitlessVoiceRecognitionScriptingInterface>()->update(); | ||
| 5328 | } | ||
| 5215 | 5329 | ||
| 5216 | // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over | 5330 | { // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over |
| 5217 | getMain3DScene()->enqueueFrame(); | 5331 | PerformanceTimer perfTimer("enqueueFrame"); |
| 5332 | getMain3DScene()->enqueueFrame(); | ||
| 5333 | } | ||
| 5218 | } | 5334 | } |
| 5219 | 5335 | ||
| 5220 | void Application::sendAvatarViewFrustum() { | 5336 | void Application::sendAvatarViewFrustum() { |
| @@ -5435,7 +5551,7 @@ void Application::clearDomainOctreeDetails() { · 214 unmodified lines | |||
| 5435 | 5551 | ||
| 5436 | auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); | 5552 | auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); |
| 5437 | 5553 | ||
| 5438 | skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT); | 5554 | skyStage->setBackgroundMode(graphics::SunSkyStage::SKY_DEFAULT); |
| 5439 | 5555 | ||
| 5440 | DependencyManager::get<AnimationCache>()->clearUnusedResources(); | 5556 | DependencyManager::get<AnimationCache>()->clearUnusedResources(); |
| 5441 | DependencyManager::get<ModelCache>()->clearUnusedResources(); | 5557 | DependencyManager::get<ModelCache>()->clearUnusedResources(); |
| @@ -5722,10 +5838,13 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 280 unmodified lines | |||
| 5722 | scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, | 5838 | scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, |
| 5723 | LocationScriptingInterface::locationSetter); | 5839 | LocationScriptingInterface::locationSetter); |
| 5724 | 5840 | ||
| 5841 | #if !defined(Q_OS_ANDROID) | ||
| 5725 | scriptEngine->registerFunction("OverlayWebWindow", QmlWebWindowClass::constructor); | 5842 | scriptEngine->registerFunction("OverlayWebWindow", QmlWebWindowClass::constructor); |
| 5843 | #endif | ||
| 5726 | scriptEngine->registerFunction("OverlayWindow", QmlWindowClass::constructor); | 5844 | scriptEngine->registerFunction("OverlayWindow", QmlWindowClass::constructor); |
| 5727 | 5845 | ||
| 5728 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); | 5846 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 5847 | scriptEngine->registerGlobalObject("DesktopPreviewProvider", DependencyManager::get<DesktopPreviewProvider>().data()); | ||
| 5729 | scriptEngine->registerGlobalObject("Stats", Stats::getInstance()); | 5848 | scriptEngine->registerGlobalObject("Stats", Stats::getInstance()); |
| 5730 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); | 5849 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 5731 | scriptEngine->registerGlobalObject("Snapshot", DependencyManager::get<Snapshot>().data()); | 5850 | scriptEngine->registerGlobalObject("Snapshot", DependencyManager::get<Snapshot>().data()); |
| @@ -5745,10 +5864,11 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 13 unmodified lines | |||
| 5745 | scriptEngine->registerGlobalObject("ModelCache", DependencyManager::get<ModelCache>().data()); | 5864 | scriptEngine->registerGlobalObject("ModelCache", DependencyManager::get<ModelCache>().data()); |
| 5746 | scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data()); | 5865 | scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data()); |
| 5747 | 5866 | ||
| 5748 | scriptEngine->registerGlobalObject("Account", GlobalServicesScriptingInterface::getInstance()); | ||
| 5749 | scriptEngine->registerGlobalObject("DialogsManager", _dialogsManagerScriptingInterface); | 5867 | scriptEngine->registerGlobalObject("DialogsManager", _dialogsManagerScriptingInterface); |
| 5750 | 5868 | ||
| 5751 | scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance()); | 5869 | scriptEngine->registerGlobalObject("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED |
| 5870 | scriptEngine->registerGlobalObject("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED | ||
| 5871 | scriptEngine->registerGlobalObject("AccountServices", AccountServicesScriptingInterface::getInstance()); | ||
| 5752 | qScriptRegisterMetaType(scriptEngine.data(), DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue); | 5872 | qScriptRegisterMetaType(scriptEngine.data(), DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue); |
| 5753 | 5873 | ||
| 5754 | scriptEngine->registerGlobalObject("FaceTracker", DependencyManager::get<DdeFaceTracker>().data()); | 5874 | scriptEngine->registerGlobalObject("FaceTracker", DependencyManager::get<DdeFaceTracker>().data()); |
| @@ -6148,7 +6268,7 @@ void Application::showAssetServerWidget(QString filePath) { · 393 unmodified lines | |||
| 6148 | if (!hmd->getShouldShowTablet() && !isHMDMode()) { | 6268 | if (!hmd->getShouldShowTablet() && !isHMDMode()) { |
| 6149 | DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload); | 6269 | DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload); |
| 6150 | } else { | 6270 | } else { |
| 6151 | static const QUrl url("hifi/dialogs/TabletAssetServer.qml"); | 6271 | static const QUrl url("../dialogs/TabletAssetServer.qml"); |
| 6152 | tablet->pushOntoStack(url); | 6272 | tablet->pushOntoStack(url); |
| 6153 | } | 6273 | } |
| 6154 | } | 6274 | } |
| @@ -6777,6 +6897,15 @@ void Application::loadAddAvatarBookmarkDialog() const { · 622 unmodified lines | |||
| 6777 | avatarBookmarks->addBookmark(); | 6897 | avatarBookmarks->addBookmark(); |
| 6778 | } | 6898 | } |
| 6779 | 6899 | ||
| 6900 | void Application::loadAvatarBrowser() const { | ||
| 6901 | auto tablet = dynamic_cast<TabletProxy*>(DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system")); | ||
| 6902 | // construct the url to the marketplace item | ||
| 6903 | QString url = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/marketplace?category=avatars"; | ||
| 6904 | QString MARKETPLACES_INJECT_SCRIPT_PATH = "file:///" + qApp->applicationDirPath() + "/scripts/system/html/js/marketplacesInject.js"; | ||
| 6905 | tablet->gotoWebScreen(url, MARKETPLACES_INJECT_SCRIPT_PATH); | ||
| 6906 | DependencyManager::get<HMDScriptingInterface>()->openTablet(); | ||
| 6907 | } | ||
| 6908 | |||
| 6780 | void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) { | 6909 | void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) { |
| 6781 | postLambdaEvent([notify, includeAnimated, aspectRatio, this] { | 6910 | postLambdaEvent([notify, includeAnimated, aspectRatio, this] { |
| 6782 | // Get a screenshot and save it | 6911 | // Get a screenshot and save it |
| @@ -6794,7 +6923,8 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa · 11 unmodified lines | |||
| 6794 | 6923 | ||
| 6795 | void Application::takeSecondaryCameraSnapshot() { | 6924 | void Application::takeSecondaryCameraSnapshot() { |
| 6796 | postLambdaEvent([this] { | 6925 | postLambdaEvent([this] { |
| 6797 | Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot()); | 6926 | QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot()); |
| 6927 | emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true); | ||
| 6798 | }); | 6928 | }); |
| 6799 | } | 6929 | } |
| 6800 | 6930 | ||
| @@ -7358,11 +7488,13 @@ void Application::updateThreadPoolCount() const { · 557 unmodified lines | |||
| 7358 | } | 7488 | } |
| 7359 | 7489 | ||
| 7360 | void Application::updateSystemTabletMode() { | 7490 | void Application::updateSystemTabletMode() { |
| 7361 | qApp->setProperty(hifi::properties::HMD, isHMDMode()); | 7491 | if (_settingsLoaded) { |
| 7362 | if (isHMDMode()) { | 7492 | qApp->setProperty(hifi::properties::HMD, isHMDMode()); |
| 7363 | DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getHmdTabletBecomesToolbarSetting()); | 7493 | if (isHMDMode()) { |
| 7364 | } else { | 7494 | DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getHmdTabletBecomesToolbarSetting()); |
| 7365 | DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getDesktopTabletBecomesToolbarSetting()); | 7495 | } else { |
| 7496 | DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getDesktopTabletBecomesToolbarSetting()); | ||
| 7497 | } | ||
| 7366 | } | 7498 | } |
| 7367 | } | 7499 | } |
| 7368 | 7500 | ||