History

one global pickmanager

SamGondelman committed 9 years ago

Commit d7745ef1 parent 3572f7f14 files · +417 −416Browse files

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

Unified · Split

interface/src/Application.cpp+60−59
@@ -195,6 +195,7 @@ · 194 unmodified lines
195 195
196#include <raypick/RayPickScriptingInterface.h>196#include <raypick/RayPickScriptingInterface.h>
197#include <raypick/LaserPointerScriptingInterface.h>197#include <raypick/LaserPointerScriptingInterface.h>
198#include <raypick/MouseRayPick.h>
198 199
199#include <FadeEffect.h>200#include <FadeEffect.h>
200 201
@@ -750,8 +751,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 549 unmodified lines
750 _notifiedPacketVersionMismatchThisDomain(false),751 _notifiedPacketVersionMismatchThisDomain(false),
751 _maxOctreePPS(maxOctreePacketsPerSecond.get()),752 _maxOctreePPS(maxOctreePacketsPerSecond.get()),
752 _lastFaceTrackerUpdate(0),753 _lastFaceTrackerUpdate(0),
753 _snapshotSound(nullptr)754 _snapshotSound(nullptr) {
754{
755 auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();755 auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
756 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));756 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
757 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);757 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
@@ -795,7 +795,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 37 unmodified lines
795 installNativeEventFilter(&MyNativeEventFilter::getInstance());795 installNativeEventFilter(&MyNativeEventFilter::getInstance());
796#endif796#endif
797 797
798 798
799 _logger = new FileLogger(this);799 _logger = new FileLogger(this);
800 qInstallMessageHandler(messageHandler);800 qInstallMessageHandler(messageHandler);
801 801
@@ -850,13 +850,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 48 unmodified lines
850 850
851 851
852 auto audioIO = DependencyManager::get<AudioClient>();852 auto audioIO = DependencyManager::get<AudioClient>();
853 audioIO->setPositionGetter([]{853 audioIO->setPositionGetter([] {
854 auto avatarManager = DependencyManager::get<AvatarManager>();854 auto avatarManager = DependencyManager::get<AvatarManager>();
855 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;855 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
856 856
857 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;857 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;
858 });858 });
859 audioIO->setOrientationGetter([]{859 audioIO->setOrientationGetter([] {
860 auto avatarManager = DependencyManager::get<AvatarManager>();860 auto avatarManager = DependencyManager::get<AvatarManager>();
861 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;861 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
862 862
@@ -867,7 +867,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 4 unmodified lines
867 audioIO->handleRecordedAudioInput(frame->data);867 audioIO->handleRecordedAudioInput(frame->data);
868 });868 });
869 869
870 connect(audioIO.data(), &AudioClient::inputReceived, [](const QByteArray& audio){870 connect(audioIO.data(), &AudioClient::inputReceived, [](const QByteArray& audio) {
871 static auto recorder = DependencyManager::get<recording::Recorder>();871 static auto recorder = DependencyManager::get<recording::Recorder>();
872 if (recorder->isRecording()) {872 if (recorder->isRecording()) {
873 static const recording::FrameType AUDIO_FRAME_TYPE = recording::Frame::registerFrameType(AudioConstants::getAudioFrameName());873 static const recording::FrameType AUDIO_FRAME_TYPE = recording::Frame::registerFrameType(AudioConstants::getAudioFrameName());
@@ -956,14 +956,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 82 unmodified lines
956 auto addressManager = DependencyManager::get<AddressManager>();956 auto addressManager = DependencyManager::get<AddressManager>();
957 957
958 // use our MyAvatar position and quat for address manager path958 // use our MyAvatar position and quat for address manager path
959 addressManager->setPositionGetter([this]{ return getMyAvatar()->getPosition(); });959 addressManager->setPositionGetter([this] { return getMyAvatar()->getPosition(); });
960 addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });960 addressManager->setOrientationGetter([this] { return getMyAvatar()->getOrientation(); });
961 961
962 connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);962 connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
963 connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);963 connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
964 964
965 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);965 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
966 connect(this, &Application::activeDisplayPluginChanged, this, [](){966 connect(this, &Application::activeDisplayPluginChanged, this, []() {
967 qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());967 qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());
968 });968 });
969 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);969 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);
@@ -973,7 +973,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 3 unmodified lines
973 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);973 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
974 974
975 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();975 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
976 scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){976 scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine) {
977 registerScriptEngineWithApplicationServices(engine);977 registerScriptEngineWithApplicationServices(engine);
978 });978 });
979 979
@@ -989,7 +989,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
989 }, Qt::QueuedConnection);989 }, Qt::QueuedConnection);
990 990
991 connect(scriptEngines, &ScriptEngines::scriptLoadError,991 connect(scriptEngines, &ScriptEngines::scriptLoadError,
992 scriptEngines, [](const QString& filename, const QString& error){992 scriptEngines, [](const QString& filename, const QString& error) {
993 OffscreenUi::asyncWarning(nullptr, "Error Loading Script", filename + " failed to load.");993 OffscreenUi::asyncWarning(nullptr, "Error Loading Script", filename + " failed to load.");
994 }, Qt::QueuedConnection);994 }, Qt::QueuedConnection);
995 995
@@ -1101,7 +1101,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 105 unmodified lines
1101 }1101 }
1102 1102
1103 // add firstRun flag from settings to launch event1103 // add firstRun flag from settings to launch event
1104 Setting::Handle<bool> firstRun { Settings::firstRun, true };1104 Setting::Handle<bool> firstRun{ Settings::firstRun, true };
1105 1105
1106 // once the settings have been loaded, check if we need to flip the default for UserActivityLogger1106 // once the settings have been loaded, check if we need to flip the default for UserActivityLogger
1107 auto& userActivityLogger = UserActivityLogger::getInstance();1107 auto& userActivityLogger = UserActivityLogger::getInstance();
@@ -1202,42 +1202,42 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 94 unmodified lines
1202 static int lastKey = Qt::Key_unknown;1202 static int lastKey = Qt::Key_unknown;
1203 bool navAxis = false;1203 bool navAxis = false;
1204 switch (actionEnum) {1204 switch (actionEnum) {
1205 case Action::UI_NAV_VERTICAL:1205 case Action::UI_NAV_VERTICAL:
1206 navAxis = true;1206 navAxis = true;
1207 if (state > 0.0f) {1207 if (state > 0.0f) {
1208 key = Qt::Key_Up;1208 key = Qt::Key_Up;
1209 } else if (state < 0.0f) {1209 } else if (state < 0.0f) {
1210 key = Qt::Key_Down;1210 key = Qt::Key_Down;
1211 }1211 }
1212 break;1212 break;
1213 1213
1214 case Action::UI_NAV_LATERAL:1214 case Action::UI_NAV_LATERAL:
1215 navAxis = true;1215 navAxis = true;
1216 if (state > 0.0f) {1216 if (state > 0.0f) {
1217 key = Qt::Key_Right;1217 key = Qt::Key_Right;
1218 } else if (state < 0.0f) {1218 } else if (state < 0.0f) {
1219 key = Qt::Key_Left;1219 key = Qt::Key_Left;
1220 }1220 }
1221 break;1221 break;
1222 1222
1223 case Action::UI_NAV_GROUP:1223 case Action::UI_NAV_GROUP:
1224 navAxis = true;1224 navAxis = true;
1225 if (state > 0.0f) {1225 if (state > 0.0f) {
1226 key = Qt::Key_Tab;1226 key = Qt::Key_Tab;
1227 } else if (state < 0.0f) {1227 } else if (state < 0.0f) {
1228 key = Qt::Key_Backtab;1228 key = Qt::Key_Backtab;
1229 }1229 }
1230 break;1230 break;
1231 1231
1232 case Action::UI_NAV_BACK:1232 case Action::UI_NAV_BACK:
1233 key = Qt::Key_Escape;1233 key = Qt::Key_Escape;
1234 break;1234 break;
1235 1235
1236 case Action::UI_NAV_SELECT:1236 case Action::UI_NAV_SELECT:
1237 key = Qt::Key_Return;1237 key = Qt::Key_Return;
1238 break;1238 break;
1239 default:1239 default:
1240 break;1240 break;
1241 }1241 }
1242 1242
1243 auto window = tabletScriptingInterface->getTabletWindow();1243 auto window = tabletScriptingInterface->getTabletWindow();
@@ -1376,8 +1376,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 132 unmodified lines
1376 1376
1377 1377
1378 QTimer* settingsTimer = new QTimer();1378 QTimer* settingsTimer = new QTimer();
1379 moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{1379 moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer] {
1380 connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer]{1380 connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer] {
1381 // Disconnect the signal from the save settings1381 // Disconnect the signal from the save settings
1382 QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);1382 QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
1383 // Stop the settings timer1383 // Stop the settings timer
@@ -1439,7 +1439,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 55 unmodified lines
1439 // Now that menu is initialized we can sync myAvatar with it's state.1439 // Now that menu is initialized we can sync myAvatar with it's state.
1440 myAvatar->updateMotionBehaviorFromMenu();1440 myAvatar->updateMotionBehaviorFromMenu();
1441 1441
1442// FIXME spacemouse code still needs cleanup1442 // FIXME spacemouse code still needs cleanup
1443#if 01443#if 0
1444 // the 3Dconnexion device wants to be initialized after a window is displayed.1444 // the 3Dconnexion device wants to be initialized after a window is displayed.
1445 SpacemouseManager::getInstance().init();1445 SpacemouseManager::getInstance().init();
@@ -1448,7 +1448,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 2 unmodified lines
1448 // If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it1448 // If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it
1449 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();1449 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
1450 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,1450 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
1451 [this](const EntityItemID& entityItemID, const PointerEvent& event) {1451 [this](const EntityItemID& entityItemID, const PointerEvent& event) {
1452 if (getEntities()->wantsKeyboardFocus(entityItemID)) {1452 if (getEntities()->wantsKeyboardFocus(entityItemID)) {
1453 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);1453 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
1454 setKeyboardFocusEntity(entityItemID);1454 setKeyboardFocusEntity(entityItemID);
@@ -1663,8 +1663,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 208 unmodified lines
1663 totalServerOctreeElements += i->second.getTotalElements();1663 totalServerOctreeElements += i->second.getTotalElements();
1664 }1664 }
1665 1665
1666 properties["local_octree_elements"] = (qint64) OctreeElement::getInternalNodeCount();1666 properties["local_octree_elements"] = (qint64)OctreeElement::getInternalNodeCount();
1667 properties["server_octree_elements"] = (qint64) totalServerOctreeElements;1667 properties["server_octree_elements"] = (qint64)totalServerOctreeElements;
1668 1668
1669 properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();1669 properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
1670 properties["using_hmd"] = isHMDMode();1670 properties["using_hmd"] = isHMDMode();
@@ -1685,7 +1685,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 14 unmodified lines
1685 if (_autoSwitchDisplayModeSupportedHMDPlugin) {1685 if (_autoSwitchDisplayModeSupportedHMDPlugin) {
1686 if (getActiveDisplayPlugin() != _autoSwitchDisplayModeSupportedHMDPlugin &&1686 if (getActiveDisplayPlugin() != _autoSwitchDisplayModeSupportedHMDPlugin &&
1687 !_autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {1687 !_autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {
1688 startHMDStandBySession();1688 startHMDStandBySession();
1689 }1689 }
1690 // Poll periodically to check whether the user has worn HMD or not. Switch Display mode accordingly.1690 // Poll periodically to check whether the user has worn HMD or not. Switch Display mode accordingly.
1691 // If the user wears HMD then switch to VR mode. If the user removes HMD then switch to Desktop mode.1691 // If the user wears HMD then switch to VR mode. If the user removes HMD then switch to Desktop mode.
@@ -1729,7 +1729,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 37 unmodified lines
1729 connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {1729 connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
1730 auto avatarManager = DependencyManager::get<AvatarManager>();1730 auto avatarManager = DependencyManager::get<AvatarManager>();
1731 int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getPosition(),1731 int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getPosition(),
1732 NEARBY_AVATAR_RADIUS_METERS) - 1;1732 NEARBY_AVATAR_RADIUS_METERS) - 1;
1733 if (nearbyAvatars != lastCountOfNearbyAvatars) {1733 if (nearbyAvatars != lastCountOfNearbyAvatars) {
1734 lastCountOfNearbyAvatars = nearbyAvatars;1734 lastCountOfNearbyAvatars = nearbyAvatars;
1735 UserActivityLogger::getInstance().logAction("nearby_avatars", { { "count", nearbyAvatars } });1735 UserActivityLogger::getInstance().logAction("nearby_avatars", { { "count", nearbyAvatars } });
@@ -1817,14 +1817,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 81 unmodified lines
1817 1817
1818 connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);1818 connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);
1819 1819
1820 _pickManager.setShouldPickHUDOperator([&]() { return DependencyManager::get<HMDScriptingInterface>()->isHMDMode(); });
1821
1820 // Setup the mouse ray pick and related operators1822 // Setup the mouse ray pick and related operators
1821 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_rayPickManager.createRayPick(1823 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_pickManager.addPick(RAY, std::make_shared<MouseRayPick>(
1822 PickFilter(RayPickScriptingInterface::PICK_ENTITIES() | RayPickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()),1824 PickFilter(RayPickScriptingInterface::PICK_ENTITIES() | RayPickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true)));
1823 0.0f, true));
1824 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](QUuid rayPickID) {1825 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](QUuid rayPickID) {
1825 RayToEntityIntersectionResult entityResult;1826 RayToEntityIntersectionResult entityResult;
1826 entityResult.intersects = false;1827 entityResult.intersects = false;
1827 QVariantMap result = _rayPickManager.getPrevPickResult(rayPickID);1828 QVariantMap result = _pickManager.getPrevPickResult(rayPickID);
1828 if (result["type"].isValid()) {1829 if (result["type"].isValid()) {
1829 entityResult.intersects = result["type"] != RayPickScriptingInterface::INTERSECTED_NONE();1830 entityResult.intersects = result["type"] != RayPickScriptingInterface::INTERSECTED_NONE();
1830 if (entityResult.intersects) {1831 if (entityResult.intersects) {
@@ -1838,7 +1839,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 7 unmodified lines
1838 return entityResult;1839 return entityResult;
1839 });1840 });
1840 DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](QUuid rayPickID, bool value) {1841 DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](QUuid rayPickID, bool value) {
1841 _rayPickManager.setPrecisionPicking(rayPickID, value);1842 _pickManager.setPrecisionPicking(rayPickID, value);
1842 });1843 });
1843 1844
1844 qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID());1845 qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID());
@@ -4910,8 +4911,8 @@ void Application::update(float deltaTime) { · 3065 unmodified lines
4910 4911
4911 // TODO: break these out into distinct perfTimers when they prove interesting4912 // TODO: break these out into distinct perfTimers when they prove interesting
4912 {4913 {
4913 PROFILE_RANGE(app, "RayPickManager");4914 PROFILE_RANGE(app, "PickManager");
4914 _rayPickManager.update();4915 _pickManager.update();
4915 }4916 }
4916 4917
4917 {4918 {