Showing the changes to interface/src/Application.cpp (1 of 275 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), |
| @@ -610,6 +604,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 267 unmodified lines | ||
| 610 | 604 | _settingsTimer.setSingleShot(false); |
| 611 | 605 | _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL); |
| 612 | 606 | _settingsThread.start(); |
| 607 | + | |
| 608 | + if (Menu::getInstance()->isOptionChecked(MenuOption::IndependentMode)) { | |
| 609 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, true); | |
| 610 | + cameraMenuChanged(); | |
| 611 | + } | |
| 613 | 612 | |
| 614 | 613 | _trayIcon->show(); |
| 615 | 614 | |
| @@ -814,9 +813,9 @@ void Application::initializeGL() { · 198 unmodified lines | ||
| 814 | 813 | _idleLoopStdev.reset(); |
| 815 | 814 | |
| 816 | 815 | if (_justStarted) { |
| 817 | − float startupTime = (float)_applicationStartupTime.elapsed() / 1000.0; | |
| 816 | + float startupTime = (float)_applicationStartupTime.elapsed() / 1000.0f; | |
| 818 | 817 | _justStarted = false; |
| 819 | − qCDebug(interfaceapp, "Startup time: %4.2f seconds.", startupTime); | |
| 818 | + qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTime); | |
| 820 | 819 | } |
| 821 | 820 | |
| 822 | 821 | // update before the first render |
| @@ -831,6 +830,7 @@ void Application::initializeUi() { · 8 unmodified lines | ||
| 831 | 830 | LoginDialog::registerType(); |
| 832 | 831 | MessageDialog::registerType(); |
| 833 | 832 | VrMenu::registerType(); |
| 833 | + Tooltip::registerType(); | |
| 834 | 834 | UpdateDialog::registerType(); |
| 835 | 835 | |
| 836 | 836 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| @@ -844,7 +844,7 @@ void Application::initializeUi() { · 7 unmodified lines | ||
| 844 | 844 | VrMenu::executeQueuedLambdas(); |
| 845 | 845 | offscreenUi->setMouseTranslator([this](const QPointF& p){ |
| 846 | 846 | if (OculusManager::isConnected()) { |
| 847 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p)); | |
| 847 | + glm::vec2 pos = _compositor.screenToOverlay(toGlm(p)); | |
| 848 | 848 | return QPointF(pos.x, pos.y); |
| 849 | 849 | } |
| 850 | 850 | return QPointF(p); |
| @@ -877,6 +877,7 @@ void Application::paintGL() { · 26 unmodified lines | ||
| 877 | 877 | OculusManager::beginFrameTiming(); |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | + | |
| 880 | 881 | PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); |
| 881 | 882 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 882 | 883 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| @@ -884,13 +885,22 @@ void Application::paintGL() { · 1 unmodified line | ||
| 884 | 885 | |
| 885 | 886 | { |
| 886 | 887 | PerformanceTimer perfTimer("renderOverlay"); |
| 888 | + /* | |
| 889 | + gpu::Context context(new gpu::GLBackend()); | |
| 890 | + RenderArgs renderArgs(&context, nullptr, getViewFrustum(), lodManager->getOctreeSizeScale(), | |
| 891 | + lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE, | |
| 892 | + RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); | |
| 893 | + */ | |
| 887 | 894 | _applicationOverlay.renderOverlay(&renderArgs); |
| 888 | 895 | } |
| 889 | 896 | |
| 890 | 897 | glEnable(GL_LINE_SMOOTH); |
| 891 | 898 | |
| 892 | − Menu::getInstance()->setIsOptionChecked("First Person", _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); | |
| 893 | − Application::getInstance()->cameraMenuChanged(); | |
| 899 | + if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | |
| 900 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); | |
| 901 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); | |
| 902 | + Application::getInstance()->cameraMenuChanged(); | |
| 903 | + } | |
| 894 | 904 | |
| 895 | 905 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 896 | 906 | // Always use the default eye position, not the actual head eye position. |
| @@ -909,13 +919,18 @@ void Application::paintGL() { · 12 unmodified lines | ||
| 909 | 919 | } |
| 910 | 920 | |
| 911 | 921 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 912 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 913 | − _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 914 | 922 | if (OculusManager::isConnected()) { |
| 915 | 923 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); |
| 916 | 924 | } else { |
| 917 | 925 | _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); |
| 918 | 926 | } |
| 927 | + if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 928 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 929 | + _myCamera.getRotation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 930 | + } else { | |
| 931 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 932 | + _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 933 | + } | |
| 919 | 934 | |
| 920 | 935 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 921 | 936 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| @@ -964,9 +979,7 @@ void Application::paintGL() { · 42 unmodified lines | ||
| 964 | 979 | glPopMatrix(); |
| 965 | 980 | |
| 966 | 981 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; |
| 967 | − if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 968 | − _rearMirrorTools->render(&renderArgs, true, _glWidget->mapFromGlobal(QCursor::pos())); | |
| 969 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 982 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 970 | 983 | renderRearViewMirror(&renderArgs, _mirrorViewRect); |
| 971 | 984 | } |
| 972 | 985 | |
| @@ -974,16 +987,18 @@ void Application::paintGL() { · 1 unmodified line | ||
| 974 | 987 | |
| 975 | 988 | auto finalFbo = DependencyManager::get<GlowEffect>()->render(&renderArgs); |
| 976 | 989 | |
| 990 | + | |
| 977 | 991 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); |
| 978 | 992 | glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); |
| 979 | 993 | glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y, |
| 980 | 994 | 0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(), |
| 981 | − GL_COLOR_BUFFER_BIT, GL_NEAREST); | |
| 995 | + GL_COLOR_BUFFER_BIT, GL_LINEAR); | |
| 982 | 996 | glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); |
| 983 | 997 | |
| 984 | − _applicationOverlay.displayOverlayTexture(); | |
| 998 | + _compositor.displayOverlayTexture(&renderArgs); | |
| 985 | 999 | } |
| 986 | 1000 | |
| 1001 | + | |
| 987 | 1002 | if (!OculusManager::isConnected() || OculusManager::allowSwap()) { |
| 988 | 1003 | _glWidget->swapBuffers(); |
| 989 | 1004 | } |
| @@ -1041,27 +1056,24 @@ void Application::resizeGL() { · 51 unmodified lines | ||
| 1041 | 1056 | } else { |
| 1042 | 1057 | renderSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); |
| 1043 | 1058 | } |
| 1044 | − if (_renderResolution == toGlm(renderSize)) { | |
| 1045 | − return; | |
| 1046 | − } | |
| 1047 | 1059 | |
| 1048 | − _renderResolution = toGlm(renderSize); | |
| 1049 | − DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize); | |
| 1050 | − resetCamerasOnResizeGL(_myCamera, _renderResolution); | |
| 1060 | + if (_renderResolution != toGlm(renderSize)) { | |
| 1061 | + _renderResolution = toGlm(renderSize); | |
| 1062 | + DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize); | |
| 1063 | + resetCamerasOnResizeGL(_myCamera, _renderResolution); | |
| 1051 | 1064 | |
| 1052 | − glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu??? | |
| 1065 | + glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu??? | |
| 1053 | 1066 | |
| 1054 | − updateProjectionMatrix(); | |
| 1055 | − glLoadIdentity(); | |
| 1067 | + updateProjectionMatrix(); | |
| 1068 | + glLoadIdentity(); | |
| 1069 | + } | |
| 1056 | 1070 | |
| 1057 | 1071 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 1058 | − offscreenUi->resize(_glWidget->size()); | |
| 1072 | + | |
| 1073 | + auto canvasSize = _glWidget->size(); | |
| 1074 | + offscreenUi->resize(canvasSize); | |
| 1059 | 1075 | _glWidget->makeCurrent(); |
| 1060 | 1076 | |
| 1061 | − // update Stats width | |
| 1062 | − // let's set horizontal offset to give stats some margin to mirror | |
| 1063 | − int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 1064 | − Stats::getInstance()->resetWidth(_renderResolution.x, horizontalOffset); | |
| 1065 | 1077 | } |
| 1066 | 1078 | |
| 1067 | 1079 | void Application::updateProjectionMatrix() { |
| @@ -1380,11 +1392,17 @@ void Application::keyPressEvent(QKeyEvent* event) { · 312 unmodified lines | ||
| 1380 | 1392 | if (isShifted) { |
| 1381 | 1393 | Menu::getInstance()->triggerOption(MenuOption::Mirror); |
| 1382 | 1394 | } else { |
| 1383 | − Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); | |
| 1395 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, !Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)); | |
| 1396 | + if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 1397 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, true); | |
| 1398 | + } | |
| 1399 | + cameraMenuChanged(); | |
| 1384 | 1400 | } |
| 1385 | 1401 | break; |
| 1386 | 1402 | case Qt::Key_P: |
| 1387 | − Menu::getInstance()->triggerOption(MenuOption::FirstPerson); | |
| 1403 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)); | |
| 1404 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)); | |
| 1405 | + cameraMenuChanged(); | |
| 1388 | 1406 | break; |
| 1389 | 1407 | case Qt::Key_Slash: |
| 1390 | 1408 | Menu::getInstance()->triggerOption(MenuOption::Stats); |
| @@ -1559,27 +1577,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 168 unmodified lines | ||
| 1559 | 1577 | _keyboardMouseDevice.mousePressEvent(event); |
| 1560 | 1578 | |
| 1561 | 1579 | if (event->button() == Qt::LeftButton) { |
| 1562 | − _mouseDragStartedX = getTrueMouseX(); | |
| 1563 | − _mouseDragStartedY = getTrueMouseY(); | |
| 1580 | + _mouseDragStarted = getTrueMouse(); | |
| 1564 | 1581 | _mousePressed = true; |
| 1565 | 1582 | |
| 1566 | − if (mouseOnScreen()) { | |
| 1567 | − if (DependencyManager::get<AudioToolBox>()->mousePressEvent(getMouseX(), getMouseY())) { | |
| 1568 | − // stop propagation | |
| 1569 | − return; | |
| 1570 | − } | |
| 1571 | − | |
| 1572 | − if (DependencyManager::get<CameraToolBox>()->mousePressEvent(getMouseX(), getMouseY())) { | |
| 1573 | − // stop propagation | |
| 1574 | − return; | |
| 1575 | − } | |
| 1576 | − | |
| 1577 | − if (_rearMirrorTools->mousePressEvent(getMouseX(), getMouseY())) { | |
| 1578 | − // stop propagation | |
| 1579 | − return; | |
| 1580 | − } | |
| 1581 | − } | |
| 1582 | − | |
| 1583 | 1583 | // nobody handled this - make it an action event on the _window object |
| 1584 | 1584 | HFActionEvent actionEvent(HFActionEvent::startType(), |
| 1585 | 1585 | computePickRay(event->x(), event->y())); |
| @@ -1597,16 +1597,7 @@ void Application::mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceI · 11 unmodified lines | ||
| 1597 | 1597 | return; |
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | − if (activeWindow() == _window) { | |
| 1601 | − if (event->button() == Qt::LeftButton) { | |
| 1602 | − if (mouseOnScreen()) { | |
| 1603 | − if (DependencyManager::get<CameraToolBox>()->mouseDoublePressEvent(getMouseX(), getMouseY())) { | |
| 1604 | − // stop propagation | |
| 1605 | − return; | |
| 1606 | − } | |
| 1607 | − } | |
| 1608 | − } | |
| 1609 | − } | |
| 1600 | + _controllerScriptingInterface.emitMouseDoublePressEvent(event); | |
| 1610 | 1601 | } |
| 1611 | 1602 | |
| 1612 | 1603 | void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { |
| @@ -1628,13 +1619,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 15 unmodified lines | ||
| 1628 | 1619 | if (event->button() == Qt::LeftButton) { |
| 1629 | 1620 | _mousePressed = false; |
| 1630 | 1621 | |
| 1631 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && mouseOnScreen()) { | |
| 1632 | − // let's set horizontal offset to give stats some margin to mirror | |
| 1633 | − int horizontalOffset = MIRROR_VIEW_WIDTH; | |
| 1634 | − Stats::getInstance()->checkClick(getMouseX(), getMouseY(), | |
| 1635 | − getMouseDragStartedX(), getMouseDragStartedY(), horizontalOffset); | |
| 1636 | − } | |
| 1637 | − | |
| 1638 | 1622 | // fire an action end event |
| 1639 | 1623 | HFActionEvent actionEvent(HFActionEvent::endType(), |
| 1640 | 1624 | computePickRay(event->x(), event->y())); |
| @@ -1662,22 +1646,18 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 21 unmodified lines | ||
| 1662 | 1646 | bool validTouch = false; |
| 1663 | 1647 | if (activeWindow() == _window) { |
| 1664 | 1648 | const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints(); |
| 1665 | − _touchAvgX = 0.0f; | |
| 1666 | − _touchAvgY = 0.0f; | |
| 1649 | + _touchAvg = vec2(); | |
| 1667 | 1650 | int numTouches = tPoints.count(); |
| 1668 | 1651 | if (numTouches > 1) { |
| 1669 | 1652 | for (int i = 0; i < numTouches; ++i) { |
| 1670 | − _touchAvgX += tPoints[i].pos().x(); | |
| 1671 | − _touchAvgY += tPoints[i].pos().y(); | |
| 1653 | + _touchAvg += toGlm(tPoints[i].pos()); | |
| 1672 | 1654 | } |
| 1673 | − _touchAvgX /= (float)(numTouches); | |
| 1674 | − _touchAvgY /= (float)(numTouches); | |
| 1655 | + _touchAvg /= (float)(numTouches); | |
| 1675 | 1656 | validTouch = true; |
| 1676 | 1657 | } |
| 1677 | 1658 | } |
| 1678 | 1659 | if (!_isTouchPressed) { |
| 1679 | − _touchDragStartedAvgX = _touchAvgX; | |
| 1680 | − _touchDragStartedAvgY = _touchAvgY; | |
| 1660 | + _touchDragStartedAvg = _touchAvg; | |
| 1681 | 1661 | } |
| 1682 | 1662 | _isTouchPressed = validTouch; |
| 1683 | 1663 | } |
| @@ -1713,8 +1693,7 @@ void Application::touchEndEvent(QTouchEvent* event) { · 29 unmodified lines | ||
| 1713 | 1693 | _keyboardMouseDevice.touchEndEvent(event); |
| 1714 | 1694 | |
| 1715 | 1695 | // put any application specific touch behavior below here.. |
| 1716 | − _touchDragStartedAvgX = _touchAvgX; | |
| 1717 | − _touchDragStartedAvgY = _touchAvgY; | |
| 1696 | + _touchDragStartedAvg = _touchAvg; | |
| 1718 | 1697 | _isTouchPressed = false; |
| 1719 | 1698 | |
| 1720 | 1699 | } |
| @@ -1863,9 +1842,9 @@ void Application::setFullscreen(bool fullscreen) { · 142 unmodified lines | ||
| 1863 | 1842 | Menu::getInstance()->getActionForOption(MenuOption::Fullscreen)->setChecked(fullscreen); |
| 1864 | 1843 | } |
| 1865 | 1844 | |
| 1866 | −// The following code block is useful on platforms that can have a visible | |
| 1867 | −// app menu in a fullscreen window. However the OSX mechanism hides the | |
| 1868 | −// application menu for fullscreen apps, so the check is not required. | |
| 1845 | + // The following code block is useful on platforms that can have a visible | |
| 1846 | + // app menu in a fullscreen window. However the OSX mechanism hides the | |
| 1847 | + // application menu for fullscreen apps, so the check is not required. | |
| 1869 | 1848 | #ifndef Q_OS_MAC |
| 1870 | 1849 | if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { |
| 1871 | 1850 | if (fullscreen) { |
| @@ -1939,11 +1918,6 @@ void Application::setEnableVRMode(bool enableVRMode) { · 67 unmodified lines | ||
| 1939 | 1918 | } else { |
| 1940 | 1919 | OculusManager::abandonCalibration(); |
| 1941 | 1920 | OculusManager::disconnect(); |
| 1942 | − | |
| 1943 | − _mirrorCamera.setHmdPosition(glm::vec3()); | |
| 1944 | − _mirrorCamera.setHmdRotation(glm::quat()); | |
| 1945 | − _myCamera.setHmdPosition(glm::vec3()); | |
| 1946 | − _myCamera.setHmdRotation(glm::quat()); | |
| 1947 | 1921 | } |
| 1948 | 1922 | |
| 1949 | 1923 | resizeGL(); |
| @@ -1955,44 +1929,34 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { · 5 unmodified lines | ||
| 1955 | 1929 | |
| 1956 | 1930 | bool Application::mouseOnScreen() const { |
| 1957 | 1931 | if (OculusManager::isConnected()) { |
| 1958 | − return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() && | |
| 1959 | − getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight(); | |
| 1932 | + ivec2 mouse = getMouse(); | |
| 1933 | + if (!glm::all(glm::greaterThanEqual(mouse, ivec2()))) { | |
| 1934 | + return false; | |
| 1935 | + } | |
| 1936 | + ivec2 size = toGlm(_glWidget->getDeviceSize()); | |
| 1937 | + if (!glm::all(glm::lessThanEqual(mouse, size))) { | |
| 1938 | + return false; | |
| 1939 | + } | |
| 1960 | 1940 | } |
| 1961 | 1941 | return true; |
| 1962 | 1942 | } |
| 1963 | 1943 | |
| 1964 | −int Application::getMouseX() const { | |
| 1965 | − if (OculusManager::isConnected()) { | |
| 1966 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY())); | |
| 1967 | − return pos.x; | |
| 1968 | − } | |
| 1969 | − return getTrueMouseX(); | |
| 1970 | −} | |
| 1971 | − | |
| 1972 | −int Application::getMouseY() const { | |
| 1944 | +ivec2 Application::getMouse() const { | |
| 1973 | 1945 | if (OculusManager::isConnected()) { |
| 1974 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY())); | |
| 1975 | − return pos.y; | |
| 1946 | + return _compositor.screenToOverlay(getTrueMouse()); | |
| 1976 | 1947 | } |
| 1977 | − return getTrueMouseY(); | |
| 1948 | + return getTrueMouse(); | |
| 1978 | 1949 | } |
| 1979 | 1950 | |
| 1980 | −int Application::getMouseDragStartedX() const { | |
| 1951 | +ivec2 Application::getMouseDragStarted() const { | |
| 1981 | 1952 | if (OculusManager::isConnected()) { |
| 1982 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(), | |
| 1983 | − getTrueMouseDragStartedY())); | |
| 1984 | − return pos.x; | |
| 1953 | + return _compositor.screenToOverlay(getTrueMouseDragStarted()); | |
| 1985 | 1954 | } |
| 1986 | − return getTrueMouseDragStartedX(); | |
| 1955 | + return getTrueMouseDragStarted(); | |
| 1987 | 1956 | } |
| 1988 | 1957 | |
| 1989 | −int Application::getMouseDragStartedY() const { | |
| 1990 | − if (OculusManager::isConnected()) { | |
| 1991 | − glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(), | |
| 1992 | − getTrueMouseDragStartedY())); | |
| 1993 | − return pos.y; | |
| 1994 | − } | |
| 1995 | − return getTrueMouseDragStartedY(); | |
| 1958 | +ivec2 Application::getTrueMouseDragStarted() const { | |
| 1959 | + return _mouseDragStarted; | |
| 1996 | 1960 | } |
| 1997 | 1961 | |
| 1998 | 1962 | FaceTracker* Application::getActiveFaceTracker() { |
| @@ -2237,13 +2201,6 @@ void Application::init() { · 238 unmodified lines | ||
| 2237 | 2201 | _entityClipboardRenderer.setViewFrustum(getViewFrustum()); |
| 2238 | 2202 | _entityClipboardRenderer.setTree(&_entityClipboard); |
| 2239 | 2203 | |
| 2240 | − _rearMirrorTools = new RearMirrorTools(_mirrorViewRect); | |
| 2241 | − | |
| 2242 | − connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); | |
| 2243 | − connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); | |
| 2244 | − connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); | |
| 2245 | − connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); | |
| 2246 | − | |
| 2247 | 2204 | // initialize the GlowEffect with our widget |
| 2248 | 2205 | bool glow = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect); |
| 2249 | 2206 | DependencyManager::get<GlowEffect>()->init(glow); |
| @@ -2408,13 +2365,23 @@ void Application::cameraMenuChanged() { · 158 unmodified lines | ||
| 2408 | 2365 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 2409 | 2366 | _myAvatar->setBoomLength(MyAvatar::ZOOM_MIN); |
| 2410 | 2367 | } |
| 2411 | − } else { | |
| 2368 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::ThirdPerson)) { | |
| 2412 | 2369 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 2413 | 2370 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 2414 | 2371 | if (_myAvatar->getBoomLength() == MyAvatar::ZOOM_MIN) { |
| 2415 | 2372 | _myAvatar->setBoomLength(MyAvatar::ZOOM_DEFAULT); |
| 2416 | 2373 | } |
| 2417 | 2374 | } |
| 2375 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::IndependentMode)) { | |
| 2376 | + if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { | |
| 2377 | + _myCamera.setMode(CAMERA_MODE_INDEPENDENT); | |
| 2378 | + } | |
| 2379 | + } | |
| 2380 | +} | |
| 2381 | + | |
| 2382 | +void Application::rotationModeChanged() { | |
| 2383 | + if (!Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 2384 | + _myAvatar->setHeadPitch(0); | |
| 2418 | 2385 | } |
| 2419 | 2386 | } |
| 2420 | 2387 | |
| @@ -2502,18 +2469,22 @@ void Application::update(float deltaTime) { · 81 unmodified lines | ||
| 2502 | 2469 | |
| 2503 | 2470 | // Transfer the user inputs to the driveKeys |
| 2504 | 2471 | _myAvatar->clearDriveKeys(); |
| 2505 | − _myAvatar->setDriveKeys(FWD, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_FORWARD)); | |
| 2506 | − _myAvatar->setDriveKeys(BACK, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_BACKWARD)); | |
| 2507 | − _myAvatar->setDriveKeys(UP, _userInputMapper.getActionState(UserInputMapper::VERTICAL_UP)); | |
| 2508 | − _myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN)); | |
| 2509 | − _myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT)); | |
| 2510 | − _myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT)); | |
| 2511 | − _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP)); | |
| 2512 | − _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN)); | |
| 2513 | − _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT)); | |
| 2514 | − _myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT)); | |
| 2515 | − _myAvatar->setDriveKeys(BOOM_IN, _userInputMapper.getActionState(UserInputMapper::BOOM_IN)); | |
| 2516 | − _myAvatar->setDriveKeys(BOOM_OUT, _userInputMapper.getActionState(UserInputMapper::BOOM_OUT)); | |
| 2472 | + if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { | |
| 2473 | + if (!_controllerScriptingInterface.areActionsCaptured()) { | |
| 2474 | + _myAvatar->setDriveKeys(FWD, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_FORWARD)); | |
| 2475 | + _myAvatar->setDriveKeys(BACK, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_BACKWARD)); | |
| 2476 | + _myAvatar->setDriveKeys(UP, _userInputMapper.getActionState(UserInputMapper::VERTICAL_UP)); | |
| 2477 | + _myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN)); | |
| 2478 | + _myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT)); | |
| 2479 | + _myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT)); | |
| 2480 | + _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP)); | |
| 2481 | + _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN)); | |
| 2482 | + _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT)); | |
| 2483 | + _myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT)); | |
| 2484 | + } | |
| 2485 | + _myAvatar->setDriveKeys(BOOM_IN, _userInputMapper.getActionState(UserInputMapper::BOOM_IN)); | |
| 2486 | + _myAvatar->setDriveKeys(BOOM_OUT, _userInputMapper.getActionState(UserInputMapper::BOOM_OUT)); | |
| 2487 | + } | |
| 2517 | 2488 | |
| 2518 | 2489 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 2519 | 2490 | |
| @@ -2530,24 +2501,45 @@ void Application::update(float deltaTime) { · 10 unmodified lines | ||
| 2530 | 2501 | |
| 2531 | 2502 | _entitySimulation.lock(); |
| 2532 | 2503 | _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete()); |
| 2504 | + _entitySimulation.unlock(); | |
| 2505 | + | |
| 2506 | + _entities.getTree()->lockForWrite(); | |
| 2507 | + _entitySimulation.lock(); | |
| 2533 | 2508 | _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd()); |
| 2509 | + _entitySimulation.unlock(); | |
| 2510 | + _entities.getTree()->unlock(); | |
| 2511 | + | |
| 2512 | + _entities.getTree()->lockForWrite(); | |
| 2513 | + _entitySimulation.lock(); | |
| 2534 | 2514 | _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange()); |
| 2515 | + _entitySimulation.unlock(); | |
| 2516 | + _entities.getTree()->unlock(); | |
| 2517 | + | |
| 2518 | + _entitySimulation.lock(); | |
| 2535 | 2519 | _entitySimulation.applyActionChanges(); |
| 2536 | 2520 | _entitySimulation.unlock(); |
| 2537 | 2521 | |
| 2522 | + | |
| 2538 | 2523 | AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data(); |
| 2539 | 2524 | _physicsEngine.deleteObjects(avatarManager->getObjectsToDelete()); |
| 2540 | 2525 | _physicsEngine.addObjects(avatarManager->getObjectsToAdd()); |
| 2541 | 2526 | _physicsEngine.changeObjects(avatarManager->getObjectsToChange()); |
| 2542 | 2527 | |
| 2528 | + _entities.getTree()->lockForWrite(); | |
| 2543 | 2529 | _physicsEngine.stepSimulation(); |
| 2530 | + _entities.getTree()->unlock(); | |
| 2544 | 2531 | |
| 2545 | 2532 | if (_physicsEngine.hasOutgoingChanges()) { |
| 2533 | + _entities.getTree()->lockForWrite(); | |
| 2546 | 2534 | _entitySimulation.lock(); |
| 2547 | 2535 | _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges(), _physicsEngine.getSessionID()); |
| 2548 | 2536 | _entitySimulation.unlock(); |
| 2537 | + _entities.getTree()->unlock(); | |
| 2549 | 2538 | |
| 2539 | + _entities.getTree()->lockForWrite(); | |
| 2550 | 2540 | avatarManager->handleOutgoingChanges(_physicsEngine.getOutgoingChanges()); |
| 2541 | + _entities.getTree()->unlock(); | |
| 2542 | + | |
| 2551 | 2543 | auto collisionEvents = _physicsEngine.getCollisionEvents(); |
| 2552 | 2544 | avatarManager->handleCollisionEvents(collisionEvents); |
| 2553 | 2545 | |
| @@ -3137,7 +3129,7 @@ PickRay Application::computePickRay(float x, float y) const { · 583 unmodified lines | ||
| 3137 | 3129 | y /= size.y; |
| 3138 | 3130 | PickRay result; |
| 3139 | 3131 | if (isHMDMode()) { |
| 3140 | − getApplicationOverlay().computeHmdPickRay(glm::vec2(x, y), result.origin, result.direction); | |
| 3132 | + getApplicationCompositor().computeHmdPickRay(glm::vec2(x, y), result.origin, result.direction); | |
| 3141 | 3133 | } else { |
| 3142 | 3134 | if (QThread::currentThread() == activeRenderingThread) { |
| 3143 | 3135 | getDisplayViewFrustum()->computePickRay(x, y, result.origin, result.direction); |
| @@ -3166,13 +3158,11 @@ QImage Application::renderAvatarBillboard(RenderArgs* renderArgs) { · 22 unmodified lines | ||
| 3166 | 3158 | renderRearViewMirror(renderArgs, QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, |
| 3167 | 3159 | BILLBOARD_SIZE, BILLBOARD_SIZE), |
| 3168 | 3160 | true); |
| 3169 | − | |
| 3170 | 3161 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 3171 | 3162 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); |
| 3172 | 3163 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 3173 | 3164 | |
| 3174 | 3165 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 3175 | − | |
| 3176 | 3166 | return image; |
| 3177 | 3167 | } |
| 3178 | 3168 | |
| @@ -3357,6 +3347,11 @@ namespace render { · 178 unmodified lines | ||
| 3357 | 3347 | |
| 3358 | 3348 | |
| 3359 | 3349 | void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool selfAvatarOnly, bool billboard) { |
| 3350 | + | |
| 3351 | + // FIXME: This preRender call is temporary until we create a separate render::scene for the mirror rendering. | |
| 3352 | + // Then we can move this logic into the Avatar::simulate call. | |
| 3353 | + _myAvatar->preRender(renderArgs); | |
| 3354 | + | |
| 3360 | 3355 | activeRenderingThread = QThread::currentThread(); |
| 3361 | 3356 | PROFILE_RANGE(__FUNCTION__); |
| 3362 | 3357 | PerformanceTimer perfTimer("display"); |
| @@ -3368,9 +3363,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 5 unmodified lines | ||
| 3368 | 3363 | |
| 3369 | 3364 | // flip x if in mirror mode (also requires reversing winding order for backface culling) |
| 3370 | 3365 | if (theCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 3371 | − glScalef(-1.0f, 1.0f, 1.0f); | |
| 3372 | − glFrontFace(GL_CW); | |
| 3373 | − | |
| 3366 | + //glScalef(-1.0f, 1.0f, 1.0f); | |
| 3367 | + //glFrontFace(GL_CW); | |
| 3374 | 3368 | } else { |
| 3375 | 3369 | glFrontFace(GL_CCW); |
| 3376 | 3370 | } |
| @@ -3393,7 +3387,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 16 unmodified lines | ||
| 3393 | 3387 | viewTransform.setTranslation(theCamera.getPosition()); |
| 3394 | 3388 | viewTransform.setRotation(rotation); |
| 3395 | 3389 | if (theCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 3396 | − viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f)); | |
| 3390 | +// viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f)); | |
| 3397 | 3391 | } |
| 3398 | 3392 | if (renderArgs->_renderSide != RenderArgs::MONO) { |
| 3399 | 3393 | glm::mat4 invView = glm::inverse(_untranslatedViewMatrix); |
| @@ -3530,6 +3524,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 130 unmodified lines | ||
| 3530 | 3524 | |
| 3531 | 3525 | renderContext._maxDrawnOpaqueItems = sceneInterface->getEngineMaxDrawnOpaqueItems(); |
| 3532 | 3526 | renderContext._maxDrawnTransparentItems = sceneInterface->getEngineMaxDrawnTransparentItems(); |
| 3527 | + renderContext._maxDrawnOverlay3DItems = sceneInterface->getEngineMaxDrawnOverlay3DItems(); | |
| 3533 | 3528 | |
| 3534 | 3529 | renderArgs->_shouldRender = LODManager::shouldRender; |
| 3535 | 3530 | |
| @@ -3546,7 +3541,9 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 10 unmodified lines | ||
| 3546 | 3541 | |
| 3547 | 3542 | sceneInterface->setEngineFeedTransparentItems(engineRC->_numFeedTransparentItems); |
| 3548 | 3543 | sceneInterface->setEngineDrawnTransparentItems(engineRC->_numDrawnTransparentItems); |
| 3549 | − | |
| 3544 | + | |
| 3545 | + sceneInterface->setEngineFeedOverlay3DItems(engineRC->_numFeedOverlay3DItems); | |
| 3546 | + sceneInterface->setEngineDrawnOverlay3DItems(engineRC->_numDrawnOverlay3DItems); | |
| 3550 | 3547 | } |
| 3551 | 3548 | //Render the sixense lasers |
| 3552 | 3549 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) { |
| @@ -3654,8 +3651,8 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 101 unmodified lines | ||
| 3654 | 3651 | // +-----------------------+ |
| 3655 | 3652 | // -1,-1 1,-1 |
| 3656 | 3653 | |
| 3657 | − glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale, | |
| 3658 | − ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight()); | |
| 3654 | + glm::vec2 screenPoint((projectedPoint.x + 1.0f) * horizontalScale, | |
| 3655 | + ((projectedPoint.y + 1.0f) * -verticalScale) + _glWidget->getDeviceHeight()); | |
| 3659 | 3656 | |
| 3660 | 3657 | return screenPoint; |
| 3661 | 3658 | } |
| @@ -3673,7 +3670,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 11 unmodified lines | ||
| 3673 | 3670 | _mirrorCamera.setPosition(_myAvatar->getPosition() + |
| 3674 | 3671 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 3675 | 3672 | |
| 3676 | − } else if (RearMirrorTools::rearViewZoomLevel.get() == BODY) { | |
| 3673 | + } else if (!AvatarInputs::getInstance()->mirrorZoomed()) { | |
| 3677 | 3674 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + |
| 3678 | 3675 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| 3679 | 3676 | |
| @@ -3708,7 +3705,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 28 unmodified lines | ||
| 3708 | 3705 | } else { |
| 3709 | 3706 | // if not rendering the billboard, the region is in device independent coordinates; must convert to device |
| 3710 | 3707 | QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize(); |
| 3711 | − float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale(); | |
| 3708 | + float ratio = (float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale(); | |
| 3712 | 3709 | int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio; |
| 3713 | 3710 | glViewport(x, size.height() - y - height, width, height); |
| 3714 | 3711 | glScissor(x, size.height() - y - height, width, height); |
| @@ -3723,10 +3720,6 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 8 unmodified lines | ||
| 3723 | 3720 | displaySide(renderArgs, _mirrorCamera, true, billboard); |
| 3724 | 3721 | glPopMatrix(); |
| 3725 | 3722 | |
| 3726 | − if (!billboard) { | |
| 3727 | − _rearMirrorTools->render(renderArgs, false, _glWidget->mapFromGlobal(QCursor::pos())); | |
| 3728 | − } | |
| 3729 | − | |
| 3730 | 3723 | // reset Viewport and projection matrix |
| 3731 | 3724 | glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); |
| 3732 | 3725 | glDisable(GL_SCISSOR_TEST); |
| @@ -3866,7 +3859,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 133 unmodified lines | ||
| 3866 | 3859 | _entityServerJurisdictions.unlock(); |
| 3867 | 3860 | |
| 3868 | 3861 | qCDebug(interfaceapp, "model server going away...... v[%f, %f, %f, %f]", |
| 3869 | − rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); | |
| 3862 | + (double)rootDetails.x, (double)rootDetails.y, (double)rootDetails.z, (double)rootDetails.s); | |
| 3870 | 3863 | |
| 3871 | 3864 | // Add the jurisditionDetails object to the list of "fade outs" |
| 3872 | 3865 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) { |
| @@ -3952,7 +3945,8 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin · 79 unmodified lines | ||
| 3952 | 3945 | jurisdiction->unlock(); |
| 3953 | 3946 | |
| 3954 | 3947 | qCDebug(interfaceapp, "stats from new %s server... [%f, %f, %f, %f]", |
| 3955 | − qPrintable(serverType), rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); | |
| 3948 | + qPrintable(serverType), | |
| 3949 | + (double)rootDetails.x, (double)rootDetails.y, (double)rootDetails.z, (double)rootDetails.s); | |
| 3956 | 3950 | |
| 3957 | 3951 | // Add the jurisditionDetails object to the list of "fade outs" |
| 3958 | 3952 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) { |
| @@ -4059,6 +4053,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 100 unmodified lines | ||
| 4059 | 4053 | connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(scriptFinished(const QString&))); |
| 4060 | 4054 | |
| 4061 | 4055 | connect(scriptEngine, SIGNAL(loadScript(const QString&, bool)), this, SLOT(loadScript(const QString&, bool))); |
| 4056 | + connect(scriptEngine, SIGNAL(reloadScript(const QString&, bool)), this, SLOT(reloadScript(const QString&, bool))); | |
| 4062 | 4057 | |
| 4063 | 4058 | scriptEngine->registerGlobalObject("Overlays", &_overlays); |
| 4064 | 4059 | qScriptRegisterMetaType(scriptEngine, OverlayPropertyResultToScriptValue, OverlayPropertyResultFromScriptValue); |
| @@ -4274,7 +4269,7 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { · 209 unmodified lines | ||
| 4274 | 4269 | } |
| 4275 | 4270 | |
| 4276 | 4271 | ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUserLoaded, |
| 4277 | − bool loadScriptFromEditor, bool activateMainWindow) { | |
| 4272 | + bool loadScriptFromEditor, bool activateMainWindow, bool reload) { | |
| 4278 | 4273 | |
| 4279 | 4274 | if (isAboutToQuit()) { |
| 4280 | 4275 | return NULL; |
| @@ -4303,7 +4298,7 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 22 unmodified lines | ||
| 4303 | 4298 | connect(scriptEngine, &ScriptEngine::errorLoadingScript, this, &Application::handleScriptLoadError); |
| 4304 | 4299 | |
| 4305 | 4300 | // get the script engine object to load the script at the designated script URL |
| 4306 | − scriptEngine->loadURL(scriptUrl); | |
| 4301 | + scriptEngine->loadURL(scriptUrl, reload); | |
| 4307 | 4302 | } |
| 4308 | 4303 | |
| 4309 | 4304 | // restore the main window's active state |
| @@ -4314,6 +4309,10 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 4 unmodified lines | ||
| 4314 | 4309 | return scriptEngine; |
| 4315 | 4310 | } |
| 4316 | 4311 | |
| 4312 | +void Application::reloadScript(const QString& scriptName, bool isUserLoaded) { | |
| 4313 | + loadScript(scriptName, isUserLoaded, false, false, true); | |
| 4314 | +} | |
| 4315 | + | |
| 4317 | 4316 | void Application::handleScriptEngineLoaded(const QString& scriptFilename) { |
| 4318 | 4317 | ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(sender()); |
| 4319 | 4318 | |
| @@ -4341,14 +4340,25 @@ void Application::scriptFinished(const QString& scriptName) { · 21 unmodified lines | ||
| 4341 | 4340 | } |
| 4342 | 4341 | |
| 4343 | 4342 | void Application::stopAllScripts(bool restart) { |
| 4344 | − // stops all current running scripts | |
| 4343 | + if (restart) { | |
| 4344 | + // Delete all running scripts from cache so that they are re-downloaded when they are restarted | |
| 4345 | + auto scriptCache = DependencyManager::get<ScriptCache>(); | |
| 4346 | + for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); | |
| 4347 | + it != _scriptEnginesHash.constEnd(); it++) { | |
| 4348 | + if (!it.value()->isFinished()) { | |
| 4349 | + scriptCache->deleteScript(it.key()); | |
| 4350 | + } | |
| 4351 | + } | |
| 4352 | + } | |
| 4353 | + | |
| 4354 | + // Stop and possibly restart all currently running scripts | |
| 4345 | 4355 | for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); |
| 4346 | 4356 | it != _scriptEnginesHash.constEnd(); it++) { |
| 4347 | 4357 | if (it.value()->isFinished()) { |
| 4348 | 4358 | continue; |
| 4349 | 4359 | } |
| 4350 | 4360 | if (restart && it.value()->isUserLoaded()) { |
| 4351 | − connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&))); | |
| 4361 | + connect(it.value(), SIGNAL(finished(const QString&)), SLOT(reloadScript(const QString&))); | |
| 4352 | 4362 | } |
| 4353 | 4363 | it.value()->stop(); |
| 4354 | 4364 | qCDebug(interfaceapp) << "stopping script..." << it.key(); |
| @@ -4356,13 +4366,20 @@ void Application::stopAllScripts(bool restart) { · 1 unmodified line | ||
| 4356 | 4366 | // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities |
| 4357 | 4367 | // whenever a script stops in case it happened to have been setting joint rotations. |
| 4358 | 4368 | // TODO: expose animation priorities and provide a layered animation control system. |
| 4369 | + _myAvatar->clearJointAnimationPriorities(); | |
| 4359 | 4370 | _myAvatar->clearScriptableSettings(); |
| 4360 | 4371 | } |
| 4361 | 4372 | |
| 4362 | −void Application::stopScript(const QString &scriptName) { | |
| 4373 | +void Application::stopScript(const QString &scriptName, bool restart) { | |
| 4363 | 4374 | const QString& scriptURLString = QUrl(scriptName).toString(); |
| 4364 | 4375 | if (_scriptEnginesHash.contains(scriptURLString)) { |
| 4365 | − _scriptEnginesHash.value(scriptURLString)->stop(); | |
| 4376 | + ScriptEngine* scriptEngine = _scriptEnginesHash[scriptURLString]; | |
| 4377 | + if (restart) { | |
| 4378 | + auto scriptCache = DependencyManager::get<ScriptCache>(); | |
| 4379 | + scriptCache->deleteScript(scriptName); | |
| 4380 | + connect(scriptEngine, SIGNAL(finished(const QString&)), SLOT(reloadScript(const QString&))); | |
| 4381 | + } | |
| 4382 | + scriptEngine->stop(); | |
| 4366 | 4383 | qCDebug(interfaceapp) << "stopping script..." << scriptName; |
| 4367 | 4384 | // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities |
| 4368 | 4385 | // whenever a script stops in case it happened to have been setting joint rotations. |
| @@ -4378,6 +4395,10 @@ void Application::reloadAllScripts() { · 9 unmodified lines | ||
| 4378 | 4395 | stopAllScripts(true); |
| 4379 | 4396 | } |
| 4380 | 4397 | |
| 4398 | +void Application::reloadOneScript(const QString& scriptName) { | |
| 4399 | + stopScript(scriptName, true); | |
| 4400 | +} | |
| 4401 | + | |
| 4381 | 4402 | void Application::loadDefaultScripts() { |
| 4382 | 4403 | if (!_scriptEnginesHash.contains(DEFAULT_SCRIPTS_JS_URL)) { |
| 4383 | 4404 | loadScript(DEFAULT_SCRIPTS_JS_URL); |
| @@ -4732,11 +4753,9 @@ void Application::postLambdaEvent(std::function<void()> f) { · 348 unmodified lines | ||
| 4732 | 4753 | } |
| 4733 | 4754 | |
| 4734 | 4755 | void Application::initPlugins() { |
| 4735 | − OculusManager::init(); | |
| 4736 | 4756 | } |
| 4737 | 4757 | |
| 4738 | 4758 | void Application::shutdownPlugins() { |
| 4739 | − OculusManager::deinit(); | |
| 4740 | 4759 | } |
| 4741 | 4760 | |
| 4742 | 4761 | glm::vec3 Application::getHeadPosition() const { |
| @@ -4756,12 +4775,8 @@ QSize Application::getDeviceSize() const { · 13 unmodified lines | ||
| 4756 | 4775 | return _glWidget->getDeviceSize(); |
| 4757 | 4776 | } |
| 4758 | 4777 | |
| 4759 | −int Application::getTrueMouseX() const { | |
| 4760 | − return _glWidget->mapFromGlobal(QCursor::pos()).x(); | |
| 4761 | −} | |
| 4762 | − | |
| 4763 | −int Application::getTrueMouseY() const { | |
| 4764 | − return _glWidget->mapFromGlobal(QCursor::pos()).y(); | |
| 4778 | +ivec2 Application::getTrueMouse() const { | |
| 4779 | + return toGlm(_glWidget->mapFromGlobal(QCursor::pos())); | |
| 4765 | 4780 | } |
| 4766 | 4781 | |
| 4767 | 4782 | bool Application::isThrottleRendering() const { |
| @@ -4791,3 +4806,25 @@ qreal Application::getDevicePixelRatio() { · 23 unmodified lines | ||
| 4791 | 4806 | return _window ? _window->windowHandle()->devicePixelRatio() : 1.0; |
| 4792 | 4807 | } |
| 4793 | 4808 | |
| 4809 | +mat4 Application::getEyeProjection(int eye) const { | |
| 4810 | + if (isHMDMode()) { | |
| 4811 | + return OculusManager::getEyeProjection(eye); | |
| 4812 | + } | |
| 4813 | + | |
| 4814 | + return _viewFrustum.getProjection(); | |
| 4815 | +} | |
| 4816 | + | |
| 4817 | +mat4 Application::getEyePose(int eye) const { | |
| 4818 | + if (isHMDMode()) { | |
| 4819 | + return OculusManager::getEyePose(eye); | |
| 4820 | + } | |
| 4821 | + | |
| 4822 | + return mat4(); | |
| 4823 | +} | |
| 4824 | + | |
| 4825 | +mat4 Application::getHeadPose() const { | |
| 4826 | + if (isHMDMode()) { | |
| 4827 | + return OculusManager::getHeadPose(); | |
| 4828 | + } | |
| 4829 | + return mat4(); | |
| 4830 | +} | |