History

Merge remote-tracking branch 'upstream/master' into destroy

SamGondelman committed 8 years ago

Commit 8a9c27e2 parents d2699e8 7905c91476 files · +19958 −8214Browse files

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

Unified · Split

interface/src/Application.cpp+92−21
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 #include <QtCore/QFileSelector>
3131 #include <QtConcurrent/QtConcurrentRun>
3232
33+#include <QtGui/QClipboard>
3334 #include <QtGui/QScreen>
3435 #include <QtGui/QWindow>
3536 #include <QtGui/QDesktopServices>
@@ -62,6 +63,7 @@ · 26 unmodified lines
6263 #include <AddressManager.h>
6364 #include <AnimDebugDraw.h>
6465 #include <BuildInfo.h>
66+#include <AnimationCacheScriptingInterface.h>
6567 #include <AssetClient.h>
6668 #include <AssetUpload.h>
6769 #include <AutoUpdater.h>
@@ -97,6 +99,8 @@ · 29 unmodified lines
9799 #include <MainWindow.h>
98100 #include <MappingRequest.h>
99101 #include <MessagesClient.h>
102+#include <model-networking/ModelCacheScriptingInterface.h>
103+#include <model-networking/TextureCacheScriptingInterface.h>
100104 #include <ModelEntityItem.h>
101105 #include <NetworkAccessManager.h>
102106 #include <NetworkingConstants.h>
@@ -126,9 +130,10 @@ · 23 unmodified lines
126130 #include <ScriptEngines.h>
127131 #include <ScriptCache.h>
128132 #include <ShapeEntityItem.h>
129−#include <SoundCache.h>
133+#include <SoundCacheScriptingInterface.h>
130134 #include <ui/TabletScriptingInterface.h>
131135 #include <ui/ToolbarScriptingInterface.h>
136+#include <InteractiveWindow.h>
132137 #include <Tooltip.h>
133138 #include <udt/PacketHeaders.h>
134139 #include <UserActivityLogger.h>
@@ -141,6 +146,7 @@ · 6 unmodified lines
141146 #include <QmlFragmentClass.h>
142147 #include <Preferences.h>
143148 #include <display-plugins/CompositorHelper.h>
149+#include <display-plugins/hmd/HmdDisplayPlugin.h>
144150 #include <trackers/EyeTracker.h>
145151 #include <avatars-renderer/ScriptAvatar.h>
146152 #include <RenderableEntityItem.h>
@@ -864,16 +870,20 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 717 unmodified lines
864870 DependencyManager::set<recording::ClipCache>();
865871 DependencyManager::set<GeometryCache>();
866872 DependencyManager::set<ModelCache>();
873+ DependencyManager::set<ModelCacheScriptingInterface>();
867874 DependencyManager::set<ScriptCache>();
868875 DependencyManager::set<SoundCache>();
876+ DependencyManager::set<SoundCacheScriptingInterface>();
869877 DependencyManager::set<DdeFaceTracker>();
870878 DependencyManager::set<EyeTracker>();
871879 DependencyManager::set<AudioClient>();
872880 DependencyManager::set<AudioScope>();
873881 DependencyManager::set<DeferredLightingEffect>();
874882 DependencyManager::set<TextureCache>();
883+ DependencyManager::set<TextureCacheScriptingInterface>();
875884 DependencyManager::set<FramebufferCache>();
876885 DependencyManager::set<AnimationCache>();
886+ DependencyManager::set<AnimationCacheScriptingInterface>();
877887 DependencyManager::set<ModelBlender>();
878888 DependencyManager::set<UsersScriptingInterface>();
879889 DependencyManager::set<AvatarManager>();
@@ -1072,6 +1082,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 192 unmodified lines
10721082 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Regular.ttf");
10731083 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Bold.ttf");
10741084 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-SemiBold.ttf");
1085+ QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Cairo-SemiBold.ttf");
10751086 _window->setWindowTitle("High Fidelity Interface");
10761087
10771088 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
@@ -1449,8 +1460,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 371 unmodified lines
14491460 // add firstRun flag from settings to launch event
14501461 Setting::Handle<bool> firstRun { Settings::firstRun, true };
14511462
1452− QString machineFingerPrint = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
1453−
14541463 auto& userActivityLogger = UserActivityLogger::getInstance();
14551464 if (userActivityLogger.isEnabled()) {
14561465 // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
@@ -1502,13 +1511,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 45 unmodified lines
15021511 properties["first_run"] = firstRun.get();
15031512
15041513 // add the user's machine ID to the launch event
1514+ QString machineFingerPrint = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
15051515 properties["machine_fingerprint"] = machineFingerPrint;
15061516
15071517 userActivityLogger.logAction("launch", properties);
15081518 }
15091519
1510− setCrashAnnotation("machine_fingerprint", machineFingerPrint.toStdString());
1511−
15121520 _entityEditSender.setMyAvatar(myAvatar.get());
15131521
15141522 // The entity octree will have to know about MyAvatar for the parentJointName import
@@ -2130,6 +2138,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 615 unmodified lines
21302138 || ((rightHandPose.valid || lastRightHandPose.valid) && (rightHandPose != lastRightHandPose));
21312139 lastLeftHandPose = leftHandPose;
21322140 lastRightHandPose = rightHandPose;
2141+ properties["avatar_identity_requests_sent"] = DependencyManager::get<AvatarManager>()->getIdentityRequestsSent();
21332142
21342143 UserActivityLogger::getInstance().logAction("stats", properties);
21352144 });
@@ -2266,6 +2275,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 130 unmodified lines
22662275 qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID());
22672276
22682277 #if defined(Q_OS_ANDROID)
2278+ connect(&AndroidHelper::instance(), &AndroidHelper::beforeEnterBackground, this, &Application::beforeEnterBackground);
22692279 connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground);
22702280 connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
22712281 AndroidHelper::instance().notifyLoadComplete();
@@ -2575,12 +2585,18 @@ Application::~Application() { · 303 unmodified lines
25752585
25762586 DependencyManager::destroy<CompositorHelper>(); // must be destroyed before the FramebufferCache
25772587
2588+ DependencyManager::destroy<SoundCacheScriptingInterface>();
2589+
25782590 DependencyManager::destroy<AvatarManager>();
2591+ DependencyManager::destroy<AnimationCacheScriptingInterface>();
25792592 DependencyManager::destroy<AnimationCache>();
25802593 DependencyManager::destroy<FramebufferCache>();
2594+ DependencyManager::destroy<TextureCacheScriptingInterface>();
25812595 DependencyManager::destroy<TextureCache>();
2596+ DependencyManager::destroy<ModelCacheScriptingInterface>();
25822597 DependencyManager::destroy<ModelCache>();
25832598 DependencyManager::destroy<ScriptCache>();
2599+ DependencyManager::destroy<SoundCacheScriptingInterface>();
25842600 DependencyManager::destroy<SoundCache>();
25852601 DependencyManager::destroy<OctreeStatsProvider>();
25862602 DependencyManager::destroy<GeometryCache>();
@@ -2730,6 +2746,10 @@ void Application::initializeDisplayPlugins() { · 143 unmodified lines
27302746 QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged,
27312747 [this](const QSize& size) { resizeGL(); });
27322748 QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
2749+ if (displayPlugin->isHmd()) {
2750+ QObject::connect(dynamic_cast<HmdDisplayPlugin*>(displayPlugin.get()), &HmdDisplayPlugin::hmdMountedChanged,
2751+ DependencyManager::get<HMDScriptingInterface>().data(), &HMDScriptingInterface::mountedChanged);
2752+ }
27332753 }
27342754
27352755 // The default display plugin needs to be activated first, otherwise the display plugin thread
@@ -2994,6 +3014,7 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) { · 258 unmodified lines
29943014
29953015 surfaceContext->setContextProperty("Overlays", &_overlays);
29963016 surfaceContext->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data());
3017+ surfaceContext->setContextProperty("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
29973018 surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
29983019 surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
29993020 surfaceContext->setContextProperty("ScriptDiscoveryService", DependencyManager::get<ScriptEngines>().data());
@@ -3001,10 +3022,11 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) { · 1 unmodified line
30013022 surfaceContext->setContextProperty("LocationBookmarks", DependencyManager::get<LocationBookmarks>().data());
30023023
30033024 // Caches
3004− surfaceContext->setContextProperty("AnimationCache", DependencyManager::get<AnimationCache>().data());
3005− surfaceContext->setContextProperty("TextureCache", DependencyManager::get<TextureCache>().data());
3006− surfaceContext->setContextProperty("ModelCache", DependencyManager::get<ModelCache>().data());
3007− surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data());
3025+ surfaceContext->setContextProperty("AnimationCache", DependencyManager::get<AnimationCacheScriptingInterface>().data());
3026+ surfaceContext->setContextProperty("TextureCache", DependencyManager::get<TextureCacheScriptingInterface>().data());
3027+ surfaceContext->setContextProperty("ModelCache", DependencyManager::get<ModelCacheScriptingInterface>().data());
3028+ surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
3029+
30083030 surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
30093031
30103032 surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
@@ -3233,6 +3255,7 @@ void Application::setSettingConstrainToolbarPosition(bool setting) { · 222 unmodified lines
32333255 void Application::showHelp() {
32343256 static const QString HAND_CONTROLLER_NAME_VIVE = "vive";
32353257 static const QString HAND_CONTROLLER_NAME_OCULUS_TOUCH = "oculus";
3258+ static const QString HAND_CONTROLLER_NAME_WINDOWS_MR = "windowsMR";
32363259
32373260 static const QString TAB_KEYBOARD_MOUSE = "kbm";
32383261 static const QString TAB_GAMEPAD = "gamepad";
@@ -3247,9 +3270,13 @@ void Application::showHelp() { · 8 unmodified lines
32473270 } else if (PluginUtils::isOculusTouchControllerAvailable()) {
32483271 defaultTab = TAB_HAND_CONTROLLERS;
32493272 handControllerName = HAND_CONTROLLER_NAME_OCULUS_TOUCH;
3273+ } else if (qApp->getActiveDisplayPlugin()->getName() == "WindowMS") {
3274+ defaultTab = TAB_HAND_CONTROLLERS;
3275+ handControllerName = HAND_CONTROLLER_NAME_WINDOWS_MR;
32503276 } else if (PluginUtils::isXboxControllerAvailable()) {
32513277 defaultTab = TAB_GAMEPAD;
32523278 }
3279+ // TODO need some way to detect windowsMR to load controls reference default tab in Help > Controls Reference menu.
32533280
32543281 QUrlQuery queryString;
32553282 queryString.addQueryItem("handControllerName", handControllerName);
@@ -3274,13 +3301,22 @@ void Application::resizeGL() { · 18 unmodified lines
32743301 // Set the desired FBO texture size. If it hasn't changed, this does nothing.
32753302 // Otherwise, it must rebuild the FBOs
32763303 uvec2 framebufferSize = displayPlugin->getRecommendedRenderSize();
3277− float renderResolutionScale = getRenderResolutionScale();
3278− uvec2 renderSize = uvec2(vec2(framebufferSize) * renderResolutionScale);
3304+ uvec2 renderSize = uvec2(framebufferSize);
32793305 if (_renderResolution != renderSize) {
32803306 _renderResolution = renderSize;
32813307 DependencyManager::get<FramebufferCache>()->setFrameBufferSize(fromGlm(renderSize));
32823308 }
32833309
3310+ auto renderResolutionScale = getRenderResolutionScale();
3311+ if (displayPlugin->getRenderResolutionScale() != renderResolutionScale) {
3312+ auto renderConfig = _renderEngine->getConfiguration();
3313+ assert(renderConfig);
3314+ auto mainView = renderConfig->getConfig("RenderMainView.RenderDeferredTask");
3315+ assert(mainView);
3316+ mainView->setProperty("resolutionScale", renderResolutionScale);
3317+ displayPlugin->setRenderResolutionScale(renderResolutionScale);
3318+ }
3319+
32843320 // FIXME the aspect ratio for stereo displays is incorrect based on this.
32853321 float aspectRatio = displayPlugin->getRecommendedAspectRatio();
32863322 _myCamera.setProjection(glm::perspective(glm::radians(_fieldOfView.get()), aspectRatio,
@@ -3292,7 +3328,6 @@ void Application::resizeGL() { · 5 unmodified lines
32923328 }
32933329
32943330 DependencyManager::get<OffscreenUi>()->resize(fromGlm(displayPlugin->getRecommendedUiSize()));
3295− displayPlugin->setRenderResolutionScale(renderResolutionScale);
32963331 }
32973332
32983333 void Application::handleSandboxStatus(QNetworkReply* reply) {
@@ -3652,6 +3687,10 @@ bool Application::event(QEvent* event) { · 353 unmodified lines
36523687
36533688 bool Application::eventFilter(QObject* object, QEvent* event) {
36543689
3690+ if (_aboutToQuit) {
3691+ return true;
3692+ }
3693+
36553694 if (event->type() == QEvent::Leave) {
36563695 getApplicationCompositor().handleLeaveEvent();
36573696 }
@@ -4031,7 +4070,18 @@ void Application::mousePressEvent(QMouseEvent* event) { · 373 unmodified lines
40314070 return;
40324071 }
40334072
4073+#if defined(Q_OS_MAC)
4074+ // Fix for OSX right click dragging on window when coming from a native window
4075+ bool isFocussed = hasFocus();
4076+ if (!isFocussed && event->button() == Qt::MouseButton::RightButton) {
4077+ setFocus();
4078+ isFocussed = true;
4079+ }
4080+
4081+ if (isFocussed) {
4082+#else
40344083 if (hasFocus()) {
4084+#endif
40354085 if (_keyboardMouseDevice->isActive()) {
40364086 _keyboardMouseDevice->mousePressEvent(event);
40374087 }
@@ -4818,6 +4868,7 @@ void Application::loadSettings() { · 780 unmodified lines
48184868 }
48194869
48204870 isFirstPerson = (qApp->isHMDMode());
4871+
48214872 } else {
48224873 // if this is not the first run, the camera will be initialized differently depending on user settings
48234874
@@ -5265,7 +5316,7 @@ void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm · 441 unmodified lines
52655316 _keyboardFocusHighlight->setPulseMin(0.5);
52665317 _keyboardFocusHighlight->setPulseMax(1.0);
52675318 _keyboardFocusHighlight->setColorPulse(1.0);
5268− _keyboardFocusHighlight->setIgnoreRayIntersection(true);
5319+ _keyboardFocusHighlight->setIgnorePickIntersection(true);
52695320 _keyboardFocusHighlight->setDrawInFront(false);
52705321 _keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight);
52715322 }
@@ -6169,6 +6220,9 @@ PickRay Application::computePickRay(float x, float y) const { · 897 unmodified lines
61696220 getApplicationCompositor().computeHmdPickRay(pickPoint, result.origin, result.direction);
61706221 } else {
61716222 pickPoint /= getCanvasSize();
6223+ if (_myCamera.getMode() == CameraMode::CAMERA_MODE_MIRROR) {
6224+ pickPoint.x = 1.0f - pickPoint.x;
6225+ }
61726226 QMutexLocker viewLocker(&_viewMutex);
61736227 _viewFrustum.computePickRay(pickPoint.x, pickPoint.y, result.origin, result.direction);
61746228 }
@@ -6504,9 +6558,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 329 unmodified lines
65046558 entityScriptingInterface->setPacketSender(&_entityEditSender);
65056559 entityScriptingInterface->setEntityTree(getEntities()->getTree());
65066560
6507− // give the script engine to the RecordingScriptingInterface for its callbacks
6508− DependencyManager::get<RecordingScriptingInterface>()->setScriptEngine(scriptEngine);
6509−
65106561 if (property(hifi::properties::TEST).isValid()) {
65116562 scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance());
65126563 }
@@ -6580,10 +6631,10 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 67 unmodified lines
65806631 scriptEngine->registerGlobalObject("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
65816632
65826633 // Caches
6583− scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
6584− scriptEngine->registerGlobalObject("TextureCache", DependencyManager::get<TextureCache>().data());
6585− scriptEngine->registerGlobalObject("ModelCache", DependencyManager::get<ModelCache>().data());
6586− scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
6634+ scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCacheScriptingInterface>().data());
6635+ scriptEngine->registerGlobalObject("TextureCache", DependencyManager::get<TextureCacheScriptingInterface>().data());
6636+ scriptEngine->registerGlobalObject("ModelCache", DependencyManager::get<ModelCacheScriptingInterface>().data());
6637+ scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
65876638
65886639 scriptEngine->registerGlobalObject("DialogsManager", _dialogsManagerScriptingInterface);
65896640
@@ -6642,6 +6693,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 52 unmodified lines
66426693
66436694 qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue);
66446695
6696+ registerInteractiveWindowMetaType(scriptEngine.data());
6697+
66456698 DependencyManager::get<PickScriptingInterface>()->registerMetaTypes(scriptEngine.data());
66466699
66476700 // connect this script engines printedMessage signal to the global ScriptEngines these various messages
@@ -7622,7 +7675,6 @@ void Application::toggleEntityScriptServerLogDialog() { · 974 unmodified lines
76227675
76237676 void Application::loadAddAvatarBookmarkDialog() const {
76247677 auto avatarBookmarks = DependencyManager::get<AvatarBookmarks>();
7625− avatarBookmarks->addBookmark();
76267678 }
76277679
76287680 void Application::loadAvatarBrowser() const {
@@ -8304,7 +8356,24 @@ void Application::saveNextPhysicsStats(QString filename) { · 675 unmodified lines
83048356 _physicsEngine->saveNextPhysicsStats(filename);
83058357 }
83068358
8359+void Application::copyToClipboard(const QString& text) {
8360+ if (QThread::currentThread() != qApp->thread()) {
8361+ QMetaObject::invokeMethod(this, "copyToClipboard");
8362+ return;
8363+ }
8364+
8365+ // assume that the address is being copied because the user wants a shareable address
8366+ QApplication::clipboard()->setText(text);
8367+}
8368+
83078369 #if defined(Q_OS_ANDROID)
8370+void Application::beforeEnterBackground() {
8371+ auto nodeList = DependencyManager::get<NodeList>();
8372+ nodeList->setSendDomainServerCheckInEnabled(false);
8373+ nodeList->reset(true);
8374+ clearDomainOctreeDetails();
8375+}
8376+
83088377 void Application::enterBackground() {
83098378 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
83108379 "stop", Qt::BlockingQueuedConnection);
@@ -8319,6 +8388,8 @@ void Application::enterForeground() { · 8 unmodified lines
83198388 if (!getActiveDisplayPlugin() || getActiveDisplayPlugin()->isActive() || !getActiveDisplayPlugin()->activate()) {
83208389 qWarning() << "Could not re-activate display plugin";
83218390 }
8391+ auto nodeList = DependencyManager::get<NodeList>();
8392+ nodeList->setSendDomainServerCheckInEnabled(true);
83228393 }
83238394 #endif
83248395