Showing the changes to interface/src/Application.cpp (1 of 8 files). Show all
Unified · Split
| @@ -290,7 +290,6 @@ bool setupEssentials(int& argc, char** argv) { · 289 unmodified lines | ||
| 290 | 290 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 291 | 291 | QApplication(argc, argv), |
| 292 | 292 | _dependencyManagerIsSetup(setupEssentials(argc, argv)), |
| 293 | − _offscreenContext(new OffscreenGlContext()), | |
| 294 | 293 | _window(new MainWindow(desktop())), |
| 295 | 294 | _toolWindow(NULL), |
| 296 | 295 | _friendsWindow(NULL), |
| @@ -319,8 +318,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 22 unmodified lines | ||
| 319 | 318 | _cursorVisible(true), |
| 320 | 319 | _lastMouseMove(usecTimestampNow()), |
| 321 | 320 | _lastMouseMoveWasSimulated(false), |
| 322 | − _touchAvgX(0.0f), | |
| 323 | − _touchAvgY(0.0f), | |
| 324 | 321 | _isTouchPressed(false), |
| 325 | 322 | _mousePressed(false), |
| 326 | 323 | _enableProcessOctreeThread(true), |
| @@ -501,7 +498,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 174 unmodified lines | ||
| 501 | 498 | ResourceCache::setRequestLimit(3); |
| 502 | 499 | |
| 503 | 500 | _window->setCentralWidget(new QWidget()); |
| 501 | + | |
| 504 | 502 | _window->restoreGeometry(); |
| 503 | + | |
| 505 | 504 | _window->setVisible(true); |
| 506 | 505 | |
| 507 | 506 | #if 0 |
| @@ -592,7 +591,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 84 unmodified lines | ||
| 592 | 591 | this->installEventFilter(this); |
| 593 | 592 | // The offscreen UI needs to intercept the mouse and keyboard |
| 594 | 593 | // events coming from the onscreen window |
| 595 | − _glWidget->installEventFilter(DependencyManager::get<OffscreenUi>().data()); | |
| 594 | + this->installEventFilter(DependencyManager::get<OffscreenUi>().data()); | |
| 596 | 595 | |
| 597 | 596 | // initialize our face trackers after loading the menu settings |
| 598 | 597 | auto faceshiftTracker = DependencyManager::get<Faceshift>(); |
| @@ -810,18 +809,14 @@ void Application::initializeUi() { · 211 unmodified lines | ||
| 810 | 809 | |
| 811 | 810 | void Application::paintGL() { |
| 812 | 811 | PROFILE_RANGE(__FUNCTION__); |
| 813 | − _glWidget->makeCurrent(); | |
| 812 | + _offscreenContext->makeCurrent(); | |
| 814 | 813 | PerformanceTimer perfTimer("paintGL"); |
| 815 | − //Need accurate frame timing for the oculus rift | |
| 816 | − if (OculusManager::isConnected()) { | |
| 817 | − OculusManager::beginFrameTiming(); | |
| 818 | − } | |
| 814 | + getActiveDisplayPlugin()->preDisplay(); | |
| 819 | 815 | |
| 820 | 816 | PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); |
| 821 | 817 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 822 | 818 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| 823 | 819 | |
| 824 | − _offscreenContext->makeCurrent(); | |
| 825 | 820 | QSize fbSize = getActiveDisplayPlugin()->getRecommendedFramebufferSize() * getRenderResolutionScale(); |
| 826 | 821 | DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize); |
| 827 | 822 | |
| @@ -888,7 +883,8 @@ void Application::paintGL() { · 60 unmodified lines | ||
| 888 | 883 | glPopMatrix(); |
| 889 | 884 | |
| 890 | 885 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 891 | − _rearMirrorTools->render(true, _glWidget->mapFromGlobal(QCursor::pos())); | |
| 886 | + glm::vec2 mpos = getActiveDisplayPlugin()->getUiMousePosition(); | |
| 887 | + _rearMirrorTools->render(true, QPoint(mpos.x, mpos.y)); | |
| 892 | 888 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 893 | 889 | renderRearViewMirror(_mirrorViewRect); |
| 894 | 890 | } |
| @@ -1460,8 +1456,7 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 565 unmodified lines | ||
| 1460 | 1456 | _keyboardMouseDevice.mousePressEvent(event); |
| 1461 | 1457 | |
| 1462 | 1458 | if (event->button() == Qt::LeftButton) { |
| 1463 | − _mouseDragStartedX = getTrueMouseX(); | |
| 1464 | − _mouseDragStartedY = getTrueMouseY(); | |
| 1459 | + _mouseDragStarted = getTrueMousePosition(); | |
| 1465 | 1460 | _mousePressed = true; |
| 1466 | 1461 | |
| 1467 | 1462 | if (mouseOnScreen()) { |
| @@ -1563,22 +1558,18 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 95 unmodified lines | ||
| 1563 | 1558 | bool validTouch = false; |
| 1564 | 1559 | if (activeWindow() == _window) { |
| 1565 | 1560 | const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints(); |
| 1566 | − _touchAvgX = 0.0f; | |
| 1567 | − _touchAvgY = 0.0f; | |
| 1561 | + _touchAvg = glm::vec2(0); | |
| 1568 | 1562 | int numTouches = tPoints.count(); |
| 1569 | 1563 | if (numTouches > 1) { |
| 1570 | 1564 | for (int i = 0; i < numTouches; ++i) { |
| 1571 | − _touchAvgX += tPoints[i].pos().x(); | |
| 1572 | − _touchAvgY += tPoints[i].pos().y(); | |
| 1565 | + _touchAvg += toGlm(tPoints[i].pos()); | |
| 1573 | 1566 | } |
| 1574 | − _touchAvgX /= (float)(numTouches); | |
| 1575 | − _touchAvgY /= (float)(numTouches); | |
| 1567 | + _touchAvg /= numTouches; | |
| 1576 | 1568 | validTouch = true; |
| 1577 | 1569 | } |
| 1578 | 1570 | } |
| 1579 | 1571 | if (!_isTouchPressed) { |
| 1580 | − _touchDragStartedAvgX = _touchAvgX; | |
| 1581 | − _touchDragStartedAvgY = _touchAvgY; | |
| 1572 | + _touchDragStartedAvg = _touchAvg; | |
| 1582 | 1573 | } |
| 1583 | 1574 | _isTouchPressed = validTouch; |
| 1584 | 1575 | } |
| @@ -1614,8 +1605,7 @@ void Application::touchEndEvent(QTouchEvent* event) { · 29 unmodified lines | ||
| 1614 | 1605 | _keyboardMouseDevice.touchEndEvent(event); |
| 1615 | 1606 | |
| 1616 | 1607 | // put any application specific touch behavior below here.. |
| 1617 | − _touchDragStartedAvgX = _touchAvgX; | |
| 1618 | − _touchDragStartedAvgY = _touchAvgY; | |
| 1608 | + _touchDragStartedAvg = _touchAvg; | |
| 1619 | 1609 | _isTouchPressed = false; |
| 1620 | 1610 | |
| 1621 | 1611 | } |
| @@ -1736,13 +1726,11 @@ void Application::idle() { · 114 unmodified lines | ||
| 1736 | 1726 | const float BIGGEST_DELTA_TIME_SECS = 0.25f; |
| 1737 | 1727 | update(glm::clamp((float)timeSinceLastUpdate / 1000.0f, 0.0f, BIGGEST_DELTA_TIME_SECS)); |
| 1738 | 1728 | } |
| 1739 | − | |
| 1740 | 1729 | { |
| 1741 | 1730 | PerformanceTimer perfTimer("updateGL"); |
| 1742 | 1731 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); |
| 1743 | 1732 | getActiveDisplayPlugin()->idle(); |
| 1744 | 1733 | } |
| 1745 | − | |
| 1746 | 1734 | { |
| 1747 | 1735 | PerformanceTimer perfTimer("rest"); |
| 1748 | 1736 | PerformanceWarning warn(showWarnings, "Application::idle()... rest of it"); |
| @@ -1822,15 +1810,12 @@ void Application::setFullscreen(bool fullscreen) { · 73 unmodified lines | ||
| 1822 | 1810 | } |
| 1823 | 1811 | } |
| 1824 | 1812 | |
| 1825 | − | |
| 1826 | −void Application::setEnable3DTVMode(bool enable3DTVMode) { | |
| 1827 | 1813 | #if 0 |
| 1814 | +void Application::setEnable3DTVMode(bool enable3DTVMode) { | |
| 1828 | 1815 | resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); |
| 1829 | −#endif | |
| 1830 | 1816 | } |
| 1831 | 1817 | |
| 1832 | 1818 | void Application::setEnableVRMode(bool enableVRMode) { |
| 1833 | −#if 0 | |
| 1834 | 1819 | if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) != enableVRMode) { |
| 1835 | 1820 | Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(enableVRMode); |
| 1836 | 1821 | } |
| @@ -1855,8 +1840,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines | ||
| 1855 | 1840 | resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); |
| 1856 | 1841 | |
| 1857 | 1842 | updateCursorVisibility(); |
| 1858 | −#endif | |
| 1859 | 1843 | } |
| 1844 | +#endif | |
| 1860 | 1845 | |
| 1861 | 1846 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { |
| 1862 | 1847 | SixenseManager::getInstance().setLowVelocityFilter(lowVelocityFilter); |
| @@ -1875,16 +1860,15 @@ int Application::getMouseY() const { · 12 unmodified lines | ||
| 1875 | 1860 | } |
| 1876 | 1861 | |
| 1877 | 1862 | ivec2 Application::getMouseDragStarted() const { |
| 1878 | − return getActiveDisplaylugin()->trueMouseToUiMouse( | |
| 1879 | − glm::ivec2(getTrueMouseDragStartedX(), getTrueMouseDragStartedY())); | |
| 1863 | + return getActiveDisplayPlugin()->trueMouseToUiMouse(getTrueMouseDragStarted()); | |
| 1880 | 1864 | } |
| 1881 | 1865 | |
| 1882 | 1866 | int Application::getMouseDragStartedX() const { |
| 1883 | − return getMouseDragStarted().x; | |
| 1867 | + return getMouseDragStarted().x; | |
| 1884 | 1868 | } |
| 1885 | 1869 | |
| 1886 | 1870 | int Application::getMouseDragStartedY() const { |
| 1887 | − return getMouseDragStarted().y; | |
| 1871 | + return getMouseDragStarted().y; | |
| 1888 | 1872 | } |
| 1889 | 1873 | |
| 1890 | 1874 | FaceTracker* Application::getActiveFaceTracker() { |
| @@ -2221,9 +2205,8 @@ void Application::updateMyAvatarLookAtPosition() { · 330 unmodified lines | ||
| 2221 | 2205 | bool isLookingAtSomeone = false; |
| 2222 | 2206 | glm::vec3 lookAtSpot; |
| 2223 | 2207 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 2224 | −#if 0 | |
| 2225 | 2208 | // When I am in mirror mode, just look right at the camera (myself) |
| 2226 | − if (!OculusManager::isConnected()) { | |
| 2209 | + if (!isHMDMode()) { | |
| 2227 | 2210 | lookAtSpot = _myCamera.getPosition(); |
| 2228 | 2211 | } else { |
| 2229 | 2212 | if (_myAvatar->isLookingAtLeftEye()) { |
| @@ -2232,7 +2215,7 @@ void Application::updateMyAvatarLookAtPosition() { · 2 unmodified lines | ||
| 2232 | 2215 | lookAtSpot = OculusManager::getRightEyePosition(); |
| 2233 | 2216 | } |
| 2234 | 2217 | } |
| 2235 | −#endif | |
| 2218 | + | |
| 2236 | 2219 | } else { |
| 2237 | 2220 | AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef(); |
| 2238 | 2221 | if (lookingAt && _myAvatar != lookingAt.data()) { |
| @@ -3190,12 +3173,12 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 951 unmodified lines | ||
| 3190 | 3173 | _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha); |
| 3191 | 3174 | } |
| 3192 | 3175 | |
| 3193 | − // draw the sky dome | |
| 3194 | − if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 3195 | − PerformanceTimer perfTimer("atmosphere"); | |
| 3196 | − PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 3197 | − "Application::displaySide() ... atmosphere..."); | |
| 3198 | − _environment.renderAtmospheres(theCamera); | |
| 3176 | + // draw the sky dome | |
| 3177 | + if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 3178 | + PerformanceTimer perfTimer("atmosphere"); | |
| 3179 | + PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 3180 | + "Application::displaySide() ... atmosphere..."); | |
| 3181 | + _environment.renderAtmospheres(theCamera); | |
| 3199 | 3182 | } |
| 3200 | 3183 | |
| 3201 | 3184 | } |
| @@ -3444,7 +3427,8 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 242 unmodified lines | ||
| 3444 | 3427 | glPopMatrix(); |
| 3445 | 3428 | |
| 3446 | 3429 | if (!billboard) { |
| 3447 | − _rearMirrorTools->render(false, _glWidget->mapFromGlobal(QCursor::pos())); | |
| 3430 | + glm::vec2 mpos = getActiveDisplayPlugin()->getUiMousePosition(); | |
| 3431 | + _rearMirrorTools->render(false, QPoint(mpos.x, mpos.y)); | |
| 3448 | 3432 | } |
| 3449 | 3433 | |
| 3450 | 3434 | // reset Viewport and projection matrix |
| @@ -4320,6 +4304,7 @@ void Application::skipVersion(QString latestVersion) { · 869 unmodified lines | ||
| 4320 | 4304 | } |
| 4321 | 4305 | |
| 4322 | 4306 | void Application::takeSnapshot() { |
| 4307 | +#if 0 | |
| 4323 | 4308 | QMediaPlayer* player = new QMediaPlayer(); |
| 4324 | 4309 | QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); |
| 4325 | 4310 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| @@ -4336,6 +4321,8 @@ void Application::takeSnapshot() { · 10 unmodified lines | ||
| 4336 | 4321 | _snapshotShareDialog = new SnapshotShareDialog(fileName, desktop()); |
| 4337 | 4322 | } |
| 4338 | 4323 | _snapshotShareDialog->show(); |
| 4324 | +#endif | |
| 4325 | + | |
| 4339 | 4326 | } |
| 4340 | 4327 | |
| 4341 | 4328 | void Application::setVSyncEnabled() { |
| @@ -4524,7 +4511,7 @@ glm::uvec2 Application::getCanvasSize() const { · 182 unmodified lines | ||
| 4524 | 4511 | } |
| 4525 | 4512 | |
| 4526 | 4513 | QSize Application::getDeviceSize() const { |
| 4527 | − return getActiveDisplayPlugin()->getRecommendedFramebufferSize(); // _glWidget->getDeviceSize(); | |
| 4514 | + return getActiveDisplayPlugin()->getDeviceSize(); | |
| 4528 | 4515 | } |
| 4529 | 4516 | |
| 4530 | 4517 | void Application::resizeGL() { |
| @@ -4544,21 +4531,15 @@ glm::vec2 Application::getViewportDimensions() const { · 13 unmodified lines | ||
| 4544 | 4531 | glm::ivec2 Application::getTrueMousePosition() const { |
| 4545 | 4532 | return getActiveDisplayPlugin()->getTrueMousePosition(); |
| 4546 | 4533 | } |
| 4534 | + | |
| 4547 | 4535 | glm::quat Application::getHeadOrientation() const { |
| 4548 | 4536 | return getActiveDisplayPlugin()->headOrientation(); |
| 4549 | 4537 | } |
| 4538 | + | |
| 4550 | 4539 | glm::vec3 Application::getHeadPosition() const { |
| 4551 | 4540 | return getActiveDisplayPlugin()->headTranslation(); |
| 4552 | 4541 | } |
| 4553 | 4542 | |
| 4554 | −int Application::getTrueMouseX() const { | |
| 4555 | − return getActiveDisplayPlugin()->getTrueMousePosition().x; | |
| 4556 | −} | |
| 4557 | − | |
| 4558 | −int Application::getTrueMouseY() const { | |
| 4559 | − return getActiveDisplayPlugin()->getTrueMousePosition().y; | |
| 4560 | −} | |
| 4561 | − | |
| 4562 | 4543 | bool Application::isThrottleRendering() const { |
| 4563 | 4544 | return getActiveDisplayPlugin()->isThrottled(); |
| 4564 | 4545 | } |
| @@ -4659,43 +4640,3 @@ void Application::initPlugins() { · 94 unmodified lines | ||
| 4659 | 4640 | void Application::shutdownPlugins() { |
| 4660 | 4641 | OculusManager::deinit(); |
| 4661 | 4642 | } |
| 4662 | − | |
| 4663 | −glm::vec3 Application::getHeadPosition() const { | |
| 4664 | − return OculusManager::getRelativePosition(); | |
| 4665 | −} | |
| 4666 | − | |
| 4667 | −glm::quat Application::getHeadOrientation() const { | |
| 4668 | − return OculusManager::getOrientation(); | |
| 4669 | −} | |
| 4670 | − | |
| 4671 | −glm::uvec2 Application::getCanvasSize() const { | |
| 4672 | − return glm::uvec2(_glWidget->width(), _glWidget->height()); | |
| 4673 | −} | |
| 4674 | − | |
| 4675 | −QSize Application::getDeviceSize() const { | |
| 4676 | − return _glWidget->getDeviceSize(); | |
| 4677 | −} | |
| 4678 | − | |
| 4679 | −int Application::getTrueMouseX() const { | |
| 4680 | − return _glWidget->mapFromGlobal(QCursor::pos()).x(); | |
| 4681 | −} | |
| 4682 | − | |
| 4683 | −int Application::getTrueMouseY() const { | |
| 4684 | − return _glWidget->mapFromGlobal(QCursor::pos()).y(); | |
| 4685 | −} | |
| 4686 | − | |
| 4687 | −bool Application::isThrottleRendering() const { | |
| 4688 | − return _glWidget->isThrottleRendering(); | |
| 4689 | −} | |
| 4690 | − | |
| 4691 | −PickRay Application::computePickRay() const { | |
| 4692 | − return computePickRay(getTrueMouseX(), getTrueMouseY()); | |
| 4693 | −} | |
| 4694 | − | |
| 4695 | −bool Application::hasFocus() const { | |
| 4696 | − return _glWidget->hasFocus(); | |
| 4697 | −} | |
| 4698 | − | |
| 4699 | −void Application::resizeGL() { | |
| 4700 | − this->resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 4701 | −} | |