History

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

ZappoMan committed 9 years ago

Commit 29fff2e2 parents 292d472 c8d505c87 files · +2615 −682Browse files

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

Unified · Split

interface/src/Application.cpp+44−26
@@ -252,7 +252,7 @@ public: · 251 unmodified lines
252252 static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND;
253253 static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large
254254 static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples
255−
255+
256256 // Set the heartbeat on launch
257257 DeadlockWatchdogThread() {
258258 setObjectName("Deadlock Watchdog");
@@ -616,7 +616,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 357 unmodified lines
616616 _window->setWindowTitle("Interface");
617617
618618 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
619−
619+
620620 auto nodeList = DependencyManager::get<NodeList>();
621621
622622 // 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
637637 qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services.";
638638 #endif
639639
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);
640643
641644 static const QString NO_UPDATER_ARG = "--no-updater";
642645 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
697700 audioIO->setPositionGetter([]{
698701 auto avatarManager = DependencyManager::get<AvatarManager>();
699702 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
700−
703+
701704 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;
702705 });
703706 audioIO->setOrientationGetter([]{
@@ -880,7 +883,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 176 unmodified lines
880883 #ifdef Q_OS_MAC
881884 auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget
882885 #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
884887 // window menu, which is a pain, so only hide it for the GL surface
885888 auto cursorTarget = _glWidget;
886889 #endif
@@ -1125,7 +1128,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 238 unmodified lines
11251128 loadSettings();
11261129
11271130 // 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
11291132 // relative to the desktop size for this plugin
11301133 auto offscreenUi = DependencyManager::get<OffscreenUi>();
11311134 offscreenUi->getDesktop()->setProperty("repositionLocked", false);
@@ -1235,8 +1238,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 103 unmodified lines
12351238
12361239 // Add periodic checks to send user activity data
12371240 static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000;
1238− static int SEND_STATS_INTERVAL_MS = 10000;
12391241 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;
12401246
12411247 static glm::vec3 lastAvatarPosition = myAvatar->getPosition();
12421248 static glm::mat4 lastHMDHeadPose = getHMDSensorPose();
@@ -1598,7 +1604,7 @@ void Application::checkChangeCursor() { · 355 unmodified lines
15981604 #ifdef Q_OS_MAC
15991605 auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget
16001606 #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
16021608 // window menu, which is a pain, so only hide it for the GL surface
16031609 auto cursorTarget = _glWidget;
16041610 #endif
@@ -1785,7 +1791,7 @@ Application::~Application() { · 180 unmodified lines
17851791 #endif
17861792 // The window takes ownership of the menu, so this has the side effect of destroying it.
17871793 _window->setMenuBar(nullptr);
1788−
1794+
17891795 _window->deleteLater();
17901796
17911797 // Can't log to file passed this point, FileLogger about to be deleted
@@ -1811,10 +1817,10 @@ void Application::initializeGL() { · 19 unmodified lines
18111817
18121818 _glWidget->makeCurrent();
18131819 gpu::Context::init<gpu::gl::GLBackend>();
1814− qApp->setProperty(hifi::properties::gl::MAKE_PROGRAM_CALLBACK,
1820+ qApp->setProperty(hifi::properties::gl::MAKE_PROGRAM_CALLBACK,
18151821 QVariant::fromValue((void*)(&gpu::gl::GLBackend::makeProgram)));
18161822 _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
18181824 // we need to restore primary rendering context
18191825 _glWidget->makeCurrent();
18201826
@@ -1828,7 +1834,7 @@ void Application::initializeGL() { · 7 unmodified lines
18281834 assert(items.canCast<RenderFetchCullSortTask::Output>());
18291835 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
18301836 if (QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD)) {
1831− _renderEngine->addJob<RenderForwardTask>("RenderForwardTask", items.get<RenderFetchCullSortTask::Output>());
1837+ _renderEngine->addJob<RenderForwardTask>("Forward", items.get<RenderFetchCullSortTask::Output>());
18321838 } else {
18331839 _renderEngine->addJob<RenderDeferredTask>("RenderDeferredTask", items.get<RenderFetchCullSortTask::Output>());
18341840 }
@@ -1931,6 +1937,8 @@ void Application::initializeUi() { · 96 unmodified lines
19311937 rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
19321938 rootContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
19331939
1940+ rootContext->setContextProperty("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
1941+
19341942 rootContext->setContextProperty("Camera", &_myCamera);
19351943
19361944 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
@@ -2034,7 +2042,7 @@ void Application::paintGL() { · 97 unmodified lines
20342042 // FIXME not needed anymore?
20352043 _offscreenContext->makeCurrent();
20362044
2037− // If a display plugin loses it's underlying support, it
2045+ // If a display plugin loses it's underlying support, it
20382046 // needs to be able to signal us to not use it
20392047 if (!displayPlugin->beginFrameRender(_frameCount)) {
20402048 _inPaint = false;
@@ -2846,7 +2854,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 805 unmodified lines
28462854 if (isMirrorChecked) {
28472855
28482856 // 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
28502858 // behavior of returning to ThirdPerson
28512859 if (_returnFromFullScreenMirrorTo.isEmpty()) {
28522860 _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
@@ -3020,7 +3028,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 167 unmodified lines
30203028 maybeToggleMenuVisible(event);
30213029
30223030 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
30243032 // compositor reticle
30253033 // handleRealMouseMoveEvent() will return true, if we shouldn't process the event further
30263034 if (!compositor.fakeEventActive() && compositor.handleRealMouseMoveEvent()) {
@@ -3392,6 +3400,8 @@ void Application::idle(float nsecsElapsed) { · 365 unmodified lines
33923400 PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } });
33933401 #endif
33943402
3403+
3404+
33953405 auto displayPlugin = getActiveDisplayPlugin();
33963406 if (displayPlugin) {
33973407 PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate());
@@ -3401,9 +3411,15 @@ void Application::idle(float nsecsElapsed) { · 3 unmodified lines
34013411 PROFILE_COUNTER_IF_CHANGED(app, "pendingDownloads", int, ResourceCache::getPendingRequestCount());
34023412 PROFILE_COUNTER_IF_CHANGED(app, "currentProcessing", int, DependencyManager::get<StatTracker>()->getStat("Processing").toInt());
34033413 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+ });
34073423
34083424 PROFILE_RANGE(app, __FUNCTION__);
34093425
@@ -4109,7 +4125,7 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 699 unmodified lines
41094125 }
41104126 _lastAcceptedKeyPress = usecTimestampNow();
41114127
4112− setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(),
4128+ setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(),
41134129 entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);
41144130 }
41154131 }
@@ -4700,7 +4716,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 584 unmodified lines
47004716 _octreeQuery.setMaxQueryPacketsPerSecond(0);
47014717 }
47024718
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
47044720 // that will cause our next query to be guarenteed to be different and the server will resend to us
47054721 if (forceResend) {
47064722 _octreeQuery.setCameraPosition(glm::vec3(-0.1, -0.1, -0.1));
@@ -5295,15 +5311,17 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 588 unmodified lines
52955311 if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) {
52965312 // We've seen the same number of nearby entities for several stats packets in a row. assume we've got all
52975313 // the local entities.
5314+ bool result = true;
52985315 foreach (EntityItemPointer entity, entities) {
52995316 if (entity->shouldBePhysical() && !entity->isReadyToComputeShape()) {
53005317 static QString repeatedMessage =
53015318 LogHandler::getInstance().addRepeatedMessageRegex("Physics disabled until entity loads: .*");
53025319 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;
53045322 }
53055323 }
5306− return true;
5324+ return result;
53075325 }
53085326 return false;
53095327 }
@@ -5834,7 +5852,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin · 524 unmodified lines
58345852 mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));
58355853 addAssetToWorldWithNewMapping(filePath, mapping, copy);
58365854 } else {
5837− QString errorInfo = "Too many copies of asset name: "
5855+ QString errorInfo = "Too many copies of asset name: "
58385856 + mapping.left(mapping.length() - QString::number(copy).length() - 1);
58395857 qWarning(interfaceapp) << "Error downloading model: " + errorInfo;
58405858 addAssetToWorldError(filenameFromPath(filePath), errorInfo);
@@ -5901,7 +5919,7 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) { · 60 unmodified lines
59015919
59025920 // Note: Model dimensions are not available here; model is scaled per FBX mesh in RenderableModelEntityItem::update() later
59035921 // on. But FBX dimensions may be in cm, so we monitor for the dimension change and rescale again if warranted.
5904−
5922+
59055923 if (entityID == QUuid()) {
59065924 QString errorInfo = "Could not add model " + mapping + " to world.";
59075925 qWarning(interfaceapp) << "Could not add model to world: " + errorInfo;
@@ -6365,7 +6383,7 @@ glm::uvec2 Application::getCanvasSize() const { · 457 unmodified lines
63656383 }
63666384
63676385 QRect Application::getRenderingGeometry() const {
6368− auto geometry = _glWidget->geometry();
6386+ auto geometry = _glWidget->geometry();
63696387 auto topLeft = geometry.topLeft();
63706388 auto topLeftScreen = _glWidget->mapToGlobal(topLeft);
63716389 geometry.moveTopLeft(topLeftScreen);
@@ -6728,8 +6746,8 @@ bool Application::makeRenderingContextCurrent() { · 356 unmodified lines
67286746 return _offscreenContext->makeCurrent();
67296747 }
67306748
6731−bool Application::isForeground() const {
6732− return _isForeground && !_window->isMinimized();
6749+bool Application::isForeground() const {
6750+ return _isForeground && !_window->isMinimized();
67336751 }
67346752
67356753 void Application::sendMousePressOnEntity(QUuid id, PointerEvent event) {