Showing the changes to interface/src/Application.cpp (1 of 87 files). Show all
Unified · Split
| @@ -252,7 +252,7 @@ public: · 251 unmodified lines | ||
| 252 | 252 | static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND; |
| 253 | 253 | static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large |
| 254 | 254 | static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples |
| 255 | − | |
| 255 | + | |
| 256 | 256 | // Set the heartbeat on launch |
| 257 | 257 | DeadlockWatchdogThread() { |
| 258 | 258 | setObjectName("Deadlock Watchdog"); |
| @@ -616,7 +616,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 357 unmodified lines | ||
| 616 | 616 | _window->setWindowTitle("Interface"); |
| 617 | 617 | |
| 618 | 618 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us |
| 619 | − | |
| 619 | + | |
| 620 | 620 | auto nodeList = DependencyManager::get<NodeList>(); |
| 621 | 621 | |
| 622 | 622 | // Set up a watchdog thread to intentionally crash the application on deadlocks |
| @@ -637,6 +637,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 14 unmodified lines | ||
| 637 | 637 | qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services."; |
| 638 | 638 | #endif |
| 639 | 639 | |
| 640 | + // set the OCULUS_STORE property so the oculus plugin can know if we ran from the Oculus Store | |
| 641 | + static const QString OCULUS_STORE_ARG = "--oculus-store"; | |
| 642 | + setProperty(hifi::properties::OCULUS_STORE, arguments().indexOf(OCULUS_STORE_ARG) != -1); | |
| 640 | 643 | |
| 641 | 644 | static const QString NO_UPDATER_ARG = "--no-updater"; |
| 642 | 645 | static const bool noUpdater = arguments().indexOf(NO_UPDATER_ARG) != -1; |
| @@ -697,7 +700,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 54 unmodified lines | ||
| 697 | 700 | audioIO->setPositionGetter([]{ |
| 698 | 701 | auto avatarManager = DependencyManager::get<AvatarManager>(); |
| 699 | 702 | auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr; |
| 700 | − | |
| 703 | + | |
| 701 | 704 | return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO; |
| 702 | 705 | }); |
| 703 | 706 | audioIO->setOrientationGetter([]{ |
| @@ -880,7 +883,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 176 unmodified lines | ||
| 880 | 883 | #ifdef Q_OS_MAC |
| 881 | 884 | auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget |
| 882 | 885 | #else |
| 883 | − // On windows and linux, hiding the top level cursor also means it's invisible when hovering over the | |
| 886 | + // On windows and linux, hiding the top level cursor also means it's invisible when hovering over the | |
| 884 | 887 | // window menu, which is a pain, so only hide it for the GL surface |
| 885 | 888 | auto cursorTarget = _glWidget; |
| 886 | 889 | #endif |
| @@ -1125,7 +1128,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 238 unmodified lines | ||
| 1125 | 1128 | loadSettings(); |
| 1126 | 1129 | |
| 1127 | 1130 | // Now that we've loaded the menu and thus switched to the previous display plugin |
| 1128 | − // we can unlock the desktop repositioning code, since all the positions will be | |
| 1131 | + // we can unlock the desktop repositioning code, since all the positions will be | |
| 1129 | 1132 | // relative to the desktop size for this plugin |
| 1130 | 1133 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 1131 | 1134 | offscreenUi->getDesktop()->setProperty("repositionLocked", false); |
| @@ -1235,8 +1238,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 103 unmodified lines | ||
| 1235 | 1238 | |
| 1236 | 1239 | // Add periodic checks to send user activity data |
| 1237 | 1240 | static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000; |
| 1238 | − static int SEND_STATS_INTERVAL_MS = 10000; | |
| 1239 | 1241 | static int NEARBY_AVATAR_RADIUS_METERS = 10; |
| 1242 | + | |
| 1243 | + // setup the stats interval depending on if the 1s faster hearbeat was requested | |
| 1244 | + static const QString FAST_STATS_ARG = "--fast-heartbeat"; | |
| 1245 | + static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000; | |
| 1240 | 1246 | |
| 1241 | 1247 | static glm::vec3 lastAvatarPosition = myAvatar->getPosition(); |
| 1242 | 1248 | static glm::mat4 lastHMDHeadPose = getHMDSensorPose(); |
| @@ -1598,7 +1604,7 @@ void Application::checkChangeCursor() { · 355 unmodified lines | ||
| 1598 | 1604 | #ifdef Q_OS_MAC |
| 1599 | 1605 | auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget |
| 1600 | 1606 | #else |
| 1601 | − // On windows and linux, hiding the top level cursor also means it's invisible when hovering over the | |
| 1607 | + // On windows and linux, hiding the top level cursor also means it's invisible when hovering over the | |
| 1602 | 1608 | // window menu, which is a pain, so only hide it for the GL surface |
| 1603 | 1609 | auto cursorTarget = _glWidget; |
| 1604 | 1610 | #endif |
| @@ -1785,7 +1791,7 @@ Application::~Application() { · 180 unmodified lines | ||
| 1785 | 1791 | #endif |
| 1786 | 1792 | // The window takes ownership of the menu, so this has the side effect of destroying it. |
| 1787 | 1793 | _window->setMenuBar(nullptr); |
| 1788 | − | |
| 1794 | + | |
| 1789 | 1795 | _window->deleteLater(); |
| 1790 | 1796 | |
| 1791 | 1797 | // Can't log to file passed this point, FileLogger about to be deleted |
| @@ -1811,10 +1817,10 @@ void Application::initializeGL() { · 19 unmodified lines | ||
| 1811 | 1817 | |
| 1812 | 1818 | _glWidget->makeCurrent(); |
| 1813 | 1819 | gpu::Context::init<gpu::gl::GLBackend>(); |
| 1814 | − qApp->setProperty(hifi::properties::gl::MAKE_PROGRAM_CALLBACK, | |
| 1820 | + qApp->setProperty(hifi::properties::gl::MAKE_PROGRAM_CALLBACK, | |
| 1815 | 1821 | QVariant::fromValue((void*)(&gpu::gl::GLBackend::makeProgram))); |
| 1816 | 1822 | _gpuContext = std::make_shared<gpu::Context>(); |
| 1817 | − // The gpu context can make child contexts for transfers, so | |
| 1823 | + // The gpu context can make child contexts for transfers, so | |
| 1818 | 1824 | // we need to restore primary rendering context |
| 1819 | 1825 | _glWidget->makeCurrent(); |
| 1820 | 1826 | |
| @@ -1828,7 +1834,7 @@ void Application::initializeGL() { · 7 unmodified lines | ||
| 1828 | 1834 | assert(items.canCast<RenderFetchCullSortTask::Output>()); |
| 1829 | 1835 | static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD"; |
| 1830 | 1836 | if (QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD)) { |
| 1831 | − _renderEngine->addJob<RenderForwardTask>("RenderForwardTask", items.get<RenderFetchCullSortTask::Output>()); | |
| 1837 | + _renderEngine->addJob<RenderForwardTask>("Forward", items.get<RenderFetchCullSortTask::Output>()); | |
| 1832 | 1838 | } else { |
| 1833 | 1839 | _renderEngine->addJob<RenderDeferredTask>("RenderDeferredTask", items.get<RenderFetchCullSortTask::Output>()); |
| 1834 | 1840 | } |
| @@ -1931,6 +1937,8 @@ void Application::initializeUi() { · 96 unmodified lines | ||
| 1931 | 1937 | rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data()); |
| 1932 | 1938 | rootContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data()); |
| 1933 | 1939 | |
| 1940 | + rootContext->setContextProperty("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data()); | |
| 1941 | + | |
| 1934 | 1942 | rootContext->setContextProperty("Camera", &_myCamera); |
| 1935 | 1943 | |
| 1936 | 1944 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| @@ -2034,7 +2042,7 @@ void Application::paintGL() { · 97 unmodified lines | ||
| 2034 | 2042 | // FIXME not needed anymore? |
| 2035 | 2043 | _offscreenContext->makeCurrent(); |
| 2036 | 2044 | |
| 2037 | − // If a display plugin loses it's underlying support, it | |
| 2045 | + // If a display plugin loses it's underlying support, it | |
| 2038 | 2046 | // needs to be able to signal us to not use it |
| 2039 | 2047 | if (!displayPlugin->beginFrameRender(_frameCount)) { |
| 2040 | 2048 | _inPaint = false; |
| @@ -2846,7 +2854,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 805 unmodified lines | ||
| 2846 | 2854 | if (isMirrorChecked) { |
| 2847 | 2855 | |
| 2848 | 2856 | // if we got here without coming in from a non-Full Screen mirror case, then our |
| 2849 | − // _returnFromFullScreenMirrorTo is unknown. In that case we'll go to the old | |
| 2857 | + // _returnFromFullScreenMirrorTo is unknown. In that case we'll go to the old | |
| 2850 | 2858 | // behavior of returning to ThirdPerson |
| 2851 | 2859 | if (_returnFromFullScreenMirrorTo.isEmpty()) { |
| 2852 | 2860 | _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson; |
| @@ -3020,7 +3028,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 167 unmodified lines | ||
| 3020 | 3028 | maybeToggleMenuVisible(event); |
| 3021 | 3029 | |
| 3022 | 3030 | auto& compositor = getApplicationCompositor(); |
| 3023 | − // if this is a real mouse event, and we're in HMD mode, then we should use it to move the | |
| 3031 | + // if this is a real mouse event, and we're in HMD mode, then we should use it to move the | |
| 3024 | 3032 | // compositor reticle |
| 3025 | 3033 | // handleRealMouseMoveEvent() will return true, if we shouldn't process the event further |
| 3026 | 3034 | if (!compositor.fakeEventActive() && compositor.handleRealMouseMoveEvent()) { |
| @@ -3392,6 +3400,8 @@ void Application::idle(float nsecsElapsed) { · 365 unmodified lines | ||
| 3392 | 3400 | PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } }); |
| 3393 | 3401 | #endif |
| 3394 | 3402 | |
| 3403 | + | |
| 3404 | + | |
| 3395 | 3405 | auto displayPlugin = getActiveDisplayPlugin(); |
| 3396 | 3406 | if (displayPlugin) { |
| 3397 | 3407 | PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate()); |
| @@ -3401,9 +3411,15 @@ void Application::idle(float nsecsElapsed) { · 3 unmodified lines | ||
| 3401 | 3411 | PROFILE_COUNTER_IF_CHANGED(app, "pendingDownloads", int, ResourceCache::getPendingRequestCount()); |
| 3402 | 3412 | PROFILE_COUNTER_IF_CHANGED(app, "currentProcessing", int, DependencyManager::get<StatTracker>()->getStat("Processing").toInt()); |
| 3403 | 3413 | PROFILE_COUNTER_IF_CHANGED(app, "pendingProcessing", int, DependencyManager::get<StatTracker>()->getStat("PendingProcessing").toInt()); |
| 3404 | − | |
| 3405 | − | |
| 3406 | − | |
| 3414 | + auto renderConfig = _renderEngine->getConfiguration(); | |
| 3415 | + PROFILE_COUNTER_IF_CHANGED(render, "gpuTime", float, (float)_gpuContext->getFrameTimerGPUAverage()); | |
| 3416 | + PROFILE_COUNTER(render_detail, "gpuTimes", { | |
| 3417 | + { "OpaqueRangeTimer", renderConfig->getConfig("OpaqueRangeTimer")->property("gpuRunTime") }, | |
| 3418 | + { "LinearDepth", renderConfig->getConfig("LinearDepth")->property("gpuRunTime") }, | |
| 3419 | + { "SurfaceGeometry", renderConfig->getConfig("SurfaceGeometry")->property("gpuRunTime") }, | |
| 3420 | + { "RenderDeferred", renderConfig->getConfig("RenderDeferred")->property("gpuRunTime") }, | |
| 3421 | + { "ToneAndPostRangeTimer", renderConfig->getConfig("ToneAndPostRangeTimer")->property("gpuRunTime") } | |
| 3422 | + }); | |
| 3407 | 3423 | |
| 3408 | 3424 | PROFILE_RANGE(app, __FUNCTION__); |
| 3409 | 3425 | |
| @@ -4109,7 +4125,7 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 699 unmodified lines | ||
| 4109 | 4125 | } |
| 4110 | 4126 | _lastAcceptedKeyPress = usecTimestampNow(); |
| 4111 | 4127 | |
| 4112 | − setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(), | |
| 4128 | + setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(), | |
| 4113 | 4129 | entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR); |
| 4114 | 4130 | } |
| 4115 | 4131 | } |
| @@ -4700,7 +4716,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 584 unmodified lines | ||
| 4700 | 4716 | _octreeQuery.setMaxQueryPacketsPerSecond(0); |
| 4701 | 4717 | } |
| 4702 | 4718 | |
| 4703 | − // if asked to forceResend, then set the query's position/orientation to be degenerate in a manner | |
| 4719 | + // if asked to forceResend, then set the query's position/orientation to be degenerate in a manner | |
| 4704 | 4720 | // that will cause our next query to be guarenteed to be different and the server will resend to us |
| 4705 | 4721 | if (forceResend) { |
| 4706 | 4722 | _octreeQuery.setCameraPosition(glm::vec3(-0.1, -0.1, -0.1)); |
| @@ -5295,15 +5311,17 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 588 unmodified lines | ||
| 5295 | 5311 | if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) { |
| 5296 | 5312 | // We've seen the same number of nearby entities for several stats packets in a row. assume we've got all |
| 5297 | 5313 | // the local entities. |
| 5314 | + bool result = true; | |
| 5298 | 5315 | foreach (EntityItemPointer entity, entities) { |
| 5299 | 5316 | if (entity->shouldBePhysical() && !entity->isReadyToComputeShape()) { |
| 5300 | 5317 | static QString repeatedMessage = |
| 5301 | 5318 | LogHandler::getInstance().addRepeatedMessageRegex("Physics disabled until entity loads: .*"); |
| 5302 | 5319 | qCDebug(interfaceapp) << "Physics disabled until entity loads: " << entity->getID() << entity->getName(); |
| 5303 | − return false; | |
| 5320 | + // don't break here because we want all the relevant entities to start their downloads | |
| 5321 | + result = false; | |
| 5304 | 5322 | } |
| 5305 | 5323 | } |
| 5306 | − return true; | |
| 5324 | + return result; | |
| 5307 | 5325 | } |
| 5308 | 5326 | return false; |
| 5309 | 5327 | } |
| @@ -5834,7 +5852,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin · 524 unmodified lines | ||
| 5834 | 5852 | mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy)); |
| 5835 | 5853 | addAssetToWorldWithNewMapping(filePath, mapping, copy); |
| 5836 | 5854 | } else { |
| 5837 | − QString errorInfo = "Too many copies of asset name: " | |
| 5855 | + QString errorInfo = "Too many copies of asset name: " | |
| 5838 | 5856 | + mapping.left(mapping.length() - QString::number(copy).length() - 1); |
| 5839 | 5857 | qWarning(interfaceapp) << "Error downloading model: " + errorInfo; |
| 5840 | 5858 | addAssetToWorldError(filenameFromPath(filePath), errorInfo); |
| @@ -5901,7 +5919,7 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) { · 60 unmodified lines | ||
| 5901 | 5919 | |
| 5902 | 5920 | // Note: Model dimensions are not available here; model is scaled per FBX mesh in RenderableModelEntityItem::update() later |
| 5903 | 5921 | // on. But FBX dimensions may be in cm, so we monitor for the dimension change and rescale again if warranted. |
| 5904 | − | |
| 5922 | + | |
| 5905 | 5923 | if (entityID == QUuid()) { |
| 5906 | 5924 | QString errorInfo = "Could not add model " + mapping + " to world."; |
| 5907 | 5925 | qWarning(interfaceapp) << "Could not add model to world: " + errorInfo; |
| @@ -6365,7 +6383,7 @@ glm::uvec2 Application::getCanvasSize() const { · 457 unmodified lines | ||
| 6365 | 6383 | } |
| 6366 | 6384 | |
| 6367 | 6385 | QRect Application::getRenderingGeometry() const { |
| 6368 | − auto geometry = _glWidget->geometry(); | |
| 6386 | + auto geometry = _glWidget->geometry(); | |
| 6369 | 6387 | auto topLeft = geometry.topLeft(); |
| 6370 | 6388 | auto topLeftScreen = _glWidget->mapToGlobal(topLeft); |
| 6371 | 6389 | geometry.moveTopLeft(topLeftScreen); |
| @@ -6728,8 +6746,8 @@ bool Application::makeRenderingContextCurrent() { · 356 unmodified lines | ||
| 6728 | 6746 | return _offscreenContext->makeCurrent(); |
| 6729 | 6747 | } |
| 6730 | 6748 | |
| 6731 | −bool Application::isForeground() const { | |
| 6732 | − return _isForeground && !_window->isMinimized(); | |
| 6749 | +bool Application::isForeground() const { | |
| 6750 | + return _isForeground && !_window->isMinimized(); | |
| 6733 | 6751 | } |
| 6734 | 6752 | |
| 6735 | 6753 | void Application::sendMousePressOnEntity(QUuid id, PointerEvent event) { |