History

Merge remote-tracking branch 'upstream/master' into stable-merge

Ryan Huffman committed 9 years ago

Commit 150dcd72 parents bf73183 76ef2b5604 files · +26518 −12320Browse files

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

Unified · Split

interface/src/Application.cpp+243−175
@@ -171,13 +171,17 @@ · 170 unmodified lines
171171 #include "ui/Stats.h"
172172 #include "ui/UpdateDialog.h"
173173 #include "ui/overlays/Overlays.h"
174+#include "ui/DomainConnectionModel.h"
174175 #include "Util.h"
175176 #include "InterfaceParentFinder.h"
177+#include "ui/OctreeStatsProvider.h"
176178
177179 #include "FrameTimingsScriptingInterface.h"
178180 #include <GPUIdent.h>
179181 #include <gl/GLHelpers.h>
180182 #include <src/scripting/LimitlessVoiceRecognitionScriptingInterface.h>
183+#include <EntityScriptClient.h>
184+#include <ModelScriptingInterface.h>
181185
182186 // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
183187 // FIXME seems to be broken.
@@ -214,20 +218,12 @@ static const QString FBX_EXTENSION = ".fbx"; · 30 unmodified lines
214218 static const QString OBJ_EXTENSION = ".obj";
215219 static const QString AVA_JSON_EXTENSION = ".ava.json";
216220
217−static const int MIRROR_VIEW_TOP_PADDING = 5;
218−static const int MIRROR_VIEW_LEFT_PADDING = 10;
219−static const int MIRROR_VIEW_WIDTH = 265;
220−static const int MIRROR_VIEW_HEIGHT = 215;
221221 static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f;
222−static const float MIRROR_REARVIEW_DISTANCE = 0.722f;
223−static const float MIRROR_REARVIEW_BODY_DISTANCE = 2.56f;
224−static const float MIRROR_FIELD_OF_VIEW = 30.0f;
225222
226223 static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND;
227224
228−static const QString INFO_WELCOME_PATH = "html/interface-welcome.html";
229225 static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html";
230−static const QString INFO_HELP_PATH = "html/help.html";
226+static const QString INFO_HELP_PATH = "../../../html/tabletHelp.html";
231227
232228 static const unsigned int THROTTLED_SIM_FRAMERATE = 15;
233229 static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE;
@@ -424,6 +420,7 @@ static const QString STATE_CAMERA_THIRD_PERSON = "CameraThirdPerson"; · 190 unmodified lines
424420 static const QString STATE_CAMERA_ENTITY = "CameraEntity";
425421 static const QString STATE_CAMERA_INDEPENDENT = "CameraIndependent";
426422 static const QString STATE_SNAP_TURN = "SnapTurn";
423+static const QString STATE_ADVANCED_MOVEMENT_CONTROLS = "AdvancedMovement";
427424 static const QString STATE_GROUNDED = "Grounded";
428425 static const QString STATE_NAV_FOCUSED = "NavigationFocused";
429426
@@ -500,6 +497,8 @@ bool setupEssentials(int& argc, char** argv) { · 70 unmodified lines
500497 DependencyManager::set<TabletScriptingInterface>();
501498 DependencyManager::set<ToolbarScriptingInterface>();
502499 DependencyManager::set<UserActivityLoggerScriptingInterface>();
500+ DependencyManager::set<AssetMappingsScriptingInterface>();
501+ DependencyManager::set<DomainConnectionModel>();
503502
504503 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
505504 DependencyManager::set<SpeechRecognizer>();
@@ -514,7 +513,7 @@ bool setupEssentials(int& argc, char** argv) { · 8 unmodified lines
514513 DependencyManager::set<MessagesClient>();
515514 controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_CAMERA_FULL_SCREEN_MIRROR,
516515 STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_THIRD_PERSON, STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT,
517− STATE_SNAP_TURN, STATE_GROUNDED, STATE_NAV_FOCUSED } });
516+ STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED } });
518517 DependencyManager::set<UserInputMapper>();
519518 DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
520519 DependencyManager::set<InterfaceParentFinder>();
@@ -524,6 +523,8 @@ bool setupEssentials(int& argc, char** argv) { · 3 unmodified lines
524523 DependencyManager::set<EntityScriptClient>();
525524 DependencyManager::set<EntityScriptServerLogClient>();
526525 DependencyManager::set<LimitlessVoiceRecognitionScriptingInterface>();
526+ DependencyManager::set<OctreeStatsProvider>(nullptr, qApp->getOcteeSceneStats());
527+
527528 return previousSessionCrashed;
528529 }
529530
@@ -551,6 +552,7 @@ const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f; · 21 unmodified lines
551552 const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true;
552553 const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false;
553554 const bool DEFAULT_TABLET_VISIBLE_TO_OTHERS = false;
555+const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = true;
554556
555557 Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runServer, QString runServerPathOption) :
556558 QApplication(argc, argv),
@@ -566,7 +568,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
566568 _entityClipboardRenderer(false, this, this),
567569 _entityClipboard(new EntityTree()),
568570 _lastQueriedTime(usecTimestampNow()),
569− _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
570571 _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION),
571572 _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
572573 _hmdTabletScale("hmdTabletScale", DEFAULT_HMD_TABLET_SCALE_PERCENT),
@@ -574,6 +575,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1 unmodified line
574575 _desktopTabletBecomesToolbarSetting("desktopTabletBecomesToolbar", DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR),
575576 _hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR),
576577 _tabletVisibleToOthersSetting("tabletVisibleToOthers", DEFAULT_TABLET_VISIBLE_TO_OTHERS),
578+ _preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
577579 _constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
578580 _scaleMirror(1.0f),
579581 _rotateMirror(0.0f),
@@ -608,6 +610,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 28 unmodified lines
608610 }
609611 }
610612
613+ // make sure the debug draw singleton is initialized on the main thread.
614+ DebugDraw::getInstance().removeMarker("");
611615
612616 _runningMarker.startRunningMarker();
613617
@@ -744,23 +748,24 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 130 unmodified lines
744748 }
745749 });
746750
747− auto& audioScriptingInterface = AudioScriptingInterface::getInstance();
751+ auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>();
748752 connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
749753 connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit);
750754 connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater);
751755 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
752− connect(audioIO.data(), &AudioClient::mutedByMixer, &audioScriptingInterface, &AudioScriptingInterface::mutedByMixer);
753− connect(audioIO.data(), &AudioClient::receivedFirstPacket, &audioScriptingInterface, &AudioScriptingInterface::receivedFirstPacket);
754− connect(audioIO.data(), &AudioClient::disconnected, &audioScriptingInterface, &AudioScriptingInterface::disconnected);
756+ connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
757+ connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);
758+ connect(audioIO.data(), &AudioClient::disconnected, audioScriptingInterface.data(), &AudioScriptingInterface::disconnected);
755759 connect(audioIO.data(), &AudioClient::muteEnvironmentRequested, [](glm::vec3 position, float radius) {
756760 auto audioClient = DependencyManager::get<AudioClient>();
761+ auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();
757762 auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition();
758763 float distance = glm::distance(myAvatarPosition, position);
759764 bool shouldMute = !audioClient->isMuted() && (distance < radius);
760765
761766 if (shouldMute) {
762767 audioClient->toggleMute();
763− AudioScriptingInterface::getInstance().environmentMuted();
768+ audioScriptingInterface->environmentMuted();
764769 }
765770 });
766771
@@ -845,6 +850,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 78 unmodified lines
845850 connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
846851
847852 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
853+ connect(this, &Application::activeDisplayPluginChanged, this, [](){
854+ qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());
855+ });
848856 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);
849857
850858 // Save avatar location immediately after a teleport.
@@ -1127,6 +1135,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 276 unmodified lines
11271135 _applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float {
11281136 return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0;
11291137 });
1138+ _applicationStateDevice->setInputVariant(STATE_ADVANCED_MOVEMENT_CONTROLS, []() -> float {
1139+ return qApp->getMyAvatar()->useAdvancedMovementControls() ? 1 : 0;
1140+ });
1141+
11301142 _applicationStateDevice->setInputVariant(STATE_GROUNDED, []() -> float {
11311143 return qApp->getMyAvatar()->getCharacterController()->onGround() ? 1 : 0;
11321144 });
@@ -1181,7 +1193,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 48 unmodified lines
11811193
11821194 // set the local loopback interface for local sounds
11831195 AudioInjector::setLocalAudioInterface(audioIO.data());
1184− AudioScriptingInterface::getInstance().setLocalAudioInterface(audioIO.data());
1196+ audioScriptingInterface->setLocalAudioInterface(audioIO.data());
1197+ connect(audioIO.data(), &AudioClient::noiseGateOpened, audioScriptingInterface.data(), &AudioScriptingInterface::noiseGateOpened);
1198+ connect(audioIO.data(), &AudioClient::noiseGateClosed, audioScriptingInterface.data(), &AudioScriptingInterface::noiseGateClosed);
1199+ connect(audioIO.data(), &AudioClient::inputReceived, audioScriptingInterface.data(), &AudioScriptingInterface::inputReceived);
1200+
11851201
11861202 this->installEventFilter(this);
11871203
@@ -1439,7 +1455,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 251 unmodified lines
14391455 scriptEngines->loadScript(testScript, false);
14401456 } else {
14411457 // Get sandbox content set version, if available
1442− auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";
1458+ auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";
14431459 auto contentVersionPath = acDirPath + "content-version.txt";
14441460 qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version";
14451461 auto contentVersion = 0;
@@ -1617,17 +1633,15 @@ QString Application::getUserAgent() { · 171 unmodified lines
16171633 return userAgent;
16181634 }
16191635
1620−uint64_t lastTabletUIToggle { 0 };
1621−const uint64_t toggleTabletUILockout { 500000 };
16221636 void Application::toggleTabletUI() const {
1623− uint64_t now = usecTimestampNow();
1624− if (now - lastTabletUIToggle < toggleTabletUILockout) {
1625− return;
1637+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
1638+ auto hmd = DependencyManager::get<HMDScriptingInterface>();
1639+ TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
1640+ bool messageOpen = tablet->isMessageDialogOpen();
1641+ if (!messageOpen || (messageOpen && !hmd->getShouldShowTablet())) {
1642+ auto HMD = DependencyManager::get<HMDScriptingInterface>();
1643+ HMD->toggleShouldShowTablet();
16261644 }
1627− lastTabletUIToggle = now;
1628−
1629− auto HMD = DependencyManager::get<HMDScriptingInterface>();
1630− HMD->toggleShouldShowTablet();
16311645 }
16321646
16331647 void Application::checkChangeCursor() {
@@ -1800,6 +1814,7 @@ Application::~Application() { · 166 unmodified lines
18001814 DependencyManager::destroy<GeometryCache>();
18011815 DependencyManager::destroy<ScriptCache>();
18021816 DependencyManager::destroy<SoundCache>();
1817+ DependencyManager::destroy<OctreeStatsProvider>();
18031818
18041819 ResourceManager::cleanup();
18051820
@@ -1945,8 +1960,10 @@ void Application::initializeUi() { · 139 unmodified lines
19451960 // For some reason there is already an "Application" object in the QML context,
19461961 // though I can't find it. Hence, "ApplicationInterface"
19471962 rootContext->setContextProperty("ApplicationInterface", this);
1948− rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
1963+ rootContext->setContextProperty("Audio", DependencyManager::get<AudioScriptingInterface>().data());
19491964 rootContext->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
1965+ rootContext->setContextProperty("AudioScope", DependencyManager::get<AudioScope>().data());
1966+
19501967 rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
19511968 rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
19521969 _fileDownload = new FileScriptingInterface(engine);
@@ -1959,12 +1976,13 @@ void Application::initializeUi() { · 6 unmodified lines
19591976 rootContext->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
19601977 rootContext->setContextProperty("FrameTimings", &_frameTimingsScriptingInterface);
19611978 rootContext->setContextProperty("Rates", new RatesScriptingInterface(this));
1979+ rootContext->setContextProperty("pathToFonts", "../../");
19621980
19631981 rootContext->setContextProperty("TREE_SCALE", TREE_SCALE);
19641982 rootContext->setContextProperty("Quat", new Quat());
19651983 rootContext->setContextProperty("Vec3", new Vec3());
19661984 rootContext->setContextProperty("Uuid", new ScriptUUID());
1967− rootContext->setContextProperty("Assets", new AssetMappingsScriptingInterface());
1985+ rootContext->setContextProperty("Assets", DependencyManager::get<AssetMappingsScriptingInterface>().data());
19681986
19691987 rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
19701988 rootContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
@@ -2111,21 +2129,6 @@ void Application::paintGL() { · 140 unmodified lines
21112129 batch.resetStages();
21122130 });
21132131
2114− auto inputs = AvatarInputs::getInstance();
2115− if (inputs->mirrorVisible()) {
2116− PerformanceTimer perfTimer("Mirror");
2117−
2118− renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
2119− renderArgs._blitFramebuffer = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
2120−
2121− _mirrorViewRect.moveTo(inputs->x(), inputs->y());
2122−
2123− renderRearViewMirror(&renderArgs, _mirrorViewRect, inputs->mirrorZoomed());
2124−
2125− renderArgs._blitFramebuffer.reset();
2126− renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
2127− }
2128−
21292132 {
21302133 PerformanceTimer perfTimer("renderOverlay");
21312134 // NOTE: There is no batch associated with this renderArgs
@@ -2140,7 +2143,7 @@ void Application::paintGL() { · 8 unmodified lines
21402143 PerformanceTimer perfTimer("CameraUpdates");
21412144
21422145 auto myAvatar = getMyAvatar();
2143− boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FRONT;
2146+ boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
21442147
21452148 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
21462149 Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
@@ -2364,15 +2367,15 @@ void Application::setTabletVisibleToOthersSetting(bool value) { · 217 unmodified lines
23642367 updateSystemTabletMode();
23652368 }
23662369
2370+void Application::setPreferAvatarFingerOverStylus(bool value) {
2371+ _preferAvatarFingerOverStylusSetting.set(value);
2372+}
2373+
23672374 void Application::setSettingConstrainToolbarPosition(bool setting) {
23682375 _constrainToolbarPosition.set(setting);
23692376 DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
23702377 }
23712378
2372−void Application::aboutApp() {
2373− InfoView::show(INFO_WELCOME_PATH);
2374−}
2375−
23762379 void Application::showHelp() {
23772380 static const QString HAND_CONTROLLER_NAME_VIVE = "vive";
23782381 static const QString HAND_CONTROLLER_NAME_OCULUS_TOUCH = "oculus";
@@ -2397,8 +2400,10 @@ void Application::showHelp() { · 18 unmodified lines
23972400 QUrlQuery queryString;
23982401 queryString.addQueryItem("handControllerName", handControllerName);
23992402 queryString.addQueryItem("defaultTab", defaultTab);
2400−
2401− InfoView::show(INFO_HELP_PATH, false, queryString.toString());
2403+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
2404+ TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
2405+ tablet->gotoWebScreen(INFO_HELP_PATH + "?" + queryString.toString());
2406+ //InfoView::show(INFO_HELP_PATH, false, queryString.toString());
24022407 }
24032408
24042409 void Application::resizeEvent(QResizeEvent* event) {
@@ -2754,8 +2759,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 349 unmodified lines
27542759 case Qt::Key_S:
27552760 if (isShifted && isMeta && !isOption) {
27562761 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
2757− } else if (isOption && !isShifted && !isMeta) {
2758− Menu::getInstance()->triggerOption(MenuOption::ScriptEditor);
27592762 } else if (!isOption && !isShifted && isMeta) {
27602763 takeSnapshot(true);
27612764 }
@@ -2874,56 +2877,56 @@ void Application::keyPressEvent(QKeyEvent* event) { · 112 unmodified lines
28742877 break;
28752878 #endif
28762879
2877− case Qt::Key_H:
2878− if (isShifted) {
2879− Menu::getInstance()->triggerOption(MenuOption::MiniMirror);
2880− } else {
2881− // whenever switching to/from full screen mirror from the keyboard, remember
2882− // the state you were in before full screen mirror, and return to that.
2883− auto previousMode = _myCamera.getMode();
2884− if (previousMode != CAMERA_MODE_MIRROR) {
2885− switch (previousMode) {
2886− case CAMERA_MODE_FIRST_PERSON:
2887− _returnFromFullScreenMirrorTo = MenuOption::FirstPerson;
2888− break;
2889− case CAMERA_MODE_THIRD_PERSON:
2890− _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
2891− break;
2892−
2893− // FIXME - it's not clear that these modes make sense to return to...
2894− case CAMERA_MODE_INDEPENDENT:
2895− _returnFromFullScreenMirrorTo = MenuOption::IndependentMode;
2896− break;
2897− case CAMERA_MODE_ENTITY:
2898− _returnFromFullScreenMirrorTo = MenuOption::CameraEntityMode;
2899− break;
2900−
2901− default:
2902− _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
2903− break;
2904− }
2880+ case Qt::Key_H: {
2881+ // whenever switching to/from full screen mirror from the keyboard, remember
2882+ // the state you were in before full screen mirror, and return to that.
2883+ auto previousMode = _myCamera.getMode();
2884+ if (previousMode != CAMERA_MODE_MIRROR) {
2885+ switch (previousMode) {
2886+ case CAMERA_MODE_FIRST_PERSON:
2887+ _returnFromFullScreenMirrorTo = MenuOption::FirstPerson;
2888+ break;
2889+ case CAMERA_MODE_THIRD_PERSON:
2890+ _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
2891+ break;
2892+
2893+ // FIXME - it's not clear that these modes make sense to return to...
2894+ case CAMERA_MODE_INDEPENDENT:
2895+ _returnFromFullScreenMirrorTo = MenuOption::IndependentMode;
2896+ break;
2897+ case CAMERA_MODE_ENTITY:
2898+ _returnFromFullScreenMirrorTo = MenuOption::CameraEntityMode;
2899+ break;
2900+
2901+ default:
2902+ _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
2903+ break;
29052904 }
2905+ }
29062906
2907− bool isMirrorChecked = Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror);
2908− Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, !isMirrorChecked);
2909− if (isMirrorChecked) {
2907+ bool isMirrorChecked = Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror);
2908+ Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, !isMirrorChecked);
2909+ if (isMirrorChecked) {
29102910
2911− // if we got here without coming in from a non-Full Screen mirror case, then our
2912− // _returnFromFullScreenMirrorTo is unknown. In that case we'll go to the old
2913− // behavior of returning to ThirdPerson
2914− if (_returnFromFullScreenMirrorTo.isEmpty()) {
2915− _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
2916− }
2917− Menu::getInstance()->setIsOptionChecked(_returnFromFullScreenMirrorTo, true);
2911+ // if we got here without coming in from a non-Full Screen mirror case, then our
2912+ // _returnFromFullScreenMirrorTo is unknown. In that case we'll go to the old
2913+ // behavior of returning to ThirdPerson
2914+ if (_returnFromFullScreenMirrorTo.isEmpty()) {
2915+ _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson;
29182916 }
2919− cameraMenuChanged();
2917+ Menu::getInstance()->setIsOptionChecked(_returnFromFullScreenMirrorTo, true);
29202918 }
2919+ cameraMenuChanged();
29212920 break;
2921+ }
2922+
29222923 case Qt::Key_P: {
2923− bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson);
2924− Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !isFirstPersonChecked);
2925− Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, isFirstPersonChecked);
2926− cameraMenuChanged();
2924+ if (!(isShifted || isMeta || isOption)) {
2925+ bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson);
2926+ Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !isFirstPersonChecked);
2927+ Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, isFirstPersonChecked);
2928+ cameraMenuChanged();
2929+ }
29272930 break;
29282931 }
29292932
@@ -3168,7 +3171,23 @@ void Application::mousePressEvent(QMouseEvent* event) { · 238 unmodified lines
31683171 }
31693172 }
31703173
3171−void Application::mouseDoublePressEvent(QMouseEvent* event) const {
3174+void Application::mouseDoublePressEvent(QMouseEvent* event) {
3175+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
3176+ auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
3177+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3178+ QMouseEvent mappedEvent(event->type(),
3179+ transformedPos,
3180+ event->screenPos(), event->button(),
3181+ event->buttons(), event->modifiers());
3182+
3183+ if (!_aboutToQuit) {
3184+ getOverlays().mouseDoublePressEvent(&mappedEvent);
3185+ if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
3186+ getEntities()->mouseDoublePressEvent(&mappedEvent);
3187+ }
3188+ }
3189+
3190+
31723191 // if one of our scripts have asked to capture this event, then stop processing it
31733192 if (_controllerScriptingInterface->isMouseCaptured()) {
31743193 return;
@@ -3772,7 +3791,7 @@ void Application::loadSettings() { · 597 unmodified lines
37723791 }
37733792
37743793 getMyAvatar()->loadData();
3775−
3794+ setTabletVisibleToOthersSetting(false);
37763795 _settingsLoaded = true;
37773796 }
37783797
@@ -3815,8 +3834,6 @@ void Application::init() { · 36 unmodified lines
38153834 DependencyManager::get<AvatarManager>()->init();
38163835 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
38173836
3818− _mirrorCamera.setMode(CAMERA_MODE_MIRROR);
3819−
38203837 _timerStart.start();
38213838 _lastTimeUpdated.start();
38223839
@@ -3951,7 +3968,7 @@ void Application::updateMyAvatarLookAtPosition() { · 128 unmodified lines
39513968 auto lookingAtHead = static_pointer_cast<Avatar>(lookingAt)->getHead();
39523969
39533970 const float MAXIMUM_FACE_ANGLE = 65.0f * RADIANS_PER_DEGREE;
3954− glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT;
3971+ glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD;
39553972 glm::vec3 fromLookingAtToMe = glm::normalize(myAvatar->getHead()->getEyePosition()
39563973 - lookingAtHead->getEyePosition());
39573974 float faceAngle = glm::angle(lookingAtFaceOrientation, fromLookingAtToMe);
@@ -4230,12 +4247,6 @@ void Application::updateDialogs(float deltaTime) const { · 272 unmodified lines
42304247 PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
42314248 auto dialogsManager = DependencyManager::get<DialogsManager>();
42324249
4233− // Update bandwidth dialog, if any
4234− BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();
4235− if (bandwidthDialog) {
4236− bandwidthDialog->update();
4237− }
4238−
42394250 QPointer<OctreeStatsDialog> octreeStatsDialog = dialogsManager->getOctreeStatsDialog();
42404251 if (octreeStatsDialog) {
42414252 octreeStatsDialog->update();
@@ -4359,16 +4370,16 @@ void Application::update(float deltaTime) { · 117 unmodified lines
43594370 myAvatar->clearDriveKeys();
43604371 if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {
43614372 if (!_controllerScriptingInterface->areActionsCaptured()) {
4362− myAvatar->setDriveKeys(TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
4363− myAvatar->setDriveKeys(TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
4364− myAvatar->setDriveKeys(TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));
4373+ myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
4374+ myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
4375+ myAvatar->setDriveKey(MyAvatar::TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));
43654376 if (deltaTime > FLT_EPSILON) {
4366− myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
4367− myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
4368− myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
4377+ myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
4378+ myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
4379+ myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
43694380 }
43704381 }
4371− myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
4382+ myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
43724383 }
43734384
43744385 controller::Pose leftHandPose = userInputMapper->getPoseState(controller::Action::LEFT_HAND);
@@ -4439,9 +4450,12 @@ void Application::update(float deltaTime) { · 64 unmodified lines
44394450
44404451 getEntities()->getTree()->withWriteLock([&] {
44414452 PerformanceTimer perfTimer("handleOutgoingChanges");
4442− const VectorOfMotionStates& outgoingChanges = _physicsEngine->getOutgoingChanges();
4443− _entitySimulation->handleOutgoingChanges(outgoingChanges);
4444− avatarManager->handleOutgoingChanges(outgoingChanges);
4453+ const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates();
4454+ _entitySimulation->handleDeactivatedMotionStates(deactivations);
4455+
4456+ const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates();
4457+ _entitySimulation->handleChangedMotionStates(outgoingChanges);
4458+ avatarManager->handleChangedMotionStates(outgoingChanges);
44454459 });
44464460
44474461 if (!_aboutToQuit) {
@@ -5100,58 +5114,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 652 unmodified lines
51005114 activeRenderingThread = nullptr;
51015115 }
51025116
5103−void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool isZoomed) {
5104− auto originalViewport = renderArgs->_viewport;
5105− // Grab current viewport to reset it at the end
5106−
5107− float aspect = (float)region.width() / region.height();
5108− float fov = MIRROR_FIELD_OF_VIEW;
5109−
5110− auto myAvatar = getMyAvatar();
5111−
5112− // bool eyeRelativeCamera = false;
5113− if (!isZoomed) {
5114− _mirrorCamera.setPosition(myAvatar->getChestPosition() +
5115− myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * myAvatar->getScale());
5116−
5117− } else { // HEAD zoom level
5118− // FIXME note that the positioning of the camera relative to the avatar can suffer limited
5119− // precision as the user's position moves further away from the origin. Thus at
5120− // /1e7,1e7,1e7 (well outside the buildable volume) the mirror camera veers and sways
5121− // wildly as you rotate your avatar because the floating point values are becoming
5122− // larger, squeezing out the available digits of precision you have available at the
5123− // human scale for camera positioning.
5124−
5125− // Previously there was a hack to correct this using the mechanism of repositioning
5126− // the avatar at the origin of the world for the purposes of rendering the mirror,
5127− // but it resulted in failing to render the avatar's head model in the mirror view
5128− // when in first person mode. Presumably this was because of some missed culling logic
5129− // that was not accounted for in the hack.
5130−
5131− // This was removed in commit 71e59cfa88c6563749594e25494102fe01db38e9 but could be further
5132− // investigated in order to adapt the technique while fixing the head rendering issue,
5133− // but the complexity of the hack suggests that a better approach
5134− _mirrorCamera.setPosition(myAvatar->getDefaultEyePosition() +
5135− myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * myAvatar->getScale());
5136− }
5137− _mirrorCamera.setProjection(glm::perspective(glm::radians(fov), aspect, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
5138− _mirrorCamera.setOrientation(myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
5139−
5140−
5141− // set the bounds of rear mirror view
5142− // the region is in device independent coordinates; must convert to device
5143− float ratio = (float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale();
5144− int width = region.width() * ratio;
5145− int height = region.height() * ratio;
5146− gpu::Vec4i viewport = gpu::Vec4i(0, 0, width, height);
5147− renderArgs->_viewport = viewport;
5148−
5149− // render rear mirror view
5150− displaySide(renderArgs, _mirrorCamera, true);
5151−
5152− renderArgs->_viewport = originalViewport;
5153−}
5154−
51555117 void Application::resetSensors(bool andReload) {
51565118 DependencyManager::get<Faceshift>()->reset();
51575119 DependencyManager::get<DdeFaceTracker>()->reset();
@@ -5188,6 +5150,7 @@ void Application::updateWindowTitle() const { · 30 unmodified lines
51885150 #endif
51895151 _window->setWindowTitle(title);
51905152 }
5153+
51915154 void Application::clearDomainOctreeDetails() {
51925155
51935156 // if we're about to quit, we really don't need to do any of these things...
@@ -5217,6 +5180,12 @@ void Application::clearDomainOctreeDetails() { · 23 unmodified lines
52175180 skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
52185181
52195182 _recentlyClearedDomain = true;
5183+
5184+ DependencyManager::get<AvatarManager>()->clearOtherAvatars();
5185+ DependencyManager::get<AnimationCache>()->clearUnusedResources();
5186+ DependencyManager::get<ModelCache>()->clearUnusedResources();
5187+ DependencyManager::get<SoundCache>()->clearUnusedResources();
5188+ DependencyManager::get<TextureCache>()->clearUnusedResources();
52205189 }
52215190
52225191 void Application::domainChanged(const QString& domainHostname) {
@@ -5474,8 +5443,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 251 unmodified lines
54745443 scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
54755444
54765445 // hook our avatar and avatar hash map object into this script engine
5477− scriptEngine->registerGlobalObject("MyAvatar", getMyAvatar().get());
5478− qScriptRegisterMetaType(scriptEngine, audioListenModeToScriptValue, audioListenModeFromScriptValue);
5446+ getMyAvatar()->registerMetaTypes(scriptEngine);
54795447
54805448 scriptEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarManager>().data());
54815449
@@ -5516,6 +5484,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 34 unmodified lines
55165484 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
55175485 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
55185486 scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
5487+ scriptEngine->registerGlobalObject("AudioScope", DependencyManager::get<AudioScope>().data());
55195488
55205489 // Caches
55215490 scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
@@ -5784,9 +5753,26 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) · 262 unmodified lines
57845753 }
57855754 }
57865755
5787−void Application::toggleRunningScriptsWidget() const {
5788− static const QUrl url("hifi/dialogs/RunningScripts.qml");
5789− DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
5756+void Application::toggleRunningScriptsWidget() const {
5757+ auto scriptEngines = DependencyManager::get<ScriptEngines>();
5758+ bool scriptsRunning = !scriptEngines->getRunningScripts().isEmpty();
5759+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
5760+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
5761+
5762+ if (tablet->getToolbarMode() || false == scriptsRunning) {
5763+ static const QUrl url("hifi/dialogs/RunningScripts.qml");
5764+ DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
5765+ } else {
5766+ auto hmd = DependencyManager::get<HMDScriptingInterface>();
5767+ if (!hmd->getShouldShowTablet() && !isHMDMode()) {
5768+ static const QUrl url("hifi/dialogs/RunningScripts.qml");
5769+ DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
5770+ } else {
5771+ static const QUrl url("../../hifi/dialogs/TabletRunningScripts.qml");
5772+ tablet->pushOntoStack(url);
5773+ }
5774+ }
5775+ //DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
57905776 //if (_runningScriptsWidget->isVisible()) {
57915777 // if (_runningScriptsWidget->hasFocus()) {
57925778 // _runningScriptsWidget->hide();
@@ -5801,6 +5787,24 @@ void Application::toggleRunningScriptsWidget() const { · 8 unmodified lines
58015787 //}
58025788 }
58035789
5790+void Application::showScriptLogs() {
5791+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
5792+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
5793+ auto scriptEngines = DependencyManager::get<ScriptEngines>();
5794+ QUrl defaultScriptsLoc = defaultScriptsLocation();
5795+ defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js");
5796+
5797+ if (tablet->getToolbarMode()) {
5798+ scriptEngines->loadScript(defaultScriptsLoc.toString());
5799+ } else {
5800+ QQuickItem* tabletRoot = tablet->getTabletRoot();
5801+ if (!tabletRoot && !isHMDMode()) {
5802+ scriptEngines->loadScript(defaultScriptsLoc.toString());
5803+ } else {
5804+ tablet->pushOntoStack("../../hifi/dialogs/TabletDebugWindow.qml");
5805+ }
5806+ }
5807+}
58045808
58055809 void Application::showAssetServerWidget(QString filePath) {
58065810 if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
@@ -5813,7 +5817,20 @@ void Application::showAssetServerWidget(QString filePath) { · 6 unmodified lines
58135817 emit uploadRequest(filePath);
58145818 }
58155819 };
5816− DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
5820+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
5821+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
5822+ auto hmd = DependencyManager::get<HMDScriptingInterface>();
5823+ if (tablet->getToolbarMode()) {
5824+ DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
5825+ } else {
5826+ if (!hmd->getShouldShowTablet() && !isHMDMode()) {
5827+ DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
5828+ } else {
5829+ static const QUrl url("../../hifi/dialogs/TabletAssetServer.qml");
5830+ tablet->pushOntoStack(url);
5831+ }
5832+ }
5833+
58175834 startUpload(nullptr, nullptr);
58185835 }
58195836
@@ -5836,6 +5853,21 @@ void Application::addAssetToWorldFromURL(QString url) { · 16 unmodified lines
58365853 request->send();
58375854 }
58385855
5856+void Application::showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const {
5857+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
5858+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
5859+ auto hmd = DependencyManager::get<HMDScriptingInterface>();
5860+ if (tablet->getToolbarMode()) {
5861+ DependencyManager::get<OffscreenUi>()->show(desktopURL, name);
5862+ } else {
5863+ tablet->pushOntoStack(tabletURL);
5864+ if (!hmd->getShouldShowTablet() && !isHMDMode()) {
5865+ hmd->openTablet();
5866+ }
5867+
5868+ }
5869+}
5870+
58395871 void Application::addAssetToWorldFromURLRequestFinished() {
58405872 auto request = qobject_cast<ResourceRequest*>(sender());
58415873 auto url = request->getUrl().toString();
@@ -6317,6 +6349,41 @@ void Application::loadScriptURLDialog() const { · 475 unmodified lines
63176349 }
63186350 }
63196351
6352+void Application::loadLODToolsDialog() {
6353+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
6354+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6355+ if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) {
6356+ auto dialogsManager = DependencyManager::get<DialogsManager>();
6357+ dialogsManager->lodTools();
6358+ } else {
6359+ tablet->pushOntoStack("../../hifi/dialogs/TabletLODTools.qml");
6360+ }
6361+
6362+}
6363+
6364+
6365+void Application::loadEntityStatisticsDialog() {
6366+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
6367+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6368+ if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) {
6369+ auto dialogsManager = DependencyManager::get<DialogsManager>();
6370+ dialogsManager->octreeStatsDetails();
6371+ } else {
6372+ tablet->pushOntoStack("../../hifi/dialogs/TabletEntityStatistics.qml");
6373+ }
6374+}
6375+
6376+void Application::loadDomainConnectionDialog() {
6377+ auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
6378+ auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
6379+ if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) {
6380+ auto dialogsManager = DependencyManager::get<DialogsManager>();
6381+ dialogsManager->showDomainConnectionDialog();
6382+ } else {
6383+ tablet->pushOntoStack("../../hifi/dialogs/TabletDCDialog.qml");
6384+ }
6385+}
6386+
63206387 void Application::toggleLogDialog() {
63216388 if (! _logDialog) {
63226389 _logDialog = new LogDialog(nullptr, getLogger());
@@ -6903,6 +6970,7 @@ void Application::updateThreadPoolCount() const { · 580 unmodified lines
69036970 }
69046971
69056972 void Application::updateSystemTabletMode() {
6973+ qApp->setProperty(hifi::properties::HMD, isHMDMode());
69066974 if (isHMDMode()) {
69076975 DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getHmdTabletBecomesToolbarSetting());
69086976 } else {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t