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
195195
196196 #include <raypick/RayPickScriptingInterface.h>
197197 #include <raypick/LaserPointerScriptingInterface.h>
198+#include <raypick/MouseRayPick.h>
198199
199200 #include <FadeEffect.h>
200201
@@ -750,8 +751,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 549 unmodified lines
750751 _notifiedPacketVersionMismatchThisDomain(false),
751752 _maxOctreePPS(maxOctreePacketsPerSecond.get()),
752753 _lastFaceTrackerUpdate(0),
753− _snapshotSound(nullptr)
754−{
754+ _snapshotSound(nullptr) {
755755 auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
756756 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
757757 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
@@ -795,7 +795,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 37 unmodified lines
795795 installNativeEventFilter(&MyNativeEventFilter::getInstance());
796796 #endif
797797
798−
798+
799799 _logger = new FileLogger(this);
800800 qInstallMessageHandler(messageHandler);
801801
@@ -850,13 +850,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 48 unmodified lines
850850
851851
852852 auto audioIO = DependencyManager::get<AudioClient>();
853− audioIO->setPositionGetter([]{
853+ audioIO->setPositionGetter([] {
854854 auto avatarManager = DependencyManager::get<AvatarManager>();
855855 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
856856
857857 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;
858858 });
859− audioIO->setOrientationGetter([]{
859+ audioIO->setOrientationGetter([] {
860860 auto avatarManager = DependencyManager::get<AvatarManager>();
861861 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
862862
@@ -867,7 +867,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 4 unmodified lines
867867 audioIO->handleRecordedAudioInput(frame->data);
868868 });
869869
870− connect(audioIO.data(), &AudioClient::inputReceived, [](const QByteArray& audio){
870+ connect(audioIO.data(), &AudioClient::inputReceived, [](const QByteArray& audio) {
871871 static auto recorder = DependencyManager::get<recording::Recorder>();
872872 if (recorder->isRecording()) {
873873 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
956956 auto addressManager = DependencyManager::get<AddressManager>();
957957
958958 // use our MyAvatar position and quat for address manager path
959− addressManager->setPositionGetter([this]{ return getMyAvatar()->getPosition(); });
960− addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });
959+ addressManager->setPositionGetter([this] { return getMyAvatar()->getPosition(); });
960+ addressManager->setOrientationGetter([this] { return getMyAvatar()->getOrientation(); });
961961
962962 connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
963963 connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
964964
965965 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
966− connect(this, &Application::activeDisplayPluginChanged, this, [](){
966+ connect(this, &Application::activeDisplayPluginChanged, this, []() {
967967 qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());
968968 });
969969 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);
@@ -973,7 +973,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 3 unmodified lines
973973 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
974974
975975 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
976− scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){
976+ scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine) {
977977 registerScriptEngineWithApplicationServices(engine);
978978 });
979979
@@ -989,7 +989,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
989989 }, Qt::QueuedConnection);
990990
991991 connect(scriptEngines, &ScriptEngines::scriptLoadError,
992− scriptEngines, [](const QString& filename, const QString& error){
992+ scriptEngines, [](const QString& filename, const QString& error) {
993993 OffscreenUi::asyncWarning(nullptr, "Error Loading Script", filename + " failed to load.");
994994 }, Qt::QueuedConnection);
995995
@@ -1101,7 +1101,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 105 unmodified lines
11011101 }
11021102
11031103 // add firstRun flag from settings to launch event
1104− Setting::Handle<bool> firstRun { Settings::firstRun, true };
1104+ Setting::Handle<bool> firstRun{ Settings::firstRun, true };
11051105
11061106 // once the settings have been loaded, check if we need to flip the default for UserActivityLogger
11071107 auto& userActivityLogger = UserActivityLogger::getInstance();
@@ -1202,42 +1202,42 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 94 unmodified lines
12021202 static int lastKey = Qt::Key_unknown;
12031203 bool navAxis = false;
12041204 switch (actionEnum) {
1205− case Action::UI_NAV_VERTICAL:
1206− navAxis = true;
1207− if (state > 0.0f) {
1208− key = Qt::Key_Up;
1209− } else if (state < 0.0f) {
1210− key = Qt::Key_Down;
1211− }
1212− break;
1205+ case Action::UI_NAV_VERTICAL:
1206+ navAxis = true;
1207+ if (state > 0.0f) {
1208+ key = Qt::Key_Up;
1209+ } else if (state < 0.0f) {
1210+ key = Qt::Key_Down;
1211+ }
1212+ break;
12131213
1214− case Action::UI_NAV_LATERAL:
1215− navAxis = true;
1216− if (state > 0.0f) {
1217− key = Qt::Key_Right;
1218− } else if (state < 0.0f) {
1219− key = Qt::Key_Left;
1220− }
1221− break;
1214+ case Action::UI_NAV_LATERAL:
1215+ navAxis = true;
1216+ if (state > 0.0f) {
1217+ key = Qt::Key_Right;
1218+ } else if (state < 0.0f) {
1219+ key = Qt::Key_Left;
1220+ }
1221+ break;
12221222
1223− case Action::UI_NAV_GROUP:
1224− navAxis = true;
1225− if (state > 0.0f) {
1226− key = Qt::Key_Tab;
1227− } else if (state < 0.0f) {
1228− key = Qt::Key_Backtab;
1229− }
1230− break;
1223+ case Action::UI_NAV_GROUP:
1224+ navAxis = true;
1225+ if (state > 0.0f) {
1226+ key = Qt::Key_Tab;
1227+ } else if (state < 0.0f) {
1228+ key = Qt::Key_Backtab;
1229+ }
1230+ break;
12311231
1232− case Action::UI_NAV_BACK:
1233− key = Qt::Key_Escape;
1234− break;
1232+ case Action::UI_NAV_BACK:
1233+ key = Qt::Key_Escape;
1234+ break;
12351235
1236− case Action::UI_NAV_SELECT:
1237− key = Qt::Key_Return;
1238− break;
1239− default:
1240− break;
1236+ case Action::UI_NAV_SELECT:
1237+ key = Qt::Key_Return;
1238+ break;
1239+ default:
1240+ break;
12411241 }
12421242
12431243 auto window = tabletScriptingInterface->getTabletWindow();
@@ -1376,8 +1376,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 132 unmodified lines
13761376
13771377
13781378 QTimer* settingsTimer = new QTimer();
1379− moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
1380− connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer]{
1379+ moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer] {
1380+ connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer] {
13811381 // Disconnect the signal from the save settings
13821382 QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
13831383 // Stop the settings timer
@@ -1439,7 +1439,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 55 unmodified lines
14391439 // Now that menu is initialized we can sync myAvatar with it's state.
14401440 myAvatar->updateMotionBehaviorFromMenu();
14411441
1442−// FIXME spacemouse code still needs cleanup
1442+ // FIXME spacemouse code still needs cleanup
14431443 #if 0
14441444 // the 3Dconnexion device wants to be initialized after a window is displayed.
14451445 SpacemouseManager::getInstance().init();
@@ -1448,7 +1448,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 2 unmodified lines
14481448 // 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
14491449 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
14501450 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
1451− [this](const EntityItemID& entityItemID, const PointerEvent& event) {
1451+ [this](const EntityItemID& entityItemID, const PointerEvent& event) {
14521452 if (getEntities()->wantsKeyboardFocus(entityItemID)) {
14531453 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
14541454 setKeyboardFocusEntity(entityItemID);
@@ -1663,8 +1663,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 208 unmodified lines
16631663 totalServerOctreeElements += i->second.getTotalElements();
16641664 }
16651665
1666− properties["local_octree_elements"] = (qint64) OctreeElement::getInternalNodeCount();
1667− properties["server_octree_elements"] = (qint64) totalServerOctreeElements;
1666+ properties["local_octree_elements"] = (qint64)OctreeElement::getInternalNodeCount();
1667+ properties["server_octree_elements"] = (qint64)totalServerOctreeElements;
16681668
16691669 properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
16701670 properties["using_hmd"] = isHMDMode();
@@ -1685,7 +1685,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 14 unmodified lines
16851685 if (_autoSwitchDisplayModeSupportedHMDPlugin) {
16861686 if (getActiveDisplayPlugin() != _autoSwitchDisplayModeSupportedHMDPlugin &&
16871687 !_autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {
1688− startHMDStandBySession();
1688+ startHMDStandBySession();
16891689 }
16901690 // Poll periodically to check whether the user has worn HMD or not. Switch Display mode accordingly.
16911691 // 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
17291729 connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
17301730 auto avatarManager = DependencyManager::get<AvatarManager>();
17311731 int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getPosition(),
1732− NEARBY_AVATAR_RADIUS_METERS) - 1;
1732+ NEARBY_AVATAR_RADIUS_METERS) - 1;
17331733 if (nearbyAvatars != lastCountOfNearbyAvatars) {
17341734 lastCountOfNearbyAvatars = nearbyAvatars;
17351735 UserActivityLogger::getInstance().logAction("nearby_avatars", { { "count", nearbyAvatars } });
@@ -1817,14 +1817,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 81 unmodified lines
18171817
18181818 connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);
18191819
1820+ _pickManager.setShouldPickHUDOperator([&]() { return DependencyManager::get<HMDScriptingInterface>()->isHMDMode(); });
1821+
18201822 // Setup the mouse ray pick and related operators
1821− DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_rayPickManager.createRayPick(
1822− PickFilter(RayPickScriptingInterface::PICK_ENTITIES() | RayPickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()),
1823− 0.0f, true));
1823+ DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_pickManager.addPick(RAY, std::make_shared<MouseRayPick>(
1824+ PickFilter(RayPickScriptingInterface::PICK_ENTITIES() | RayPickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true)));
18241825 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](QUuid rayPickID) {
18251826 RayToEntityIntersectionResult entityResult;
18261827 entityResult.intersects = false;
1827− QVariantMap result = _rayPickManager.getPrevPickResult(rayPickID);
1828+ QVariantMap result = _pickManager.getPrevPickResult(rayPickID);
18281829 if (result["type"].isValid()) {
18291830 entityResult.intersects = result["type"] != RayPickScriptingInterface::INTERSECTED_NONE();
18301831 if (entityResult.intersects) {
@@ -1838,7 +1839,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 7 unmodified lines
18381839 return entityResult;
18391840 });
18401841 DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](QUuid rayPickID, bool value) {
1841− _rayPickManager.setPrecisionPicking(rayPickID, value);
1842+ _pickManager.setPrecisionPicking(rayPickID, value);
18421843 });
18431844
18441845 qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID());
@@ -4910,8 +4911,8 @@ void Application::update(float deltaTime) { · 3065 unmodified lines
49104911
49114912 // TODO: break these out into distinct perfTimers when they prove interesting
49124913 {
4913− PROFILE_RANGE(app, "RayPickManager");
4914− _rayPickManager.update();
4914+ PROFILE_RANGE(app, "PickManager");
4915+ _pickManager.update();
49154916 }
49164917
49174918 {