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
252 static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND;252 static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND;
253 static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large253 static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large
254 static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples254 static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples
255 255
256 // Set the heartbeat on launch256 // Set the heartbeat on launch
257 DeadlockWatchdogThread() {257 DeadlockWatchdogThread() {
258 setObjectName("Deadlock Watchdog");258 setObjectName("Deadlock Watchdog");
@@ -616,7 +616,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 357 unmodified lines
616 _window->setWindowTitle("Interface");616 _window->setWindowTitle("Interface");
617 617
618 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us618 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
619 619
620 auto nodeList = DependencyManager::get<NodeList>();620 auto nodeList = DependencyManager::get<NodeList>();
621 621
622 // Set up a watchdog thread to intentionally crash the application on deadlocks622 // 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 qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services.";637 qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services.";
638#endif638#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 static const QString NO_UPDATER_ARG = "--no-updater";644 static const QString NO_UPDATER_ARG = "--no-updater";
642 static const bool noUpdater = arguments().indexOf(NO_UPDATER_ARG) != -1;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 audioIO->setPositionGetter([]{700 audioIO->setPositionGetter([]{
698 auto avatarManager = DependencyManager::get<AvatarManager>();701 auto avatarManager = DependencyManager::get<AvatarManager>();
699 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;702 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
700 703
701 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;704 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;
702 });705 });
703 audioIO->setOrientationGetter([]{706 audioIO->setOrientationGetter([]{
@@ -880,7 +883,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 176 unmodified lines
880#ifdef Q_OS_MAC883#ifdef Q_OS_MAC
881 auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget884 auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget
882#else885#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 // window menu, which is a pain, so only hide it for the GL surface887 // window menu, which is a pain, so only hide it for the GL surface
885 auto cursorTarget = _glWidget;888 auto cursorTarget = _glWidget;
886#endif889#endif
@@ -1125,7 +1128,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 238 unmodified lines
1125 loadSettings();1128 loadSettings();
1126 1129
1127 // Now that we've loaded the menu and thus switched to the previous display plugin1130 // 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 // relative to the desktop size for this plugin1132 // relative to the desktop size for this plugin
1130 auto offscreenUi = DependencyManager::get<OffscreenUi>();1133 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1131 offscreenUi->getDesktop()->setProperty("repositionLocked", false);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 // Add periodic checks to send user activity data1239 // Add periodic checks to send user activity data
1237 static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000;1240 static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000;
1238 static int SEND_STATS_INTERVAL_MS = 10000;
1239 static int NEARBY_AVATAR_RADIUS_METERS = 10;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 static glm::vec3 lastAvatarPosition = myAvatar->getPosition();1247 static glm::vec3 lastAvatarPosition = myAvatar->getPosition();
1242 static glm::mat4 lastHMDHeadPose = getHMDSensorPose();1248 static glm::mat4 lastHMDHeadPose = getHMDSensorPose();
@@ -1598,7 +1604,7 @@ void Application::checkChangeCursor() { · 355 unmodified lines
1598#ifdef Q_OS_MAC1604#ifdef Q_OS_MAC
1599 auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget1605 auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget
1600#else1606#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 // window menu, which is a pain, so only hide it for the GL surface1608 // window menu, which is a pain, so only hide it for the GL surface
1603 auto cursorTarget = _glWidget;1609 auto cursorTarget = _glWidget;
1604#endif1610#endif
@@ -1785,7 +1791,7 @@ Application::~Application() { · 180 unmodified lines
1785#endif1791#endif
1786 // The window takes ownership of the menu, so this has the side effect of destroying it.1792 // The window takes ownership of the menu, so this has the side effect of destroying it.
1787 _window->setMenuBar(nullptr);1793 _window->setMenuBar(nullptr);
1788 1794
1789 _window->deleteLater();1795 _window->deleteLater();
1790 1796
1791 // Can't log to file passed this point, FileLogger about to be deleted1797 // 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 _glWidget->makeCurrent();1818 _glWidget->makeCurrent();
1813 gpu::Context::init<gpu::gl::GLBackend>();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 QVariant::fromValue((void*)(&gpu::gl::GLBackend::makeProgram)));1821 QVariant::fromValue((void*)(&gpu::gl::GLBackend::makeProgram)));
1816 _gpuContext = std::make_shared<gpu::Context>();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 // we need to restore primary rendering context1824 // we need to restore primary rendering context
1819 _glWidget->makeCurrent();1825 _glWidget->makeCurrent();
1820 1826
@@ -1828,7 +1834,7 @@ void Application::initializeGL() { · 7 unmodified lines
1828 assert(items.canCast<RenderFetchCullSortTask::Output>());1834 assert(items.canCast<RenderFetchCullSortTask::Output>());
1829 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";1835 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
1830 if (QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD)) {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 } else {1838 } else {
1833 _renderEngine->addJob<RenderDeferredTask>("RenderDeferredTask", items.get<RenderFetchCullSortTask::Output>());1839 _renderEngine->addJob<RenderDeferredTask>("RenderDeferredTask", items.get<RenderFetchCullSortTask::Output>());
1834 }1840 }
@@ -1931,6 +1937,8 @@ void Application::initializeUi() { · 96 unmodified lines
1931 rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());1937 rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
1932 rootContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());1938 rootContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
1933 1939
1940 rootContext->setContextProperty("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
1941
1934 rootContext->setContextProperty("Camera", &_myCamera);1942 rootContext->setContextProperty("Camera", &_myCamera);
1935 1943
1936#if defined(Q_OS_MAC) || defined(Q_OS_WIN)1944#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
@@ -2034,7 +2042,7 @@ void Application::paintGL() { · 97 unmodified lines
2034 // FIXME not needed anymore?2042 // FIXME not needed anymore?
2035 _offscreenContext->makeCurrent();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 // needs to be able to signal us to not use it2046 // needs to be able to signal us to not use it
2039 if (!displayPlugin->beginFrameRender(_frameCount)) {2047 if (!displayPlugin->beginFrameRender(_frameCount)) {
2040 _inPaint = false;2048 _inPaint = false;
@@ -2846,7 +2854,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 805 unmodified lines
2846 if (isMirrorChecked) {2854 if (isMirrorChecked) {
2847 2855
2848 // if we got here without coming in from a non-Full Screen mirror case, then our2856 // 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 // behavior of returning to ThirdPerson2858 // behavior of returning to ThirdPerson
2851 if (_returnFromFullScreenMirrorTo.isEmpty()) {2859 if (_returnFromFullScreenMirrorTo.isEmpty()) {
2852 _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;2860 _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
@@ -3020,7 +3028,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 167 unmodified lines
3020 maybeToggleMenuVisible(event);3028 maybeToggleMenuVisible(event);
3021 3029
3022 auto& compositor = getApplicationCompositor();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 // compositor reticle3032 // compositor reticle
3025 // handleRealMouseMoveEvent() will return true, if we shouldn't process the event further3033 // handleRealMouseMoveEvent() will return true, if we shouldn't process the event further
3026 if (!compositor.fakeEventActive() && compositor.handleRealMouseMoveEvent()) {3034 if (!compositor.fakeEventActive() && compositor.handleRealMouseMoveEvent()) {
@@ -3392,6 +3400,8 @@ void Application::idle(float nsecsElapsed) { · 365 unmodified lines
3392 PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } });3400 PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } });
3393#endif3401#endif
3394 3402
3403
3404
3395 auto displayPlugin = getActiveDisplayPlugin();3405 auto displayPlugin = getActiveDisplayPlugin();
3396 if (displayPlugin) {3406 if (displayPlugin) {
3397 PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate());3407 PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate());
@@ -3401,9 +3411,15 @@ void Application::idle(float nsecsElapsed) { · 3 unmodified lines
3401 PROFILE_COUNTER_IF_CHANGED(app, "pendingDownloads", int, ResourceCache::getPendingRequestCount());3411 PROFILE_COUNTER_IF_CHANGED(app, "pendingDownloads", int, ResourceCache::getPendingRequestCount());
3402 PROFILE_COUNTER_IF_CHANGED(app, "currentProcessing", int, DependencyManager::get<StatTracker>()->getStat("Processing").toInt());3412 PROFILE_COUNTER_IF_CHANGED(app, "currentProcessing", int, DependencyManager::get<StatTracker>()->getStat("Processing").toInt());
3403 PROFILE_COUNTER_IF_CHANGED(app, "pendingProcessing", int, DependencyManager::get<StatTracker>()->getStat("PendingProcessing").toInt());3413 PROFILE_COUNTER_IF_CHANGED(app, "pendingProcessing", int, DependencyManager::get<StatTracker>()->getStat("PendingProcessing").toInt());
3404 3414 auto renderConfig = _renderEngine->getConfiguration();
3405 3415 PROFILE_COUNTER_IF_CHANGED(render, "gpuTime", float, (float)_gpuContext->getFrameTimerGPUAverage());
3406 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 PROFILE_RANGE(app, __FUNCTION__);3424 PROFILE_RANGE(app, __FUNCTION__);
3409 3425
@@ -4109,7 +4125,7 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 699 unmodified lines
4109 }4125 }
4110 _lastAcceptedKeyPress = usecTimestampNow();4126 _lastAcceptedKeyPress = usecTimestampNow();
4111 4127
4112 setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(), 4128 setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(),
4113 entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);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 _octreeQuery.setMaxQueryPacketsPerSecond(0);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 // that will cause our next query to be guarenteed to be different and the server will resend to us4720 // that will cause our next query to be guarenteed to be different and the server will resend to us
4705 if (forceResend) {4721 if (forceResend) {
4706 _octreeQuery.setCameraPosition(glm::vec3(-0.1, -0.1, -0.1));4722 _octreeQuery.setCameraPosition(glm::vec3(-0.1, -0.1, -0.1));
@@ -5295,15 +5311,17 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 588 unmodified lines
5295 if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) {5311 if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) {
5296 // We've seen the same number of nearby entities for several stats packets in a row. assume we've got all5312 // We've seen the same number of nearby entities for several stats packets in a row. assume we've got all
5297 // the local entities.5313 // the local entities.
5314 bool result = true;
5298 foreach (EntityItemPointer entity, entities) {5315 foreach (EntityItemPointer entity, entities) {
5299 if (entity->shouldBePhysical() && !entity->isReadyToComputeShape()) {5316 if (entity->shouldBePhysical() && !entity->isReadyToComputeShape()) {
5300 static QString repeatedMessage =5317 static QString repeatedMessage =
5301 LogHandler::getInstance().addRepeatedMessageRegex("Physics disabled until entity loads: .*");5318 LogHandler::getInstance().addRepeatedMessageRegex("Physics disabled until entity loads: .*");
5302 qCDebug(interfaceapp) << "Physics disabled until entity loads: " << entity->getID() << entity->getName();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 return false;5326 return false;
5309}5327}
@@ -5834,7 +5852,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin · 524 unmodified lines
5834 mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));5852 mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));
5835 addAssetToWorldWithNewMapping(filePath, mapping, copy);5853 addAssetToWorldWithNewMapping(filePath, mapping, copy);
5836 } else {5854 } else {
5837 QString errorInfo = "Too many copies of asset name: " 5855 QString errorInfo = "Too many copies of asset name: "
5838 + mapping.left(mapping.length() - QString::number(copy).length() - 1);5856 + mapping.left(mapping.length() - QString::number(copy).length() - 1);
5839 qWarning(interfaceapp) << "Error downloading model: " + errorInfo;5857 qWarning(interfaceapp) << "Error downloading model: " + errorInfo;
5840 addAssetToWorldError(filenameFromPath(filePath), errorInfo);5858 addAssetToWorldError(filenameFromPath(filePath), errorInfo);
@@ -5901,7 +5919,7 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) { · 60 unmodified lines
5901 5919
5902 // Note: Model dimensions are not available here; model is scaled per FBX mesh in RenderableModelEntityItem::update() later5920 // Note: Model dimensions are not available here; model is scaled per FBX mesh in RenderableModelEntityItem::update() later
5903 // on. But FBX dimensions may be in cm, so we monitor for the dimension change and rescale again if warranted.5921 // on. But FBX dimensions may be in cm, so we monitor for the dimension change and rescale again if warranted.
5904 5922
5905 if (entityID == QUuid()) {5923 if (entityID == QUuid()) {
5906 QString errorInfo = "Could not add model " + mapping + " to world.";5924 QString errorInfo = "Could not add model " + mapping + " to world.";
5907 qWarning(interfaceapp) << "Could not add model to world: " + errorInfo;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
6367QRect Application::getRenderingGeometry() const {6385QRect Application::getRenderingGeometry() const {
6368 auto geometry = _glWidget->geometry(); 6386 auto geometry = _glWidget->geometry();
6369 auto topLeft = geometry.topLeft();6387 auto topLeft = geometry.topLeft();
6370 auto topLeftScreen = _glWidget->mapToGlobal(topLeft);6388 auto topLeftScreen = _glWidget->mapToGlobal(topLeft);
6371 geometry.moveTopLeft(topLeftScreen);6389 geometry.moveTopLeft(topLeftScreen);
@@ -6728,8 +6746,8 @@ bool Application::makeRenderingContextCurrent() { · 356 unmodified lines
6728 return _offscreenContext->makeCurrent();6746 return _offscreenContext->makeCurrent();
6729}6747}
6730 6748
6731bool Application::isForeground() const { 6749bool Application::isForeground() const {
6732 return _isForeground && !_window->isMinimized(); 6750 return _isForeground && !_window->isMinimized();
6733}6751}
6734 6752
6735void Application::sendMousePressOnEntity(QUuid id, PointerEvent event) {6753void Application::sendMousePressOnEntity(QUuid id, PointerEvent event) {