History

Merge with master

Sam Gondelman committed 11 years ago

Commit 19ec0802 parents 778e19a 0bef506214 files · +6701 −6001Browse files

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

Unified · Split

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