Showing the changes to interface/src/Application.cpp (1 of 214 files). Show all
Unified · Split
| @@ -66,6 +66,9 @@ · 65 unmodified lines | ||
| 66 | 66 | #include <EntityScriptingInterface.h> |
| 67 | 67 | #include <ErrorDialog.h> |
| 68 | 68 | #include <GlowEffect.h> |
| 69 | +#include <gpu/Batch.h> | |
| 70 | +#include <gpu/Context.h> | |
| 71 | +#include <gpu/GLBackend.h> | |
| 69 | 72 | #include <HFActionEvent.h> |
| 70 | 73 | #include <HFBackEvent.h> |
| 71 | 74 | #include <InfoView.h> |
| @@ -83,12 +86,14 @@ · 11 unmodified lines | ||
| 83 | 86 | #include <PerfStat.h> |
| 84 | 87 | #include <PhysicsEngine.h> |
| 85 | 88 | #include <ProgramObject.h> |
| 89 | +#include <RenderDeferredTask.h> | |
| 86 | 90 | #include <ResourceCache.h> |
| 87 | 91 | #include <SceneScriptingInterface.h> |
| 88 | 92 | #include <ScriptCache.h> |
| 89 | 93 | #include <SettingHandle.h> |
| 90 | 94 | #include <SoundCache.h> |
| 91 | 95 | #include <TextRenderer.h> |
| 96 | +#include <Tooltip.h> | |
| 92 | 97 | #include <UserActivityLogger.h> |
| 93 | 98 | #include <UUID.h> |
| 94 | 99 | #include <VrMenu.h> |
| @@ -106,11 +111,9 @@ · 11 unmodified lines | ||
| 106 | 111 | |
| 107 | 112 | #include "avatar/AvatarManager.h" |
| 108 | 113 | |
| 109 | −#include "audio/AudioToolBox.h" | |
| 110 | 114 | #include "audio/AudioIOStatsRenderer.h" |
| 111 | 115 | #include "audio/AudioScope.h" |
| 112 | 116 | |
| 113 | −#include "devices/CameraToolBox.h" | |
| 114 | 117 | #include "devices/DdeFaceTracker.h" |
| 115 | 118 | #include "devices/Faceshift.h" |
| 116 | 119 | #include "devices/Leapmotion.h" |
| @@ -120,12 +123,6 @@ · 3 unmodified lines | ||
| 120 | 123 | #include "devices/OculusManager.h" |
| 121 | 124 | #include "devices/TV3DManager.h" |
| 122 | 125 | |
| 123 | −#include "gpu/Batch.h" | |
| 124 | −#include "gpu/Context.h" | |
| 125 | −#include "gpu/GLBackend.h" | |
| 126 | − | |
| 127 | −#include "RenderDeferredTask.h" | |
| 128 | − | |
| 129 | 126 | #include "scripting/AccountScriptingInterface.h" |
| 130 | 127 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 131 | 128 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -141,6 +138,7 @@ · 9 unmodified lines | ||
| 141 | 138 | #include "SpeechRecognizer.h" |
| 142 | 139 | #endif |
| 143 | 140 | |
| 141 | +#include "ui/AvatarInputs.h" | |
| 144 | 142 | #include "ui/DataWebDialog.h" |
| 145 | 143 | #include "ui/DialogsManager.h" |
| 146 | 144 | #include "ui/LoginDialog.h" |
| @@ -281,8 +279,6 @@ bool setupEssentials(int& argc, char** argv) { · 134 unmodified lines | ||
| 281 | 279 | auto animationCache = DependencyManager::set<AnimationCache>(); |
| 282 | 280 | auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>(); |
| 283 | 281 | auto modelBlender = DependencyManager::set<ModelBlender>(); |
| 284 | − auto audioToolBox = DependencyManager::set<AudioToolBox>(); | |
| 285 | − auto cameraToolBox = DependencyManager::set<CameraToolBox>(); | |
| 286 | 282 | auto avatarManager = DependencyManager::set<AvatarManager>(); |
| 287 | 283 | auto lodManager = DependencyManager::set<LODManager>(); |
| 288 | 284 | auto jsConsole = DependencyManager::set<StandAloneJSConsole>(); |
| @@ -335,8 +331,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 46 unmodified lines | ||
| 335 | 331 | _cursorVisible(true), |
| 336 | 332 | _lastMouseMove(usecTimestampNow()), |
| 337 | 333 | _lastMouseMoveWasSimulated(false), |
| 338 | − _touchAvgX(0.0f), | |
| 339 | − _touchAvgY(0.0f), | |
| 340 | 334 | _isTouchPressed(false), |
| 341 | 335 | _mousePressed(false), |
| 342 | 336 | _enableProcessOctreeThread(true), |
| @@ -814,9 +808,9 @@ void Application::initializeGL() { · 471 unmodified lines | ||
| 814 | 808 | _idleLoopStdev.reset(); |
| 815 | 809 | |
| 816 | 810 | if (_justStarted) { |
| 817 | − float startupTime = (float)_applicationStartupTime.elapsed() / 1000.0; | |
| 811 | + float startupTime = (float)_applicationStartupTime.elapsed() / 1000.0f; | |
| 818 | 812 | _justStarted = false; |
| 819 | − qCDebug(interfaceapp, "Startup time: %4.2f seconds.", startupTime); | |
| 813 | + qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTime); | |
| 820 | 814 | } |
| 821 | 815 | |
| 822 | 816 | // update before the first render |
| @@ -831,6 +825,7 @@ void Application::initializeUi() { · 8 unmodified lines | ||
| 831 | 825 | LoginDialog::registerType(); |
| 832 | 826 | MessageDialog::registerType(); |
| 833 | 827 | VrMenu::registerType(); |
| 828 | + Tooltip::registerType(); | |
| 834 | 829 | UpdateDialog::registerType(); |
| 835 | 830 | |
| 836 | 831 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| @@ -844,7 +839,7 @@ void Application::initializeUi() { · 7 unmodified lines | ||
| 844 | 839 | VrMenu::executeQueuedLambdas(); |
| 845 | 840 | offscreenUi->setMouseTranslator([this](const QPointF& p){ |
| 846 | 841 | if (OculusManager::isConnected()) { |
| 847 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p)); | |
| 842 | + glm::vec2 pos = _compositor.screenToOverlay(toGlm(p)); | |
| 848 | 843 | return QPointF(pos.x, pos.y); |
| 849 | 844 | } |
| 850 | 845 | return QPointF(p); |
| @@ -877,6 +872,7 @@ void Application::paintGL() { · 26 unmodified lines | ||
| 877 | 872 | OculusManager::beginFrameTiming(); |
| 878 | 873 | } |
| 879 | 874 | |
| 875 | + | |
| 880 | 876 | PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); |
| 881 | 877 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 882 | 878 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| @@ -884,6 +880,12 @@ void Application::paintGL() { · 1 unmodified line | ||
| 884 | 880 | |
| 885 | 881 | { |
| 886 | 882 | PerformanceTimer perfTimer("renderOverlay"); |
| 883 | + /* | |
| 884 | + gpu::Context context(new gpu::GLBackend()); | |
| 885 | + RenderArgs renderArgs(&context, nullptr, getViewFrustum(), lodManager->getOctreeSizeScale(), | |
| 886 | + lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE, | |
| 887 | + RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); | |
| 888 | + */ | |
| 887 | 889 | _applicationOverlay.renderOverlay(&renderArgs); |
| 888 | 890 | } |
| 889 | 891 | |
| @@ -912,13 +914,18 @@ void Application::paintGL() { · 22 unmodified lines | ||
| 912 | 914 | } |
| 913 | 915 | |
| 914 | 916 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 915 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 916 | − _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 917 | 917 | if (OculusManager::isConnected()) { |
| 918 | 918 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); |
| 919 | 919 | } else { |
| 920 | 920 | _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); |
| 921 | 921 | } |
| 922 | + if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 923 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 924 | + _myCamera.getRotation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 925 | + } else { | |
| 926 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 927 | + _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 928 | + } | |
| 922 | 929 | |
| 923 | 930 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 924 | 931 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| @@ -967,9 +974,7 @@ void Application::paintGL() { · 42 unmodified lines | ||
| 967 | 974 | glPopMatrix(); |
| 968 | 975 | |
| 969 | 976 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; |
| 970 | − if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 971 | − _rearMirrorTools->render(&renderArgs, true, _glWidget->mapFromGlobal(QCursor::pos())); | |
| 972 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 977 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 973 | 978 | renderRearViewMirror(&renderArgs, _mirrorViewRect); |
| 974 | 979 | } |
| 975 | 980 | |
| @@ -977,6 +982,7 @@ void Application::paintGL() { · 1 unmodified line | ||
| 977 | 982 | |
| 978 | 983 | auto finalFbo = DependencyManager::get<GlowEffect>()->render(&renderArgs); |
| 979 | 984 | |
| 985 | + | |
| 980 | 986 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); |
| 981 | 987 | glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); |
| 982 | 988 | glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y, |
| @@ -984,9 +990,10 @@ void Application::paintGL() { · 1 unmodified line | ||
| 984 | 990 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 985 | 991 | glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); |
| 986 | 992 | |
| 987 | − _applicationOverlay.displayOverlayTexture(); | |
| 993 | + _compositor.displayOverlayTexture(&renderArgs); | |
| 988 | 994 | } |
| 989 | 995 | |
| 996 | + | |
| 990 | 997 | if (!OculusManager::isConnected() || OculusManager::allowSwap()) { |
| 991 | 998 | _glWidget->swapBuffers(); |
| 992 | 999 | } |
| @@ -1044,27 +1051,24 @@ void Application::resizeGL() { · 51 unmodified lines | ||
| 1044 | 1051 | } else { |
| 1045 | 1052 | renderSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); |
| 1046 | 1053 | } |
| 1047 | − if (_renderResolution == toGlm(renderSize)) { | |
| 1048 | − return; | |
| 1049 | − } | |
| 1050 | 1054 | |
| 1051 | − _renderResolution = toGlm(renderSize); | |
| 1052 | − DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize); | |
| 1053 | − resetCamerasOnResizeGL(_myCamera, _renderResolution); | |
| 1055 | + if (_renderResolution != toGlm(renderSize)) { | |
| 1056 | + _renderResolution = toGlm(renderSize); | |
| 1057 | + DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize); | |
| 1058 | + resetCamerasOnResizeGL(_myCamera, _renderResolution); | |
| 1054 | 1059 | |
| 1055 | − glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu??? | |
| 1060 | + glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu??? | |
| 1056 | 1061 | |
| 1057 | − updateProjectionMatrix(); | |
| 1058 | − glLoadIdentity(); | |
| 1062 | + updateProjectionMatrix(); | |
| 1063 | + glLoadIdentity(); | |
| 1064 | + } | |
| 1059 | 1065 | |
| 1060 | 1066 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 1061 | − offscreenUi->resize(_glWidget->size()); | |
| 1067 | + | |
| 1068 | + auto canvasSize = _glWidget->size(); | |
| 1069 | + offscreenUi->resize(canvasSize); | |
| 1062 | 1070 | _glWidget->makeCurrent(); |
| 1063 | 1071 | |
| 1064 | − // update Stats width | |
| 1065 | − // let's set horizontal offset to give stats some margin to mirror | |
| 1066 | − int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 1067 | − Stats::getInstance()->resetWidth(_renderResolution.x, horizontalOffset); | |
| 1068 | 1072 | } |
| 1069 | 1073 | |
| 1070 | 1074 | void Application::updateProjectionMatrix() { |
| @@ -1568,27 +1572,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 497 unmodified lines | ||
| 1568 | 1572 | _keyboardMouseDevice.mousePressEvent(event); |
| 1569 | 1573 | |
| 1570 | 1574 | if (event->button() == Qt::LeftButton) { |
| 1571 | − _mouseDragStartedX = getTrueMouseX(); | |
| 1572 | − _mouseDragStartedY = getTrueMouseY(); | |
| 1575 | + _mouseDragStarted = getTrueMouse(); | |
| 1573 | 1576 | _mousePressed = true; |
| 1574 | 1577 | |
| 1575 | − if (mouseOnScreen()) { | |
| 1576 | − if (DependencyManager::get<AudioToolBox>()->mousePressEvent(getMouseX(), getMouseY())) { | |
| 1577 | − // stop propagation | |
| 1578 | − return; | |
| 1579 | − } | |
| 1580 | − | |
| 1581 | − if (DependencyManager::get<CameraToolBox>()->mousePressEvent(getMouseX(), getMouseY())) { | |
| 1582 | − // stop propagation | |
| 1583 | − return; | |
| 1584 | − } | |
| 1585 | − | |
| 1586 | − if (_rearMirrorTools->mousePressEvent(getMouseX(), getMouseY())) { | |
| 1587 | − // stop propagation | |
| 1588 | − return; | |
| 1589 | − } | |
| 1590 | − } | |
| 1591 | − | |
| 1592 | 1578 | // nobody handled this - make it an action event on the _window object |
| 1593 | 1579 | HFActionEvent actionEvent(HFActionEvent::startType(), |
| 1594 | 1580 | computePickRay(event->x(), event->y())); |
| @@ -1606,16 +1592,7 @@ void Application::mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceI · 11 unmodified lines | ||
| 1606 | 1592 | return; |
| 1607 | 1593 | } |
| 1608 | 1594 | |
| 1609 | − if (activeWindow() == _window) { | |
| 1610 | − if (event->button() == Qt::LeftButton) { | |
| 1611 | − if (mouseOnScreen()) { | |
| 1612 | − if (DependencyManager::get<CameraToolBox>()->mouseDoublePressEvent(getMouseX(), getMouseY())) { | |
| 1613 | − // stop propagation | |
| 1614 | − return; | |
| 1615 | − } | |
| 1616 | − } | |
| 1617 | − } | |
| 1618 | − } | |
| 1595 | + _controllerScriptingInterface.emitMouseDoublePressEvent(event); | |
| 1619 | 1596 | } |
| 1620 | 1597 | |
| 1621 | 1598 | void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { |
| @@ -1637,13 +1614,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 15 unmodified lines | ||
| 1637 | 1614 | if (event->button() == Qt::LeftButton) { |
| 1638 | 1615 | _mousePressed = false; |
| 1639 | 1616 | |
| 1640 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && mouseOnScreen()) { | |
| 1641 | − // let's set horizontal offset to give stats some margin to mirror | |
| 1642 | − int horizontalOffset = MIRROR_VIEW_WIDTH; | |
| 1643 | − Stats::getInstance()->checkClick(getMouseX(), getMouseY(), | |
| 1644 | − getMouseDragStartedX(), getMouseDragStartedY(), horizontalOffset); | |
| 1645 | − } | |
| 1646 | − | |
| 1647 | 1617 | // fire an action end event |
| 1648 | 1618 | HFActionEvent actionEvent(HFActionEvent::endType(), |
| 1649 | 1619 | computePickRay(event->x(), event->y())); |
| @@ -1671,22 +1641,18 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 21 unmodified lines | ||
| 1671 | 1641 | bool validTouch = false; |
| 1672 | 1642 | if (activeWindow() == _window) { |
| 1673 | 1643 | const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints(); |
| 1674 | − _touchAvgX = 0.0f; | |
| 1675 | − _touchAvgY = 0.0f; | |
| 1644 | + _touchAvg = vec2(); | |
| 1676 | 1645 | int numTouches = tPoints.count(); |
| 1677 | 1646 | if (numTouches > 1) { |
| 1678 | 1647 | for (int i = 0; i < numTouches; ++i) { |
| 1679 | − _touchAvgX += tPoints[i].pos().x(); | |
| 1680 | − _touchAvgY += tPoints[i].pos().y(); | |
| 1648 | + _touchAvg += toGlm(tPoints[i].pos()); | |
| 1681 | 1649 | } |
| 1682 | − _touchAvgX /= (float)(numTouches); | |
| 1683 | − _touchAvgY /= (float)(numTouches); | |
| 1650 | + _touchAvg /= (float)(numTouches); | |
| 1684 | 1651 | validTouch = true; |
| 1685 | 1652 | } |
| 1686 | 1653 | } |
| 1687 | 1654 | if (!_isTouchPressed) { |
| 1688 | − _touchDragStartedAvgX = _touchAvgX; | |
| 1689 | − _touchDragStartedAvgY = _touchAvgY; | |
| 1655 | + _touchDragStartedAvg = _touchAvg; | |
| 1690 | 1656 | } |
| 1691 | 1657 | _isTouchPressed = validTouch; |
| 1692 | 1658 | } |
| @@ -1722,8 +1688,7 @@ void Application::touchEndEvent(QTouchEvent* event) { · 29 unmodified lines | ||
| 1722 | 1688 | _keyboardMouseDevice.touchEndEvent(event); |
| 1723 | 1689 | |
| 1724 | 1690 | // put any application specific touch behavior below here.. |
| 1725 | − _touchDragStartedAvgX = _touchAvgX; | |
| 1726 | − _touchDragStartedAvgY = _touchAvgY; | |
| 1691 | + _touchDragStartedAvg = _touchAvg; | |
| 1727 | 1692 | _isTouchPressed = false; |
| 1728 | 1693 | |
| 1729 | 1694 | } |
| @@ -1872,9 +1837,9 @@ void Application::setFullscreen(bool fullscreen) { · 142 unmodified lines | ||
| 1872 | 1837 | Menu::getInstance()->getActionForOption(MenuOption::Fullscreen)->setChecked(fullscreen); |
| 1873 | 1838 | } |
| 1874 | 1839 | |
| 1875 | −// The following code block is useful on platforms that can have a visible | |
| 1876 | −// app menu in a fullscreen window. However the OSX mechanism hides the | |
| 1877 | −// application menu for fullscreen apps, so the check is not required. | |
| 1840 | + // The following code block is useful on platforms that can have a visible | |
| 1841 | + // app menu in a fullscreen window. However the OSX mechanism hides the | |
| 1842 | + // application menu for fullscreen apps, so the check is not required. | |
| 1878 | 1843 | #ifndef Q_OS_MAC |
| 1879 | 1844 | if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { |
| 1880 | 1845 | if (fullscreen) { |
| @@ -1939,16 +1904,15 @@ void Application::setEnableVRMode(bool enableVRMode) { · 58 unmodified lines | ||
| 1939 | 1904 | // attempt to reconnect the Oculus manager - it's possible this was a workaround |
| 1940 | 1905 | // for the sixense crash |
| 1941 | 1906 | OculusManager::disconnect(); |
| 1942 | − OculusManager::connect(); | |
| 1907 | + OculusManager::connect(_glWidget->context()->contextHandle()); | |
| 1908 | + _glWidget->setFocus(); | |
| 1909 | + _glWidget->makeCurrent(); | |
| 1910 | + glClear(GL_COLOR_BUFFER_BIT); | |
| 1943 | 1911 | } |
| 1944 | 1912 | OculusManager::recalibrate(); |
| 1945 | 1913 | } else { |
| 1946 | 1914 | OculusManager::abandonCalibration(); |
| 1947 | − | |
| 1948 | − _mirrorCamera.setHmdPosition(glm::vec3()); | |
| 1949 | − _mirrorCamera.setHmdRotation(glm::quat()); | |
| 1950 | − _myCamera.setHmdPosition(glm::vec3()); | |
| 1951 | − _myCamera.setHmdRotation(glm::quat()); | |
| 1915 | + OculusManager::disconnect(); | |
| 1952 | 1916 | } |
| 1953 | 1917 | |
| 1954 | 1918 | resizeGL(); |
| @@ -1960,44 +1924,34 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { · 5 unmodified lines | ||
| 1960 | 1924 | |
| 1961 | 1925 | bool Application::mouseOnScreen() const { |
| 1962 | 1926 | if (OculusManager::isConnected()) { |
| 1963 | − return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() && | |
| 1964 | − getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight(); | |
| 1927 | + ivec2 mouse = getMouse(); | |
| 1928 | + if (!glm::all(glm::greaterThanEqual(mouse, ivec2()))) { | |
| 1929 | + return false; | |
| 1930 | + } | |
| 1931 | + ivec2 size = toGlm(_glWidget->getDeviceSize()); | |
| 1932 | + if (!glm::all(glm::lessThanEqual(mouse, size))) { | |
| 1933 | + return false; | |
| 1934 | + } | |
| 1965 | 1935 | } |
| 1966 | 1936 | return true; |
| 1967 | 1937 | } |
| 1968 | 1938 | |
| 1969 | −int Application::getMouseX() const { | |
| 1970 | − if (OculusManager::isConnected()) { | |
| 1971 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY())); | |
| 1972 | − return pos.x; | |
| 1973 | − } | |
| 1974 | − return getTrueMouseX(); | |
| 1975 | −} | |
| 1976 | − | |
| 1977 | −int Application::getMouseY() const { | |
| 1939 | +ivec2 Application::getMouse() const { | |
| 1978 | 1940 | if (OculusManager::isConnected()) { |
| 1979 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY())); | |
| 1980 | − return pos.y; | |
| 1941 | + return _compositor.screenToOverlay(getTrueMouse()); | |
| 1981 | 1942 | } |
| 1982 | − return getTrueMouseY(); | |
| 1943 | + return getTrueMouse(); | |
| 1983 | 1944 | } |
| 1984 | 1945 | |
| 1985 | −int Application::getMouseDragStartedX() const { | |
| 1946 | +ivec2 Application::getMouseDragStarted() const { | |
| 1986 | 1947 | if (OculusManager::isConnected()) { |
| 1987 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(), | |
| 1988 | − getTrueMouseDragStartedY())); | |
| 1989 | − return pos.x; | |
| 1948 | + return _compositor.screenToOverlay(getTrueMouseDragStarted()); | |
| 1990 | 1949 | } |
| 1991 | − return getTrueMouseDragStartedX(); | |
| 1950 | + return getTrueMouseDragStarted(); | |
| 1992 | 1951 | } |
| 1993 | 1952 | |
| 1994 | −int Application::getMouseDragStartedY() const { | |
| 1995 | − if (OculusManager::isConnected()) { | |
| 1996 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(), | |
| 1997 | − getTrueMouseDragStartedY())); | |
| 1998 | − return pos.y; | |
| 1999 | − } | |
| 2000 | − return getTrueMouseDragStartedY(); | |
| 1953 | +ivec2 Application::getTrueMouseDragStarted() const { | |
| 1954 | + return _mouseDragStarted; | |
| 2001 | 1955 | } |
| 2002 | 1956 | |
| 2003 | 1957 | FaceTracker* Application::getActiveFaceTracker() { |
| @@ -2179,13 +2133,6 @@ void Application::init() { · 175 unmodified lines | ||
| 2179 | 2133 | |
| 2180 | 2134 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| 2181 | 2135 | |
| 2182 | − OculusManager::connect(); | |
| 2183 | − if (OculusManager::isConnected()) { | |
| 2184 | − QMetaObject::invokeMethod(Menu::getInstance()->getActionForOption(MenuOption::Fullscreen), | |
| 2185 | − "trigger", | |
| 2186 | − Qt::QueuedConnection); | |
| 2187 | − } | |
| 2188 | − | |
| 2189 | 2136 | TV3DManager::connect(); |
| 2190 | 2137 | if (TV3DManager::isConnected()) { |
| 2191 | 2138 | QMetaObject::invokeMethod(Menu::getInstance()->getActionForOption(MenuOption::Fullscreen), |
| @@ -2249,13 +2196,6 @@ void Application::init() { · 57 unmodified lines | ||
| 2249 | 2196 | _entityClipboardRenderer.setViewFrustum(getViewFrustum()); |
| 2250 | 2197 | _entityClipboardRenderer.setTree(&_entityClipboard); |
| 2251 | 2198 | |
| 2252 | − _rearMirrorTools = new RearMirrorTools(_mirrorViewRect); | |
| 2253 | − | |
| 2254 | − connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); | |
| 2255 | − connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); | |
| 2256 | − connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); | |
| 2257 | − connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); | |
| 2258 | − | |
| 2259 | 2199 | // initialize the GlowEffect with our widget |
| 2260 | 2200 | bool glow = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect); |
| 2261 | 2201 | DependencyManager::get<GlowEffect>()->init(glow); |
| @@ -2434,6 +2374,12 @@ void Application::cameraMenuChanged() { · 172 unmodified lines | ||
| 2434 | 2374 | } |
| 2435 | 2375 | } |
| 2436 | 2376 | |
| 2377 | +void Application::rotationModeChanged() { | |
| 2378 | + if (!Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 2379 | + _myAvatar->setHeadPitch(0); | |
| 2380 | + } | |
| 2381 | +} | |
| 2382 | + | |
| 2437 | 2383 | void Application::updateCamera(float deltaTime) { |
| 2438 | 2384 | PerformanceTimer perfTimer("updateCamera"); |
| 2439 | 2385 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| @@ -3155,7 +3101,7 @@ PickRay Application::computePickRay(float x, float y) const { · 715 unmodified lines | ||
| 3155 | 3101 | y /= size.y; |
| 3156 | 3102 | PickRay result; |
| 3157 | 3103 | if (isHMDMode()) { |
| 3158 | − getApplicationOverlay().computeHmdPickRay(glm::vec2(x, y), result.origin, result.direction); | |
| 3104 | + getApplicationCompositor().computeHmdPickRay(glm::vec2(x, y), result.origin, result.direction); | |
| 3159 | 3105 | } else { |
| 3160 | 3106 | if (QThread::currentThread() == activeRenderingThread) { |
| 3161 | 3107 | getDisplayViewFrustum()->computePickRay(x, y, result.origin, result.direction); |
| @@ -3184,13 +3130,11 @@ QImage Application::renderAvatarBillboard(RenderArgs* renderArgs) { · 22 unmodified lines | ||
| 3184 | 3130 | renderRearViewMirror(renderArgs, QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, |
| 3185 | 3131 | BILLBOARD_SIZE, BILLBOARD_SIZE), |
| 3186 | 3132 | true); |
| 3187 | − | |
| 3188 | 3133 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 3189 | 3134 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); |
| 3190 | 3135 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 3191 | 3136 | |
| 3192 | 3137 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 3193 | − | |
| 3194 | 3138 | return image; |
| 3195 | 3139 | } |
| 3196 | 3140 | |
| @@ -3386,9 +3330,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 189 unmodified lines | ||
| 3386 | 3330 | |
| 3387 | 3331 | // flip x if in mirror mode (also requires reversing winding order for backface culling) |
| 3388 | 3332 | if (theCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 3389 | − glScalef(-1.0f, 1.0f, 1.0f); | |
| 3390 | − glFrontFace(GL_CW); | |
| 3391 | − | |
| 3333 | + //glScalef(-1.0f, 1.0f, 1.0f); | |
| 3334 | + //glFrontFace(GL_CW); | |
| 3392 | 3335 | } else { |
| 3393 | 3336 | glFrontFace(GL_CCW); |
| 3394 | 3337 | } |
| @@ -3411,7 +3354,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 16 unmodified lines | ||
| 3411 | 3354 | viewTransform.setTranslation(theCamera.getPosition()); |
| 3412 | 3355 | viewTransform.setRotation(rotation); |
| 3413 | 3356 | if (theCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 3414 | − viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f)); | |
| 3357 | +// viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f)); | |
| 3415 | 3358 | } |
| 3416 | 3359 | if (renderArgs->_renderSide != RenderArgs::MONO) { |
| 3417 | 3360 | glm::mat4 invView = glm::inverse(_untranslatedViewMatrix); |
| @@ -3548,6 +3491,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 130 unmodified lines | ||
| 3548 | 3491 | |
| 3549 | 3492 | renderContext._maxDrawnOpaqueItems = sceneInterface->getEngineMaxDrawnOpaqueItems(); |
| 3550 | 3493 | renderContext._maxDrawnTransparentItems = sceneInterface->getEngineMaxDrawnTransparentItems(); |
| 3494 | + renderContext._maxDrawnOverlay3DItems = sceneInterface->getEngineMaxDrawnOverlay3DItems(); | |
| 3551 | 3495 | |
| 3552 | 3496 | renderArgs->_shouldRender = LODManager::shouldRender; |
| 3553 | 3497 | |
| @@ -3564,7 +3508,9 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 10 unmodified lines | ||
| 3564 | 3508 | |
| 3565 | 3509 | sceneInterface->setEngineFeedTransparentItems(engineRC->_numFeedTransparentItems); |
| 3566 | 3510 | sceneInterface->setEngineDrawnTransparentItems(engineRC->_numDrawnTransparentItems); |
| 3567 | − | |
| 3511 | + | |
| 3512 | + sceneInterface->setEngineFeedOverlay3DItems(engineRC->_numFeedOverlay3DItems); | |
| 3513 | + sceneInterface->setEngineDrawnOverlay3DItems(engineRC->_numDrawnOverlay3DItems); | |
| 3568 | 3514 | } |
| 3569 | 3515 | //Render the sixense lasers |
| 3570 | 3516 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) { |
| @@ -3672,8 +3618,8 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 101 unmodified lines | ||
| 3672 | 3618 | // +-----------------------+ |
| 3673 | 3619 | // -1,-1 1,-1 |
| 3674 | 3620 | |
| 3675 | − glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale, | |
| 3676 | − ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight()); | |
| 3621 | + glm::vec2 screenPoint((projectedPoint.x + 1.0f) * horizontalScale, | |
| 3622 | + ((projectedPoint.y + 1.0f) * -verticalScale) + _glWidget->getDeviceHeight()); | |
| 3677 | 3623 | |
| 3678 | 3624 | return screenPoint; |
| 3679 | 3625 | } |
| @@ -3691,7 +3637,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 11 unmodified lines | ||
| 3691 | 3637 | _mirrorCamera.setPosition(_myAvatar->getPosition() + |
| 3692 | 3638 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 3693 | 3639 | |
| 3694 | − } else if (RearMirrorTools::rearViewZoomLevel.get() == BODY) { | |
| 3640 | + } else if (!AvatarInputs::getInstance()->mirrorZoomed()) { | |
| 3695 | 3641 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + |
| 3696 | 3642 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| 3697 | 3643 | |
| @@ -3726,7 +3672,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 28 unmodified lines | ||
| 3726 | 3672 | } else { |
| 3727 | 3673 | // if not rendering the billboard, the region is in device independent coordinates; must convert to device |
| 3728 | 3674 | QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize(); |
| 3729 | − float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale(); | |
| 3675 | + float ratio = (float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale(); | |
| 3730 | 3676 | int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio; |
| 3731 | 3677 | glViewport(x, size.height() - y - height, width, height); |
| 3732 | 3678 | glScissor(x, size.height() - y - height, width, height); |
| @@ -3741,10 +3687,6 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 8 unmodified lines | ||
| 3741 | 3687 | displaySide(renderArgs, _mirrorCamera, true, billboard); |
| 3742 | 3688 | glPopMatrix(); |
| 3743 | 3689 | |
| 3744 | − if (!billboard) { | |
| 3745 | − _rearMirrorTools->render(renderArgs, false, _glWidget->mapFromGlobal(QCursor::pos())); | |
| 3746 | − } | |
| 3747 | − | |
| 3748 | 3690 | // reset Viewport and projection matrix |
| 3749 | 3691 | glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); |
| 3750 | 3692 | glDisable(GL_SCISSOR_TEST); |
| @@ -3884,7 +3826,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 133 unmodified lines | ||
| 3884 | 3826 | _entityServerJurisdictions.unlock(); |
| 3885 | 3827 | |
| 3886 | 3828 | qCDebug(interfaceapp, "model server going away...... v[%f, %f, %f, %f]", |
| 3887 | − rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); | |
| 3829 | + (double)rootDetails.x, (double)rootDetails.y, (double)rootDetails.z, (double)rootDetails.s); | |
| 3888 | 3830 | |
| 3889 | 3831 | // Add the jurisditionDetails object to the list of "fade outs" |
| 3890 | 3832 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) { |
| @@ -3970,7 +3912,8 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin · 79 unmodified lines | ||
| 3970 | 3912 | jurisdiction->unlock(); |
| 3971 | 3913 | |
| 3972 | 3914 | qCDebug(interfaceapp, "stats from new %s server... [%f, %f, %f, %f]", |
| 3973 | − qPrintable(serverType), rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); | |
| 3915 | + qPrintable(serverType), | |
| 3916 | + (double)rootDetails.x, (double)rootDetails.y, (double)rootDetails.z, (double)rootDetails.s); | |
| 3974 | 3917 | |
| 3975 | 3918 | // Add the jurisditionDetails object to the list of "fade outs" |
| 3976 | 3919 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) { |
| @@ -4750,11 +4693,9 @@ void Application::postLambdaEvent(std::function<void()> f) { · 773 unmodified lines | ||
| 4750 | 4693 | } |
| 4751 | 4694 | |
| 4752 | 4695 | void Application::initPlugins() { |
| 4753 | − OculusManager::init(); | |
| 4754 | 4696 | } |
| 4755 | 4697 | |
| 4756 | 4698 | void Application::shutdownPlugins() { |
| 4757 | − OculusManager::deinit(); | |
| 4758 | 4699 | } |
| 4759 | 4700 | |
| 4760 | 4701 | glm::vec3 Application::getHeadPosition() const { |
| @@ -4774,12 +4715,8 @@ QSize Application::getDeviceSize() const { · 13 unmodified lines | ||
| 4774 | 4715 | return _glWidget->getDeviceSize(); |
| 4775 | 4716 | } |
| 4776 | 4717 | |
| 4777 | −int Application::getTrueMouseX() const { | |
| 4778 | − return _glWidget->mapFromGlobal(QCursor::pos()).x(); | |
| 4779 | −} | |
| 4780 | − | |
| 4781 | −int Application::getTrueMouseY() const { | |
| 4782 | − return _glWidget->mapFromGlobal(QCursor::pos()).y(); | |
| 4718 | +ivec2 Application::getTrueMouse() const { | |
| 4719 | + return toGlm(_glWidget->mapFromGlobal(QCursor::pos())); | |
| 4783 | 4720 | } |
| 4784 | 4721 | |
| 4785 | 4722 | bool Application::isThrottleRendering() const { |
| @@ -4809,3 +4746,25 @@ qreal Application::getDevicePixelRatio() { · 23 unmodified lines | ||
| 4809 | 4746 | return _window ? _window->windowHandle()->devicePixelRatio() : 1.0; |
| 4810 | 4747 | } |
| 4811 | 4748 | |
| 4749 | +mat4 Application::getEyeProjection(int eye) const { | |
| 4750 | + if (isHMDMode()) { | |
| 4751 | + return OculusManager::getEyeProjection(eye); | |
| 4752 | + } | |
| 4753 | + | |
| 4754 | + return _viewFrustum.getProjection(); | |
| 4755 | +} | |
| 4756 | + | |
| 4757 | +mat4 Application::getEyePose(int eye) const { | |
| 4758 | + if (isHMDMode()) { | |
| 4759 | + return OculusManager::getEyePose(eye); | |
| 4760 | + } | |
| 4761 | + | |
| 4762 | + return mat4(); | |
| 4763 | +} | |
| 4764 | + | |
| 4765 | +mat4 Application::getHeadPose() const { | |
| 4766 | + if (isHMDMode()) { | |
| 4767 | + return OculusManager::getHeadPose(); | |
| 4768 | + } | |
| 4769 | + return mat4(); | |
| 4770 | +} | |