History

merged master

ericrius1 committed 11 years ago

Commit cf720f92 parents 10cefe0 62b3ca9275 files · +8836 −7501Browse files

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

Unified · Split

interface/src/Application.cpp+209−172
@@ -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),
@@ -610,6 +604,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 267 unmodified lines
610 _settingsTimer.setSingleShot(false);604 _settingsTimer.setSingleShot(false);
611 _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);605 _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);
612 _settingsThread.start();606 _settingsThread.start();
607
608 if (Menu::getInstance()->isOptionChecked(MenuOption::IndependentMode)) {
609 Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, true);
610 cameraMenuChanged();
611 }
613 612
614 _trayIcon->show();613 _trayIcon->show();
615 614
@@ -814,9 +813,9 @@ void Application::initializeGL() { · 198 unmodified lines
814 _idleLoopStdev.reset();813 _idleLoopStdev.reset();
815 814
816 if (_justStarted) {815 if (_justStarted) {
817 float startupTime = (float)_applicationStartupTime.elapsed() / 1000.0;816 float startupTime = (float)_applicationStartupTime.elapsed() / 1000.0f;
818 _justStarted = false;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 // update before the first render821 // update before the first render
@@ -831,6 +830,7 @@ void Application::initializeUi() { · 8 unmodified lines
831 LoginDialog::registerType();830 LoginDialog::registerType();
832 MessageDialog::registerType();831 MessageDialog::registerType();
833 VrMenu::registerType();832 VrMenu::registerType();
833 Tooltip::registerType();
834 UpdateDialog::registerType();834 UpdateDialog::registerType();
835 835
836 auto offscreenUi = DependencyManager::get<OffscreenUi>();836 auto offscreenUi = DependencyManager::get<OffscreenUi>();
@@ -844,7 +844,7 @@ void Application::initializeUi() { · 7 unmodified lines
844 VrMenu::executeQueuedLambdas();844 VrMenu::executeQueuedLambdas();
845 offscreenUi->setMouseTranslator([this](const QPointF& p){845 offscreenUi->setMouseTranslator([this](const QPointF& p){
846 if (OculusManager::isConnected()) {846 if (OculusManager::isConnected()) {
847 glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p));847 glm::vec2 pos = _compositor.screenToOverlay(toGlm(p));
848 return QPointF(pos.x, pos.y);848 return QPointF(pos.x, pos.y);
849 }849 }
850 return QPointF(p);850 return QPointF(p);
@@ -877,6 +877,7 @@ void Application::paintGL() { · 26 unmodified lines
877 OculusManager::beginFrameTiming();877 OculusManager::beginFrameTiming();
878 }878 }
879 879
880
880 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));881 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
881 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);882 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
882 PerformanceWarning warn(showWarnings, "Application::paintGL()");883 PerformanceWarning warn(showWarnings, "Application::paintGL()");
@@ -884,13 +885,22 @@ void Application::paintGL() { · 1 unmodified line
884 885
885 {886 {
886 PerformanceTimer perfTimer("renderOverlay");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 _applicationOverlay.renderOverlay(&renderArgs);894 _applicationOverlay.renderOverlay(&renderArgs);
888 }895 }
889 896
890 glEnable(GL_LINE_SMOOTH);897 glEnable(GL_LINE_SMOOTH);
891 898
892 Menu::getInstance()->setIsOptionChecked("First Person", _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);899 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
893 Application::getInstance()->cameraMenuChanged();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 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {905 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
896 // Always use the default eye position, not the actual head eye position.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 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {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 if (OculusManager::isConnected()) {922 if (OculusManager::isConnected()) {
915 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());923 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
916 } else {924 } else {
917 _myCamera.setRotation(_myAvatar->getHead()->getOrientation());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 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {935 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
921 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));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 glPopMatrix();979 glPopMatrix();
965 980
966 renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;981 renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
967 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {982 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
968 _rearMirrorTools->render(&renderArgs, true, _glWidget->mapFromGlobal(QCursor::pos()));
969 } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
970 renderRearViewMirror(&renderArgs, _mirrorViewRect); 983 renderRearViewMirror(&renderArgs, _mirrorViewRect);
971 }984 }
972 985
@@ -974,16 +987,18 @@ void Application::paintGL() { · 1 unmodified line
974 987
975 auto finalFbo = DependencyManager::get<GlowEffect>()->render(&renderArgs);988 auto finalFbo = DependencyManager::get<GlowEffect>()->render(&renderArgs);
976 989
990
977 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);991 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
978 glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));992 glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
979 glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y,993 glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y,
980 0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(),994 0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(),
981 GL_COLOR_BUFFER_BIT, GL_NEAREST);995 GL_COLOR_BUFFER_BIT, GL_LINEAR);
982 glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);996 glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
983 997
984 _applicationOverlay.displayOverlayTexture();998 _compositor.displayOverlayTexture(&renderArgs);
985 }999 }
986 1000
1001
987 if (!OculusManager::isConnected() || OculusManager::allowSwap()) {1002 if (!OculusManager::isConnected() || OculusManager::allowSwap()) {
988 _glWidget->swapBuffers();1003 _glWidget->swapBuffers();
989 }1004 }
@@ -1041,27 +1056,24 @@ void Application::resizeGL() { · 51 unmodified lines
1041 } else {1056 } else {
1042 renderSize = _glWidget->getDeviceSize() * getRenderResolutionScale();1057 renderSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
1043 }1058 }
1044 if (_renderResolution == toGlm(renderSize)) {
1045 return;
1046 }
1047 1059
1048 _renderResolution = toGlm(renderSize);1060 if (_renderResolution != toGlm(renderSize)) {
1049 DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize);1061 _renderResolution = toGlm(renderSize);
1050 resetCamerasOnResizeGL(_myCamera, _renderResolution);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();1067 updateProjectionMatrix();
1055 glLoadIdentity();1068 glLoadIdentity();
1069 }
1056 1070
1057 auto offscreenUi = DependencyManager::get<OffscreenUi>();1071 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1058 offscreenUi->resize(_glWidget->size());1072
1073 auto canvasSize = _glWidget->size();
1074 offscreenUi->resize(canvasSize);
1059 _glWidget->makeCurrent();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
1067void Application::updateProjectionMatrix() {1079void Application::updateProjectionMatrix() {
@@ -1380,11 +1392,17 @@ void Application::keyPressEvent(QKeyEvent* event) { · 312 unmodified lines
1380 if (isShifted) {1392 if (isShifted) {
1381 Menu::getInstance()->triggerOption(MenuOption::Mirror);1393 Menu::getInstance()->triggerOption(MenuOption::Mirror);
1382 } else {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 break;1401 break;
1386 case Qt::Key_P: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 break;1406 break;
1389 case Qt::Key_Slash:1407 case Qt::Key_Slash:
1390 Menu::getInstance()->triggerOption(MenuOption::Stats);1408 Menu::getInstance()->triggerOption(MenuOption::Stats);
@@ -1559,27 +1577,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 168 unmodified lines
1559 _keyboardMouseDevice.mousePressEvent(event);1577 _keyboardMouseDevice.mousePressEvent(event);
1560 1578
1561 if (event->button() == Qt::LeftButton) {1579 if (event->button() == Qt::LeftButton) {
1562 _mouseDragStartedX = getTrueMouseX();1580 _mouseDragStarted = getTrueMouse();
1563 _mouseDragStartedY = getTrueMouseY();
1564 _mousePressed = true;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 // nobody handled this - make it an action event on the _window object1583 // nobody handled this - make it an action event on the _window object
1584 HFActionEvent actionEvent(HFActionEvent::startType(),1584 HFActionEvent actionEvent(HFActionEvent::startType(),
1585 computePickRay(event->x(), event->y()));1585 computePickRay(event->x(), event->y()));
@@ -1597,16 +1597,7 @@ void Application::mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceI · 11 unmodified lines
1597 return;1597 return;
1598 }1598 }
1599 1599
1600 if (activeWindow() == _window) {1600 _controllerScriptingInterface.emitMouseDoublePressEvent(event);
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 }
1610}1601}
1611 1602
1612void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {1603void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
@@ -1628,13 +1619,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 15 unmodified lines
1628 if (event->button() == Qt::LeftButton) {1619 if (event->button() == Qt::LeftButton) {
1629 _mousePressed = false;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 // fire an action end event1622 // fire an action end event
1639 HFActionEvent actionEvent(HFActionEvent::endType(),1623 HFActionEvent actionEvent(HFActionEvent::endType(),
1640 computePickRay(event->x(), event->y()));1624 computePickRay(event->x(), event->y()));
@@ -1662,22 +1646,18 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 21 unmodified lines
1662 bool validTouch = false;1646 bool validTouch = false;
1663 if (activeWindow() == _window) {1647 if (activeWindow() == _window) {
1664 const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();1648 const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
1665 _touchAvgX = 0.0f;1649 _touchAvg = vec2();
1666 _touchAvgY = 0.0f;
1667 int numTouches = tPoints.count();1650 int numTouches = tPoints.count();
1668 if (numTouches > 1) {1651 if (numTouches > 1) {
1669 for (int i = 0; i < numTouches; ++i) {1652 for (int i = 0; i < numTouches; ++i) {
1670 _touchAvgX += tPoints[i].pos().x();1653 _touchAvg += toGlm(tPoints[i].pos());
1671 _touchAvgY += tPoints[i].pos().y();
1672 }1654 }
1673 _touchAvgX /= (float)(numTouches);1655 _touchAvg /= (float)(numTouches);
1674 _touchAvgY /= (float)(numTouches);
1675 validTouch = true;1656 validTouch = true;
1676 }1657 }
1677 }1658 }
1678 if (!_isTouchPressed) {1659 if (!_isTouchPressed) {
1679 _touchDragStartedAvgX = _touchAvgX;1660 _touchDragStartedAvg = _touchAvg;
1680 _touchDragStartedAvgY = _touchAvgY;
1681 }1661 }
1682 _isTouchPressed = validTouch;1662 _isTouchPressed = validTouch;
1683}1663}
@@ -1713,8 +1693,7 @@ void Application::touchEndEvent(QTouchEvent* event) { · 29 unmodified lines
1713 _keyboardMouseDevice.touchEndEvent(event);1693 _keyboardMouseDevice.touchEndEvent(event);
1714 1694
1715 // put any application specific touch behavior below here..1695 // put any application specific touch behavior below here..
1716 _touchDragStartedAvgX = _touchAvgX;1696 _touchDragStartedAvg = _touchAvg;
1717 _touchDragStartedAvgY = _touchAvgY;
1718 _isTouchPressed = false;1697 _isTouchPressed = false;
1719 1698
1720}1699}
@@ -1863,9 +1842,9 @@ void Application::setFullscreen(bool fullscreen) { · 142 unmodified lines
1863 Menu::getInstance()->getActionForOption(MenuOption::Fullscreen)->setChecked(fullscreen);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 visible1845 // 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 the1846 // app menu in a fullscreen window. However the OSX mechanism hides the
1868// application menu for fullscreen apps, so the check is not required.1847 // application menu for fullscreen apps, so the check is not required.
1869#ifndef Q_OS_MAC1848#ifndef Q_OS_MAC
1870 if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) {1849 if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) {
1871 if (fullscreen) {1850 if (fullscreen) {
@@ -1939,11 +1918,6 @@ void Application::setEnableVRMode(bool enableVRMode) { · 67 unmodified lines
1939 } else {1918 } else {
1940 OculusManager::abandonCalibration();1919 OculusManager::abandonCalibration();
1941 OculusManager::disconnect();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 resizeGL();1923 resizeGL();
@@ -1955,44 +1929,34 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { · 5 unmodified lines
1955 1929
1956bool Application::mouseOnScreen() const {1930bool Application::mouseOnScreen() const {
1957 if (OculusManager::isConnected()) {1931 if (OculusManager::isConnected()) {
1958 return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() &&1932 ivec2 mouse = getMouse();
1959 getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight();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 return true;1941 return true;
1962}1942}
1963 1943
1964int Application::getMouseX() const {1944ivec2 Application::getMouse() 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
1972int Application::getMouseY() const {
1973 if (OculusManager::isConnected()) {1945 if (OculusManager::isConnected()) {
1974 glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY()));1946 return _compositor.screenToOverlay(getTrueMouse());
1975 return pos.y;
1976 }1947 }
1977 return getTrueMouseY();1948 return getTrueMouse();
1978}1949}
1979 1950
1980int Application::getMouseDragStartedX() const {1951ivec2 Application::getMouseDragStarted() const {
1981 if (OculusManager::isConnected()) {1952 if (OculusManager::isConnected()) {
1982 glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(),1953 return _compositor.screenToOverlay(getTrueMouseDragStarted());
1983 getTrueMouseDragStartedY()));
1984 return pos.x;
1985 }1954 }
1986 return getTrueMouseDragStartedX();1955 return getTrueMouseDragStarted();
1987}1956}
1988 1957
1989int Application::getMouseDragStartedY() const {1958ivec2 Application::getTrueMouseDragStarted() const {
1990 if (OculusManager::isConnected()) {1959 return _mouseDragStarted;
1991 glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(),
1992 getTrueMouseDragStartedY()));
1993 return pos.y;
1994 }
1995 return getTrueMouseDragStartedY();
1996}1960}
1997 1961
1998FaceTracker* Application::getActiveFaceTracker() {1962FaceTracker* Application::getActiveFaceTracker() {
@@ -2237,13 +2201,6 @@ void Application::init() { · 238 unmodified lines
2237 _entityClipboardRenderer.setViewFrustum(getViewFrustum());2201 _entityClipboardRenderer.setViewFrustum(getViewFrustum());
2238 _entityClipboardRenderer.setTree(&_entityClipboard);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 // initialize the GlowEffect with our widget2204 // initialize the GlowEffect with our widget
2248 bool glow = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect);2205 bool glow = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect);
2249 DependencyManager::get<GlowEffect>()->init(glow);2206 DependencyManager::get<GlowEffect>()->init(glow);
@@ -2408,13 +2365,23 @@ void Application::cameraMenuChanged() { · 158 unmodified lines
2408 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);2365 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
2409 _myAvatar->setBoomLength(MyAvatar::ZOOM_MIN);2366 _myAvatar->setBoomLength(MyAvatar::ZOOM_MIN);
2410 }2367 }
2411 } else {2368 } else if (Menu::getInstance()->isOptionChecked(MenuOption::ThirdPerson)) {
2412 if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) {2369 if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) {
2413 _myCamera.setMode(CAMERA_MODE_THIRD_PERSON);2370 _myCamera.setMode(CAMERA_MODE_THIRD_PERSON);
2414 if (_myAvatar->getBoomLength() == MyAvatar::ZOOM_MIN) {2371 if (_myAvatar->getBoomLength() == MyAvatar::ZOOM_MIN) {
2415 _myAvatar->setBoomLength(MyAvatar::ZOOM_DEFAULT);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
2382void 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 // Transfer the user inputs to the driveKeys2470 // Transfer the user inputs to the driveKeys
2504 _myAvatar->clearDriveKeys();2471 _myAvatar->clearDriveKeys();
2505 _myAvatar->setDriveKeys(FWD, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_FORWARD));2472 if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {
2506 _myAvatar->setDriveKeys(BACK, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_BACKWARD));2473 if (!_controllerScriptingInterface.areActionsCaptured()) {
2507 _myAvatar->setDriveKeys(UP, _userInputMapper.getActionState(UserInputMapper::VERTICAL_UP));2474 _myAvatar->setDriveKeys(FWD, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_FORWARD));
2508 _myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN));2475 _myAvatar->setDriveKeys(BACK, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_BACKWARD));
2509 _myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT));2476 _myAvatar->setDriveKeys(UP, _userInputMapper.getActionState(UserInputMapper::VERTICAL_UP));
2510 _myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT));2477 _myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN));
2511 _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP));2478 _myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT));
2512 _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN));2479 _myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT));
2513 _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT));2480 _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP));
2514 _myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT));2481 _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN));
2515 _myAvatar->setDriveKeys(BOOM_IN, _userInputMapper.getActionState(UserInputMapper::BOOM_IN));2482 _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT));
2516 _myAvatar->setDriveKeys(BOOM_OUT, _userInputMapper.getActionState(UserInputMapper::BOOM_OUT));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 updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...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 _entitySimulation.lock();2502 _entitySimulation.lock();
2532 _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());2503 _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());
2504 _entitySimulation.unlock();
2505
2506 _entities.getTree()->lockForWrite();
2507 _entitySimulation.lock();
2533 _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());2508 _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());
2509 _entitySimulation.unlock();
2510 _entities.getTree()->unlock();
2511
2512 _entities.getTree()->lockForWrite();
2513 _entitySimulation.lock();
2534 _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());2514 _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());
2515 _entitySimulation.unlock();
2516 _entities.getTree()->unlock();
2517
2518 _entitySimulation.lock();
2535 _entitySimulation.applyActionChanges();2519 _entitySimulation.applyActionChanges();
2536 _entitySimulation.unlock();2520 _entitySimulation.unlock();
2537 2521
2522
2538 AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();2523 AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();
2539 _physicsEngine.deleteObjects(avatarManager->getObjectsToDelete());2524 _physicsEngine.deleteObjects(avatarManager->getObjectsToDelete());
2540 _physicsEngine.addObjects(avatarManager->getObjectsToAdd());2525 _physicsEngine.addObjects(avatarManager->getObjectsToAdd());
2541 _physicsEngine.changeObjects(avatarManager->getObjectsToChange());2526 _physicsEngine.changeObjects(avatarManager->getObjectsToChange());
2542 2527
2528 _entities.getTree()->lockForWrite();
2543 _physicsEngine.stepSimulation();2529 _physicsEngine.stepSimulation();
2530 _entities.getTree()->unlock();
2544 2531
2545 if (_physicsEngine.hasOutgoingChanges()) {2532 if (_physicsEngine.hasOutgoingChanges()) {
2533 _entities.getTree()->lockForWrite();
2546 _entitySimulation.lock();2534 _entitySimulation.lock();
2547 _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges(), _physicsEngine.getSessionID());2535 _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges(), _physicsEngine.getSessionID());
2548 _entitySimulation.unlock();2536 _entitySimulation.unlock();
2537 _entities.getTree()->unlock();
2549 2538
2539 _entities.getTree()->lockForWrite();
2550 avatarManager->handleOutgoingChanges(_physicsEngine.getOutgoingChanges());2540 avatarManager->handleOutgoingChanges(_physicsEngine.getOutgoingChanges());
2541 _entities.getTree()->unlock();
2542
2551 auto collisionEvents = _physicsEngine.getCollisionEvents();2543 auto collisionEvents = _physicsEngine.getCollisionEvents();
2552 avatarManager->handleCollisionEvents(collisionEvents);2544 avatarManager->handleCollisionEvents(collisionEvents);
2553 2545
@@ -3137,7 +3129,7 @@ PickRay Application::computePickRay(float x, float y) const { · 583 unmodified lines
3137 y /= size.y;3129 y /= size.y;
3138 PickRay result;3130 PickRay result;
3139 if (isHMDMode()) {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 } else {3133 } else {
3142 if (QThread::currentThread() == activeRenderingThread) {3134 if (QThread::currentThread() == activeRenderingThread) {
3143 getDisplayViewFrustum()->computePickRay(x, y, result.origin, result.direction);3135 getDisplayViewFrustum()->computePickRay(x, y, result.origin, result.direction);
@@ -3166,13 +3158,11 @@ QImage Application::renderAvatarBillboard(RenderArgs* renderArgs) { · 22 unmodified lines
3166 renderRearViewMirror(renderArgs, QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE,3158 renderRearViewMirror(renderArgs, QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE,
3167 BILLBOARD_SIZE, BILLBOARD_SIZE),3159 BILLBOARD_SIZE, BILLBOARD_SIZE),
3168 true);3160 true);
3169
3170 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);3161 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
3171 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());3162 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
3172 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);3163 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3173 3164
3174 glBindFramebuffer(GL_FRAMEBUFFER, 0);3165 glBindFramebuffer(GL_FRAMEBUFFER, 0);
3175
3176 return image;3166 return image;
3177}3167}
3178 3168
@@ -3357,6 +3347,11 @@ namespace render { · 178 unmodified lines
3357 3347
3358 3348
3359void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool selfAvatarOnly, bool billboard) {3349void 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 activeRenderingThread = QThread::currentThread();3355 activeRenderingThread = QThread::currentThread();
3361 PROFILE_RANGE(__FUNCTION__);3356 PROFILE_RANGE(__FUNCTION__);
3362 PerformanceTimer perfTimer("display");3357 PerformanceTimer perfTimer("display");
@@ -3368,9 +3363,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 5 unmodified lines
3368 3363
3369 // flip x if in mirror mode (also requires reversing winding order for backface culling)3364 // flip x if in mirror mode (also requires reversing winding order for backface culling)
3370 if (theCamera.getMode() == CAMERA_MODE_MIRROR) {3365 if (theCamera.getMode() == CAMERA_MODE_MIRROR) {
3371 glScalef(-1.0f, 1.0f, 1.0f);3366 //glScalef(-1.0f, 1.0f, 1.0f);
3372 glFrontFace(GL_CW);3367 //glFrontFace(GL_CW);
3373
3374 } else {3368 } else {
3375 glFrontFace(GL_CCW);3369 glFrontFace(GL_CCW);
3376 }3370 }
@@ -3393,7 +3387,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 16 unmodified lines
3393 viewTransform.setTranslation(theCamera.getPosition());3387 viewTransform.setTranslation(theCamera.getPosition());
3394 viewTransform.setRotation(rotation);3388 viewTransform.setRotation(rotation);
3395 if (theCamera.getMode() == CAMERA_MODE_MIRROR) {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 if (renderArgs->_renderSide != RenderArgs::MONO) {3392 if (renderArgs->_renderSide != RenderArgs::MONO) {
3399 glm::mat4 invView = glm::inverse(_untranslatedViewMatrix);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 renderContext._maxDrawnOpaqueItems = sceneInterface->getEngineMaxDrawnOpaqueItems();3525 renderContext._maxDrawnOpaqueItems = sceneInterface->getEngineMaxDrawnOpaqueItems();
3532 renderContext._maxDrawnTransparentItems = sceneInterface->getEngineMaxDrawnTransparentItems();3526 renderContext._maxDrawnTransparentItems = sceneInterface->getEngineMaxDrawnTransparentItems();
3527 renderContext._maxDrawnOverlay3DItems = sceneInterface->getEngineMaxDrawnOverlay3DItems();
3533 3528
3534 renderArgs->_shouldRender = LODManager::shouldRender;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 sceneInterface->setEngineFeedTransparentItems(engineRC->_numFeedTransparentItems);3542 sceneInterface->setEngineFeedTransparentItems(engineRC->_numFeedTransparentItems);
3548 sceneInterface->setEngineDrawnTransparentItems(engineRC->_numDrawnTransparentItems);3543 sceneInterface->setEngineDrawnTransparentItems(engineRC->_numDrawnTransparentItems);
3549 3544
3545 sceneInterface->setEngineFeedOverlay3DItems(engineRC->_numFeedOverlay3DItems);
3546 sceneInterface->setEngineDrawnOverlay3DItems(engineRC->_numDrawnOverlay3DItems);
3550 }3547 }
3551 //Render the sixense lasers3548 //Render the sixense lasers
3552 if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) {3549 if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) {
@@ -3654,8 +3651,8 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 101 unmodified lines
3654 // +-----------------------+3651 // +-----------------------+
3655 // -1,-1 1,-13652 // -1,-1 1,-1
3656 3653
3657 glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale,3654 glm::vec2 screenPoint((projectedPoint.x + 1.0f) * horizontalScale,
3658 ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight());3655 ((projectedPoint.y + 1.0f) * -verticalScale) + _glWidget->getDeviceHeight());
3659 3656
3660 return screenPoint;3657 return screenPoint;
3661}3658}
@@ -3673,7 +3670,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 11 unmodified lines
3673 _mirrorCamera.setPosition(_myAvatar->getPosition() +3670 _mirrorCamera.setPosition(_myAvatar->getPosition() +
3674 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());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 _mirrorCamera.setPosition(_myAvatar->getChestPosition() +3674 _mirrorCamera.setPosition(_myAvatar->getChestPosition() +
3678 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());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 } else {3705 } else {
3709 // if not rendering the billboard, the region is in device independent coordinates; must convert to device3706 // if not rendering the billboard, the region is in device independent coordinates; must convert to device
3710 QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize();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 int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;3709 int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
3713 glViewport(x, size.height() - y - height, width, height);3710 glViewport(x, size.height() - y - height, width, height);
3714 glScissor(x, size.height() - y - height, width, height);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 displaySide(renderArgs, _mirrorCamera, true, billboard);3720 displaySide(renderArgs, _mirrorCamera, true, billboard);
3724 glPopMatrix();3721 glPopMatrix();
3725 3722
3726 if (!billboard) {
3727 _rearMirrorTools->render(renderArgs, false, _glWidget->mapFromGlobal(QCursor::pos()));
3728 }
3729
3730 // reset Viewport and projection matrix3723 // reset Viewport and projection matrix
3731 glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);3724 glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
3732 glDisable(GL_SCISSOR_TEST);3725 glDisable(GL_SCISSOR_TEST);
@@ -3866,7 +3859,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 133 unmodified lines
3866 _entityServerJurisdictions.unlock();3859 _entityServerJurisdictions.unlock();
3867 3860
3868 qCDebug(interfaceapp, "model server going away...... v[%f, %f, %f, %f]",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 // Add the jurisditionDetails object to the list of "fade outs"3864 // Add the jurisditionDetails object to the list of "fade outs"
3872 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) {3865 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) {
@@ -3952,7 +3945,8 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin · 79 unmodified lines
3952 jurisdiction->unlock();3945 jurisdiction->unlock();
3953 3946
3954 qCDebug(interfaceapp, "stats from new %s server... [%f, %f, %f, %f]",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 // Add the jurisditionDetails object to the list of "fade outs"3951 // Add the jurisditionDetails object to the list of "fade outs"
3958 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) {3952 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnOctreeServerChanges)) {
@@ -4059,6 +4053,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 100 unmodified lines
4059 connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(scriptFinished(const QString&)));4053 connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(scriptFinished(const QString&)));
4060 4054
4061 connect(scriptEngine, SIGNAL(loadScript(const QString&, bool)), this, SLOT(loadScript(const QString&, bool)));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 scriptEngine->registerGlobalObject("Overlays", &_overlays);4058 scriptEngine->registerGlobalObject("Overlays", &_overlays);
4064 qScriptRegisterMetaType(scriptEngine, OverlayPropertyResultToScriptValue, OverlayPropertyResultFromScriptValue);4059 qScriptRegisterMetaType(scriptEngine, OverlayPropertyResultToScriptValue, OverlayPropertyResultFromScriptValue);
@@ -4274,7 +4269,7 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { · 209 unmodified lines
4274}4269}
4275 4270
4276ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUserLoaded,4271ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUserLoaded,
4277 bool loadScriptFromEditor, bool activateMainWindow) {4272 bool loadScriptFromEditor, bool activateMainWindow, bool reload) {
4278 4273
4279 if (isAboutToQuit()) {4274 if (isAboutToQuit()) {
4280 return NULL;4275 return NULL;
@@ -4303,7 +4298,7 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 22 unmodified lines
4303 connect(scriptEngine, &ScriptEngine::errorLoadingScript, this, &Application::handleScriptLoadError);4298 connect(scriptEngine, &ScriptEngine::errorLoadingScript, this, &Application::handleScriptLoadError);
4304 4299
4305 // get the script engine object to load the script at the designated script URL4300 // 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 // restore the main window's active state4304 // restore the main window's active state
@@ -4314,6 +4309,10 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 4 unmodified lines
4314 return scriptEngine;4309 return scriptEngine;
4315}4310}
4316 4311
4312void Application::reloadScript(const QString& scriptName, bool isUserLoaded) {
4313 loadScript(scriptName, isUserLoaded, false, false, true);
4314}
4315
4317void Application::handleScriptEngineLoaded(const QString& scriptFilename) {4316void Application::handleScriptEngineLoaded(const QString& scriptFilename) {
4318 ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(sender());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
4343void Application::stopAllScripts(bool restart) {4342void Application::stopAllScripts(bool restart) {
4344 // stops all current running scripts4343 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 for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();4355 for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
4346 it != _scriptEnginesHash.constEnd(); it++) {4356 it != _scriptEnginesHash.constEnd(); it++) {
4347 if (it.value()->isFinished()) {4357 if (it.value()->isFinished()) {
4348 continue;4358 continue;
4349 }4359 }
4350 if (restart && it.value()->isUserLoaded()) {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 it.value()->stop();4363 it.value()->stop();
4354 qCDebug(interfaceapp) << "stopping script..." << it.key();4364 qCDebug(interfaceapp) << "stopping script..." << it.key();
@@ -4356,13 +4366,20 @@ void Application::stopAllScripts(bool restart) { · 1 unmodified line
4356 // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities4366 // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities
4357 // whenever a script stops in case it happened to have been setting joint rotations.4367 // whenever a script stops in case it happened to have been setting joint rotations.
4358 // TODO: expose animation priorities and provide a layered animation control system.4368 // TODO: expose animation priorities and provide a layered animation control system.
4369 _myAvatar->clearJointAnimationPriorities();
4359 _myAvatar->clearScriptableSettings();4370 _myAvatar->clearScriptableSettings();
4360}4371}
4361 4372
4362void Application::stopScript(const QString &scriptName) {4373void Application::stopScript(const QString &scriptName, bool restart) {
4363 const QString& scriptURLString = QUrl(scriptName).toString();4374 const QString& scriptURLString = QUrl(scriptName).toString();
4364 if (_scriptEnginesHash.contains(scriptURLString)) {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 qCDebug(interfaceapp) << "stopping script..." << scriptName;4383 qCDebug(interfaceapp) << "stopping script..." << scriptName;
4367 // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities4384 // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities
4368 // whenever a script stops in case it happened to have been setting joint rotations.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 stopAllScripts(true);4395 stopAllScripts(true);
4379}4396}
4380 4397
4398void Application::reloadOneScript(const QString& scriptName) {
4399 stopScript(scriptName, true);
4400}
4401
4381void Application::loadDefaultScripts() {4402void Application::loadDefaultScripts() {
4382 if (!_scriptEnginesHash.contains(DEFAULT_SCRIPTS_JS_URL)) {4403 if (!_scriptEnginesHash.contains(DEFAULT_SCRIPTS_JS_URL)) {
4383 loadScript(DEFAULT_SCRIPTS_JS_URL);4404 loadScript(DEFAULT_SCRIPTS_JS_URL);
@@ -4732,11 +4753,9 @@ void Application::postLambdaEvent(std::function<void()> f) { · 348 unmodified lines
4732}4753}
4733 4754
4734void Application::initPlugins() {4755void Application::initPlugins() {
4735 OculusManager::init();
4736}4756}
4737 4757
4738void Application::shutdownPlugins() {4758void Application::shutdownPlugins() {
4739 OculusManager::deinit();
4740}4759}
4741 4760
4742glm::vec3 Application::getHeadPosition() const {4761glm::vec3 Application::getHeadPosition() const {
@@ -4756,12 +4775,8 @@ QSize Application::getDeviceSize() const { · 13 unmodified lines
4756 return _glWidget->getDeviceSize();4775 return _glWidget->getDeviceSize();
4757}4776}
4758 4777
4759int Application::getTrueMouseX() const {4778ivec2 Application::getTrueMouse() const {
4760 return _glWidget->mapFromGlobal(QCursor::pos()).x();4779 return toGlm(_glWidget->mapFromGlobal(QCursor::pos()));
4761}
4762
4763int Application::getTrueMouseY() const {
4764 return _glWidget->mapFromGlobal(QCursor::pos()).y();
4765}4780}
4766 4781
4767bool Application::isThrottleRendering() const {4782bool Application::isThrottleRendering() const {
@@ -4791,3 +4806,25 @@ qreal Application::getDevicePixelRatio() { · 23 unmodified lines
4791 return _window ? _window->windowHandle()->devicePixelRatio() : 1.0;4806 return _window ? _window->windowHandle()->devicePixelRatio() : 1.0;
4792}4807}
4793 4808
4809mat4 Application::getEyeProjection(int eye) const {
4810 if (isHMDMode()) {
4811 return OculusManager::getEyeProjection(eye);
4812 }
4813
4814 return _viewFrustum.getProjection();
4815}
4816
4817mat4 Application::getEyePose(int eye) const {
4818 if (isHMDMode()) {
4819 return OculusManager::getEyePose(eye);
4820 }
4821
4822 return mat4();
4823}
4824
4825mat4 Application::getHeadPose() const {
4826 if (isHMDMode()) {
4827 return OculusManager::getHeadPose();
4828 }
4829 return mat4();
4830}