History

resolve conflicts on merge with upstream master

Stephen Birarda committed 11 years ago

Commit 5c3e90f2 parents 5e3e363 f0b0c5f337 files · +22516 −13528Browse files

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

Unified · Split

interface/src/Application.cpp+192−126
@@ -65,6 +65,7 @@ · 64 unmodified lines
65#include <PacketHeaders.h>65#include <PacketHeaders.h>
66#include <PerfStat.h>66#include <PerfStat.h>
67#include <ResourceCache.h>67#include <ResourceCache.h>
68#include <SoundCache.h>
68#include <UserActivityLogger.h>69#include <UserActivityLogger.h>
69#include <UUID.h>70#include <UUID.h>
70 71
@@ -92,6 +93,7 @@ · 21 unmodified lines
92#include "scripting/MenuScriptingInterface.h"93#include "scripting/MenuScriptingInterface.h"
93#include "scripting/SettingsScriptingInterface.h"94#include "scripting/SettingsScriptingInterface.h"
94#include "scripting/WindowScriptingInterface.h"95#include "scripting/WindowScriptingInterface.h"
96#include "scripting/WebWindowClass.h"
95 97
96#include "ui/DataWebDialog.h"98#include "ui/DataWebDialog.h"
97#include "ui/InfoView.h"99#include "ui/InfoView.h"
@@ -108,7 +110,8 @@ static unsigned STARFIELD_SEED = 1; · 10 unmodified lines
108 110
109static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored111static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
110 112
111const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB113
114const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
112 115
113static QTimer* idleTimer = NULL;116static QTimer* idleTimer = NULL;
114 117
@@ -121,7 +124,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 6 unmodified lines
121 QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);124 QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
122 125
123 if (!logMessage.isEmpty()) {126 if (!logMessage.isEmpty()) {
124 Application::getInstance()->getLogger()->addMessage(qPrintable(logMessage));127 Application::getInstance()->getLogger()->addMessage(qPrintable(logMessage + "\n"));
125 }128 }
126}129}
127 130
@@ -158,6 +161,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 30 unmodified lines
158 _lastQueriedViewFrustum(),161 _lastQueriedViewFrustum(),
159 _lastQueriedTime(usecTimestampNow()),162 _lastQueriedTime(usecTimestampNow()),
160 _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),163 _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
164 _viewTransform(),
161 _scaleMirror(1.0f),165 _scaleMirror(1.0f),
162 _rotateMirror(0.0f),166 _rotateMirror(0.0f),
163 _raiseMirror(0.0f),167 _raiseMirror(0.0f),
@@ -369,6 +373,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 205 unmodified lines
369 // enable mouse tracking; otherwise, we only get drag events373 // enable mouse tracking; otherwise, we only get drag events
370 _glWidget->setMouseTracking(true);374 _glWidget->setMouseTracking(true);
371 375
376 _toolWindow = new ToolWindow();
377 _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
378 _toolWindow->setWindowTitle("Tools");
379
372 // initialization continues in initializeGL when OpenGL context is ready380 // initialization continues in initializeGL when OpenGL context is ready
373 381
374 // Tell our voxel edit sender about our known jurisdictions382 // Tell our voxel edit sender about our known jurisdictions
@@ -417,7 +425,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 42 unmodified lines
417 _trayIcon->show();425 _trayIcon->show();
418 426
419 // set the local loopback interface for local sounds from audio scripts427 // set the local loopback interface for local sounds from audio scripts
420 AudioScriptingInterface::getInstance().setLocalLoopbackInterface(&_audio);428 AudioScriptingInterface::getInstance().setLocalAudioInterface(&_audio);
421 429
422#ifdef HAVE_RTMIDI430#ifdef HAVE_RTMIDI
423 // setup the MIDIManager431 // setup the MIDIManager
@@ -430,6 +438,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 6 unmodified lines
430 438
431void Application::aboutToQuit() {439void Application::aboutToQuit() {
432 _aboutToQuit = true;440 _aboutToQuit = true;
441 setFullscreen(false); // if you exit while in full screen, you'll get bad behavior when you restart.
433}442}
434 443
435Application::~Application() {444Application::~Application() {
@@ -453,23 +462,22 @@ Application::~Application() { · 17 unmodified lines
453 // ask the datagram processing thread to quit and wait until it is done462 // ask the datagram processing thread to quit and wait until it is done
454 _nodeThread->quit();463 _nodeThread->quit();
455 _nodeThread->wait();464 _nodeThread->wait();
465
466 // kill any audio injectors that are still around
467 AudioScriptingInterface::getInstance().stopAllInjectors();
456 468
457 // stop the audio process469 // stop the audio process
458 QMetaObject::invokeMethod(&_audio, "stop");470 QMetaObject::invokeMethod(&_audio, "stop");
459 471
460 // ask the audio thread to quit and wait until it is done472 // ask the audio thread to quit and wait until it is done
461 _audio.thread()->quit();473 _audio.thread()->quit();
462 _audio.thread()->wait();474 _audio.thread()->wait();
463
464 // kill any audio injectors that are still around
465 AudioScriptingInterface::getInstance().stopAllInjectors();
466 475
467 _octreeProcessor.terminate();476 _octreeProcessor.terminate();
468 _voxelHideShowThread.terminate();477 _voxelHideShowThread.terminate();
469 _voxelEditSender.terminate();478 _voxelEditSender.terminate();
470 _entityEditSender.terminate();479 _entityEditSender.terminate();
471 480
472
473 VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown481 VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
474 Menu::getInstance()->deleteLater();482 Menu::getInstance()->deleteLater();
475 483
@@ -597,7 +605,7 @@ void Application::initializeGL() { · 121 unmodified lines
597 }605 }
598 606
599 // update before the first render607 // update before the first render
600 update(1.f / _fps);608 update(1.0f / _fps);
601 609
602 InfoView::showFirstTime(INFO_HELP_PATH);610 InfoView::showFirstTime(INFO_HELP_PATH);
603}611}
@@ -643,25 +651,16 @@ void Application::paintGL() { · 39 unmodified lines
643 }651 }
644 652
645 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {653 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
646 //Only behave like a true mirror when in the OR654 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
647 if (OculusManager::isConnected()) {655 _myCamera.setPosition(_myAvatar->getDefaultEyePosition() +
648 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));656 glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) +
649 _myCamera.setPosition(_myAvatar->getHead()->getEyePosition() +657 (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
650 glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) +658 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
651 (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
652 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
653 } else {
654 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
655 _myCamera.setPosition(_myAvatar->getHead()->getEyePosition() +
656 glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) +
657 (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
658 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
659 }
660 }659 }
661 660
662 // Update camera position661 // Update camera position
663 if (!OculusManager::isConnected()) {662 if (!OculusManager::isConnected()) {
664 _myCamera.update(1.f / _fps);663 _myCamera.update(1.0f / _fps);
665 }664 }
666 665
667 // Note: whichCamera is used to pick between the normal camera myCamera for our666 // Note: whichCamera is used to pick between the normal camera myCamera for our
@@ -686,7 +685,7 @@ void Application::paintGL() { · 18 unmodified lines
686 685
687 _viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation);686 _viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation);
688 687
689 _viewFrustumOffsetCamera.update(1.f/_fps);688 _viewFrustumOffsetCamera.update(1.0f/_fps);
690 whichCamera = &_viewFrustumOffsetCamera;689 whichCamera = &_viewFrustumOffsetCamera;
691 }690 }
692 691
@@ -705,7 +704,7 @@ void Application::paintGL() { · 12 unmodified lines
705 } else {704 } else {
706 OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), *whichCamera);705 OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), *whichCamera);
707 }706 }
708 _myCamera.update(1.f / _fps);707 _myCamera.update(1.0f / _fps);
709 708
710 } else if (TV3DManager::isConnected()) {709 } else if (TV3DManager::isConnected()) {
711 710
@@ -724,11 +723,11 @@ void Application::paintGL() { · 12 unmodified lines
724 displaySide(*whichCamera);723 displaySide(*whichCamera);
725 glPopMatrix();724 glPopMatrix();
726 725
727 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {726 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
728 renderRearViewMirror(_mirrorViewRect);
729
730 } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
731 _rearMirrorTools->render(true);727 _rearMirrorTools->render(true);
728
729 } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
730 renderRearViewMirror(_mirrorViewRect);
732 }731 }
733 732
734 _glowEffect.render();733 _glowEffect.render();
@@ -786,7 +785,7 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) · 51 unmodified lines
786 // Tell our viewFrustum about this change, using the application camera785 // Tell our viewFrustum about this change, using the application camera
787 if (updateViewFrustum) {786 if (updateViewFrustum) {
788 loadViewFrustum(camera, _viewFrustum);787 loadViewFrustum(camera, _viewFrustum);
789 computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);788 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
790 789
791 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the790 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
792 // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum791 // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum
@@ -843,7 +842,7 @@ bool Application::event(QEvent* event) { · 50 unmodified lines
843 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);842 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
844 843
845 if (!fileEvent->url().isEmpty()) {844 if (!fileEvent->url().isEmpty()) {
846 AddressManager::getInstance().handleLookupString(fileEvent->url().toLocalFile());845 AddressManager::getInstance().handleLookupString(fileEvent->url().toString());
847 }846 }
848 847
849 return false;848 return false;
@@ -911,7 +910,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 61 unmodified lines
911 if (!_myAvatar->getDriveKeys(UP)) {910 if (!_myAvatar->getDriveKeys(UP)) {
912 _myAvatar->jump();911 _myAvatar->jump();
913 }912 }
914 _myAvatar->setDriveKeys(UP, 1.f);913 _myAvatar->setDriveKeys(UP, 1.0f);
915 break;914 break;
916 915
917 case Qt::Key_Asterisk:916 case Qt::Key_Asterisk:
@@ -920,14 +919,14 @@ void Application::keyPressEvent(QKeyEvent* event) { · 2 unmodified lines
920 919
921 case Qt::Key_C:920 case Qt::Key_C:
922 case Qt::Key_PageDown:921 case Qt::Key_PageDown:
923 _myAvatar->setDriveKeys(DOWN, 1.f);922 _myAvatar->setDriveKeys(DOWN, 1.0f);
924 break;923 break;
925 924
926 case Qt::Key_W:925 case Qt::Key_W:
927 if (isOption && !isShifted && !isMeta) {926 if (isOption && !isShifted && !isMeta) {
928 Menu::getInstance()->triggerOption(MenuOption::Wireframe);927 Menu::getInstance()->triggerOption(MenuOption::Wireframe);
929 } else {928 } else {
930 _myAvatar->setDriveKeys(FWD, 1.f);929 _myAvatar->setDriveKeys(FWD, 1.0f);
931 }930 }
932 break;931 break;
933 932
@@ -939,7 +938,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines
939 } else if (!isOption && !isShifted && isMeta) {938 } else if (!isOption && !isShifted && isMeta) {
940 takeSnapshot();939 takeSnapshot();
941 } else {940 } else {
942 _myAvatar->setDriveKeys(BACK, 1.f);941 _myAvatar->setDriveKeys(BACK, 1.0f);
943 }942 }
944 break;943 break;
945 944
@@ -957,13 +956,13 @@ void Application::keyPressEvent(QKeyEvent* event) { · 11 unmodified lines
957 if (isShifted) {956 if (isShifted) {
958 Menu::getInstance()->triggerOption(MenuOption::Atmosphere);957 Menu::getInstance()->triggerOption(MenuOption::Atmosphere);
959 } else {958 } else {
960 _myAvatar->setDriveKeys(ROT_LEFT, 1.f);959 _myAvatar->setDriveKeys(ROT_LEFT, 1.0f);
961 }960 }
962 break;961 break;
963 962
964 case Qt::Key_D:963 case Qt::Key_D:
965 if (!isMeta) {964 if (!isMeta) {
966 _myAvatar->setDriveKeys(ROT_RIGHT, 1.f);965 _myAvatar->setDriveKeys(ROT_RIGHT, 1.0f);
967 }966 }
968 break;967 break;
969 968
@@ -991,7 +990,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 21 unmodified lines
991 _raiseMirror += 0.05f;990 _raiseMirror += 0.05f;
992 }991 }
993 } else {992 } else {
994 _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.f);993 _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.0f);
995 }994 }
996 break;995 break;
997 996
@@ -1003,23 +1002,23 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines
1003 _raiseMirror -= 0.05f;1002 _raiseMirror -= 0.05f;
1004 }1003 }
1005 } else {1004 } else {
1006 _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.f);1005 _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.0f);
1007 }1006 }
1008 break;1007 break;
1009 1008
1010 case Qt::Key_Left:1009 case Qt::Key_Left:
1011 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {1010 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
1012 _rotateMirror += PI / 20.f;1011 _rotateMirror += PI / 20.0f;
1013 } else {1012 } else {
1014 _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.f);1013 _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.0f);
1015 }1014 }
1016 break;1015 break;
1017 1016
1018 case Qt::Key_Right:1017 case Qt::Key_Right:
1019 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {1018 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
1020 _rotateMirror -= PI / 20.f;1019 _rotateMirror -= PI / 20.0f;
1021 } else {1020 } else {
1022 _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.f);1021 _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.0f);
1023 }1022 }
1024 break;1023 break;
1025 1024
@@ -1170,48 +1169,48 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 144 unmodified lines
1170 switch (event->key()) {1169 switch (event->key()) {
1171 case Qt::Key_E:1170 case Qt::Key_E:
1172 case Qt::Key_PageUp:1171 case Qt::Key_PageUp:
1173 _myAvatar->setDriveKeys(UP, 0.f);1172 _myAvatar->setDriveKeys(UP, 0.0f);
1174 break;1173 break;
1175 1174
1176 case Qt::Key_C:1175 case Qt::Key_C:
1177 case Qt::Key_PageDown:1176 case Qt::Key_PageDown:
1178 _myAvatar->setDriveKeys(DOWN, 0.f);1177 _myAvatar->setDriveKeys(DOWN, 0.0f);
1179 break;1178 break;
1180 1179
1181 case Qt::Key_W:1180 case Qt::Key_W:
1182 _myAvatar->setDriveKeys(FWD, 0.f);1181 _myAvatar->setDriveKeys(FWD, 0.0f);
1183 break;1182 break;
1184 1183
1185 case Qt::Key_S:1184 case Qt::Key_S:
1186 _myAvatar->setDriveKeys(BACK, 0.f);1185 _myAvatar->setDriveKeys(BACK, 0.0f);
1187 break;1186 break;
1188 1187
1189 case Qt::Key_A:1188 case Qt::Key_A:
1190 _myAvatar->setDriveKeys(ROT_LEFT, 0.f);1189 _myAvatar->setDriveKeys(ROT_LEFT, 0.0f);
1191 break;1190 break;
1192 1191
1193 case Qt::Key_D:1192 case Qt::Key_D:
1194 _myAvatar->setDriveKeys(ROT_RIGHT, 0.f);1193 _myAvatar->setDriveKeys(ROT_RIGHT, 0.0f);
1195 break;1194 break;
1196 1195
1197 case Qt::Key_Up:1196 case Qt::Key_Up:
1198 _myAvatar->setDriveKeys(FWD, 0.f);1197 _myAvatar->setDriveKeys(FWD, 0.0f);
1199 _myAvatar->setDriveKeys(UP, 0.f);1198 _myAvatar->setDriveKeys(UP, 0.0f);
1200 break;1199 break;
1201 1200
1202 case Qt::Key_Down:1201 case Qt::Key_Down:
1203 _myAvatar->setDriveKeys(BACK, 0.f);1202 _myAvatar->setDriveKeys(BACK, 0.0f);
1204 _myAvatar->setDriveKeys(DOWN, 0.f);1203 _myAvatar->setDriveKeys(DOWN, 0.0f);
1205 break;1204 break;
1206 1205
1207 case Qt::Key_Left:1206 case Qt::Key_Left:
1208 _myAvatar->setDriveKeys(LEFT, 0.f);1207 _myAvatar->setDriveKeys(LEFT, 0.0f);
1209 _myAvatar->setDriveKeys(ROT_LEFT, 0.f);1208 _myAvatar->setDriveKeys(ROT_LEFT, 0.0f);
1210 break;1209 break;
1211 1210
1212 case Qt::Key_Right:1211 case Qt::Key_Right:
1213 _myAvatar->setDriveKeys(RIGHT, 0.f);1212 _myAvatar->setDriveKeys(RIGHT, 0.0f);
1214 _myAvatar->setDriveKeys(ROT_RIGHT, 0.f);1213 _myAvatar->setDriveKeys(ROT_RIGHT, 0.0f);
1215 break;1214 break;
1216 case Qt::Key_Control:1215 case Qt::Key_Control:
1217 case Qt::Key_Shift:1216 case Qt::Key_Shift:
@@ -1515,7 +1514,7 @@ void Application::idle() { · 297 unmodified lines
1515 PerformanceTimer perfTimer("update");1514 PerformanceTimer perfTimer("update");
1516 PerformanceWarning warn(showWarnings, "Application::idle()... update()");1515 PerformanceWarning warn(showWarnings, "Application::idle()... update()");
1517 const float BIGGEST_DELTA_TIME_SECS = 0.25f;1516 const float BIGGEST_DELTA_TIME_SECS = 0.25f;
1518 update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));1517 update(glm::clamp((float)timeSinceLastUpdate / 1000.0f, 0.0f, BIGGEST_DELTA_TIME_SECS));
1519 }1518 }
1520 {1519 {
1521 PerformanceTimer perfTimer("updateGL");1520 PerformanceTimer perfTimer("updateGL");
@@ -1534,11 +1533,6 @@ void Application::idle() { · 12 unmodified lines
1534 _idleLoopStdev.reset();1533 _idleLoopStdev.reset();
1535 }1534 }
1536 1535
1537 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
1538 PerformanceTimer perfTimer("buckyBalls");
1539 _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
1540 }
1541
1542 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.1536 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
1543 idleTimer->start(2);1537 idleTimer->start(2);
1544 1538
@@ -1553,6 +1547,8 @@ void Application::checkBandwidthMeterClick() { · 8 unmodified lines
1553 // ... to be called upon button release1547 // ... to be called upon button release
1554 1548
1555 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&1549 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
1550 Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
1551 Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
1556 glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY)))1552 glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY)))
1557 <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH1553 <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
1558 && _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) {1554 && _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) {
@@ -1564,6 +1560,10 @@ void Application::checkBandwidthMeterClick() { · 5 unmodified lines
1564}1560}
1565 1561
1566void Application::setFullscreen(bool fullscreen) {1562void Application::setFullscreen(bool fullscreen) {
1563 if (Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen) != fullscreen) {
1564 Menu::getInstance()->getActionForOption(MenuOption::Fullscreen)->setChecked(fullscreen);
1565 }
1566
1567 if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) {1567 if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) {
1568 if (fullscreen) {1568 if (fullscreen) {
1569 // Menu show() after hide() doesn't work with Rift VR display so set height instead.1569 // Menu show() after hide() doesn't work with Rift VR display so set height instead.
@@ -1574,6 +1574,9 @@ void Application::setFullscreen(bool fullscreen) { · 4 unmodified lines
1574 }1574 }
1575 _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) :1575 _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) :
1576 (_window->windowState() & ~Qt::WindowFullScreen));1576 (_window->windowState() & ~Qt::WindowFullScreen));
1577 if (!_aboutToQuit) {
1578 _window->show();
1579 }
1577}1580}
1578 1581
1579void Application::setEnable3DTVMode(bool enable3DTVMode) {1582void Application::setEnable3DTVMode(bool enable3DTVMode) {
@@ -1581,6 +1584,10 @@ void Application::setEnable3DTVMode(bool enable3DTVMode) { · 1 unmodified line
1581}1584}
1582 1585
1583void Application::setEnableVRMode(bool enableVRMode) {1586void Application::setEnableVRMode(bool enableVRMode) {
1587 if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) != enableVRMode) {
1588 Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(enableVRMode);
1589 }
1590
1584 if (enableVRMode) {1591 if (enableVRMode) {
1585 if (!OculusManager::isConnected()) {1592 if (!OculusManager::isConnected()) {
1586 // attempt to reconnect the Oculus manager - it's possible this was a workaround1593 // attempt to reconnect the Oculus manager - it's possible this was a workaround
@@ -1591,6 +1598,11 @@ void Application::setEnableVRMode(bool enableVRMode) { · 4 unmodified lines
1591 OculusManager::recalibrate();1598 OculusManager::recalibrate();
1592 } else {1599 } else {
1593 OculusManager::abandonCalibration();1600 OculusManager::abandonCalibration();
1601
1602 _mirrorCamera.setHmdPosition(glm::vec3());
1603 _mirrorCamera.setHmdRotation(glm::quat());
1604 _myCamera.setHmdPosition(glm::vec3());
1605 _myCamera.setHmdRotation(glm::quat());
1594 }1606 }
1595 1607
1596 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());1608 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
@@ -1649,8 +1661,8 @@ void Application::makeVoxel(glm::vec3 position, · 52 unmodified lines
1649 }1661 }
1650 1662
1651glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {1663glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {
1652 return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.f) * TREE_SCALE,1664 return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.0f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.0f) * TREE_SCALE,
1653 (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE);1665 (mouseVoxel.z + mouseVoxel.s / 2.0f) * TREE_SCALE);
1654}1666}
1655 1667
1656FaceTracker* Application::getActiveFaceTracker() {1668FaceTracker* Application::getActiveFaceTracker() {
@@ -1863,7 +1875,7 @@ void Application::init() { · 206 unmodified lines
1863 3.0f * TREE_SCALE / 2.0f));1875 3.0f * TREE_SCALE / 2.0f));
1864 _sharedVoxelSystemViewFrustum.setNearClip(TREE_SCALE / 2.0f);1876 _sharedVoxelSystemViewFrustum.setNearClip(TREE_SCALE / 2.0f);
1865 _sharedVoxelSystemViewFrustum.setFarClip(3.0f * TREE_SCALE / 2.0f);1877 _sharedVoxelSystemViewFrustum.setFarClip(3.0f * TREE_SCALE / 2.0f);
1866 _sharedVoxelSystemViewFrustum.setFieldOfView(90.f);1878 _sharedVoxelSystemViewFrustum.setFieldOfView(90.0f);
1867 _sharedVoxelSystemViewFrustum.setOrientation(glm::quat());1879 _sharedVoxelSystemViewFrustum.setOrientation(glm::quat());
1868 _sharedVoxelSystemViewFrustum.calculate();1880 _sharedVoxelSystemViewFrustum.calculate();
1869 _sharedVoxelSystem.setViewFrustum(&_sharedVoxelSystemViewFrustum);1881 _sharedVoxelSystem.setViewFrustum(&_sharedVoxelSystemViewFrustum);
@@ -1922,11 +1934,14 @@ void Application::init() { · 52 unmodified lines
1922 // check if we have a URL in settings to load to jump back to1934 // check if we have a URL in settings to load to jump back to
1923 // we load this separate from the other settings so we don't double lookup a URL1935 // we load this separate from the other settings so we don't double lookup a URL
1924 QSettings* interfaceSettings = lockSettings();1936 QSettings* interfaceSettings = lockSettings();
1925 QUrl addressURL = interfaceSettings->value(SETTINGS_ADDRESS_KEY).toUrl();1937 QVariant addressVariant = interfaceSettings->value(SETTINGS_ADDRESS_KEY);
1926 1938
1927 AddressManager::getInstance().handleLookupString(addressURL.toString());1939 QString addressString = addressVariant.isNull()
1940 ? DEFAULT_HIFI_ADDRESS : addressVariant.toUrl().toString();
1928 1941
1929 unlockSettings();1942 unlockSettings();
1943
1944 AddressManager::getInstance().handleLookupString(addressString);
1930 }1945 }
1931 1946
1932 qDebug() << "Loaded settings";1947 qDebug() << "Loaded settings";
@@ -2009,25 +2024,17 @@ void Application::init() { · 76 unmodified lines
2009 2024
2010void Application::closeMirrorView() {2025void Application::closeMirrorView() {
2011 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {2026 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2012 Menu::getInstance()->triggerOption(MenuOption::Mirror);;2027 Menu::getInstance()->triggerOption(MenuOption::Mirror);
2013 }2028 }
2014}2029}
2015 2030
2016void Application::restoreMirrorView() {2031void Application::restoreMirrorView() {
2017 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2018 Menu::getInstance()->triggerOption(MenuOption::Mirror);;
2019 }
2020
2021 if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {2032 if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
2022 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);2033 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
2023 }2034 }
2024}2035}
2025 2036
2026void Application::shrinkMirrorView() {2037void Application::shrinkMirrorView() {
2027 if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2028 Menu::getInstance()->triggerOption(MenuOption::Mirror);;
2029 }
2030
2031 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {2038 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
2032 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);2039 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
2033 }2040 }
@@ -2164,7 +2171,7 @@ void Application::updateMyAvatarLookAtPosition() { · 130 unmodified lines
2164 } else {2171 } else {
2165 // I am not looking at anyone else, so just look forward2172 // I am not looking at anyone else, so just look forward
2166 lookAtSpot = _myAvatar->getHead()->getEyePosition() +2173 lookAtSpot = _myAvatar->getHead()->getEyePosition() +
2167 (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.f, 0.f, -TREE_SCALE));2174 (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
2168 }2175 }
2169 }2176 }
2170 //2177 //
@@ -2318,7 +2325,7 @@ void Application::update(float deltaTime) { · 147 unmodified lines
2318 updateDialogs(deltaTime); // update various stats dialogs if present2325 updateDialogs(deltaTime); // update various stats dialogs if present
2319 updateCursor(deltaTime); // Handle cursor updates2326 updateCursor(deltaTime); // Handle cursor updates
2320 2327
2321 {2328 if (!_aboutToQuit) {
2322 PerformanceTimer perfTimer("entities");2329 PerformanceTimer perfTimer("entities");
2323 _entities.update(); // update the models...2330 _entities.update(); // update the models...
2324 {2331 {
@@ -2675,6 +2682,14 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 350 unmodified lines
2675 });2682 });
2676}2683}
2677 2684
2685bool Application::isHMDMode() const {
2686 if (OculusManager::isConnected()) {
2687 return true;
2688 } else {
2689 return false;
2690 }
2691}
2692
2678/////////////////////////////////////////////////////////////////////////////////////2693/////////////////////////////////////////////////////////////////////////////////////
2679// loadViewFrustum()2694// loadViewFrustum()
2680//2695//
@@ -2811,6 +2826,8 @@ void Application::updateShadowMap() { · 130 unmodified lines
2811 2826
2812 // store view matrix without translation, which we'll use for precision-sensitive objects2827 // store view matrix without translation, which we'll use for precision-sensitive objects
2813 updateUntranslatedViewMatrix();2828 updateUntranslatedViewMatrix();
2829 // TODO: assign an equivalent viewTransform object to the application to match the current path which uses glMatrixStack
2830 // setViewTransform(viewTransform);
2814 2831
2815 glEnable(GL_POLYGON_OFFSET_FILL);2832 glEnable(GL_POLYGON_OFFSET_FILL);
2816 glPolygonOffset(1.1f, 4.0f); // magic numbers courtesy http://www.eecs.berkeley.edu/~ravir/6160/papers/shadowmaps.ppt2833 glPolygonOffset(1.1f, 4.0f); // magic numbers courtesy http://www.eecs.berkeley.edu/~ravir/6160/papers/shadowmaps.ppt
@@ -2828,7 +2845,12 @@ void Application::updateShadowMap() { · 11 unmodified lines
2828 // render JS/scriptable overlays2845 // render JS/scriptable overlays
2829 {2846 {
2830 PerformanceTimer perfTimer("3dOverlays");2847 PerformanceTimer perfTimer("3dOverlays");
2831 _overlays.render3D(RenderArgs::SHADOW_RENDER_MODE);2848 _overlays.render3D(false, RenderArgs::SHADOW_RENDER_MODE);
2849 }
2850
2851 {
2852 PerformanceTimer perfTimer("3dOverlaysFront");
2853 _overlays.render3D(true, RenderArgs::SHADOW_RENDER_MODE);
2832 }2854 }
2833 2855
2834 glDisable(GL_POLYGON_OFFSET_FILL);2856 glDisable(GL_POLYGON_OFFSET_FILL);
@@ -2883,7 +2905,7 @@ QImage Application::renderAvatarBillboard() { · 48 unmodified lines
2883 return image;2905 return image;
2884}2906}
2885 2907
2886void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {2908void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) {
2887 PROFILE_RANGE(__FUNCTION__);2909 PROFILE_RANGE(__FUNCTION__);
2888 PerformanceTimer perfTimer("display");2910 PerformanceTimer perfTimer("display");
2889 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");2911 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
@@ -2918,6 +2940,26 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 28 unmodified lines
2918 // store view matrix without translation, which we'll use for precision-sensitive objects2940 // store view matrix without translation, which we'll use for precision-sensitive objects
2919 updateUntranslatedViewMatrix(-whichCamera.getPosition());2941 updateUntranslatedViewMatrix(-whichCamera.getPosition());
2920 2942
2943 // Equivalent to what is happening with _untranslatedViewMatrix and the _viewMatrixTranslation
2944 // the viewTransofmr object is updatded with the correct values and saved,
2945 // this is what is used for rendering the Entities and avatars
2946 Transform viewTransform;
2947 viewTransform.setTranslation(whichCamera.getPosition());
2948 viewTransform.setRotation(rotation);
2949 viewTransform.postTranslate(eyeOffsetPos);
2950 viewTransform.postRotate(eyeOffsetOrient);
2951 if (whichCamera.getMode() == CAMERA_MODE_MIRROR) {
2952 viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f));
2953 }
2954 if (renderSide != RenderArgs::MONO) {
2955 glm::mat4 invView = glm::inverse(_untranslatedViewMatrix);
2956
2957 viewTransform.evalFromRawMatrix(invView);
2958 viewTransform.preTranslate(_viewMatrixTranslation);
2959 }
2960
2961 setViewTransform(viewTransform);
2962
2921 glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z);2963 glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z);
2922 2964
2923 // Setup 3D lights (after the camera transform, so that they are positioned in world space)2965 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
@@ -2996,13 +3038,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 72 unmodified lines
2996 _audioReflector.render();3038 _audioReflector.render();
2997 }3039 }
2998 3040
2999 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
3000 PerformanceTimer perfTimer("buckyBalls");
3001 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3002 "Application::displaySide() ... bucky balls...");
3003 _buckyBalls.render();
3004 }
3005
3006 // Draw voxels3041 // Draw voxels
3007 if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {3042 if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
3008 PerformanceTimer perfTimer("voxels");3043 PerformanceTimer perfTimer("voxels");
@@ -3024,13 +3059,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 15 unmodified lines
3024 PerformanceTimer perfTimer("entities");3059 PerformanceTimer perfTimer("entities");
3025 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),3060 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3026 "Application::displaySide() ... entities...");3061 "Application::displaySide() ... entities...");
3027 _entities.render();3062 _entities.render(RenderArgs::DEFAULT_RENDER_MODE, renderSide);
3028 }3063 }
3029 3064
3030 // render JS/scriptable overlays3065 // render JS/scriptable overlays
3031 {3066 {
3032 PerformanceTimer perfTimer("3dOverlays");3067 PerformanceTimer perfTimer("3dOverlays");
3033 _overlays.render3D();3068 _overlays.render3D(false);
3034 }3069 }
3035 3070
3036 // render the ambient occlusion effect if enabled3071 // render the ambient occlusion effect if enabled
@@ -3042,13 +3077,16 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 5 unmodified lines
3042 }3077 }
3043 }3078 }
3044 3079
3080
3081
3045 bool mirrorMode = (whichCamera.getMode() == CAMERA_MODE_MIRROR);3082 bool mirrorMode = (whichCamera.getMode() == CAMERA_MODE_MIRROR);
3046 {3083 {
3047 PerformanceTimer perfTimer("avatars");3084 PerformanceTimer perfTimer("avatars");
3048 _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,3085 _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
3049 false, selfAvatarOnly); 3086 false, selfAvatarOnly);
3050 }3087 }
3051 3088
3089
3052 {3090 {
3053 PROFILE_RANGE("DeferredLighting"); 3091 PROFILE_RANGE("DeferredLighting");
3054 PerformanceTimer perfTimer("lighting");3092 PerformanceTimer perfTimer("lighting");
@@ -3107,10 +3145,17 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 52 unmodified lines
3107 emit renderingInWorldInterface();3145 emit renderingInWorldInterface();
3108 }3146 }
3109 }3147 }
3110 3148
3111 if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) {3149 if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) {
3112 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);3150 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
3113 }3151 }
3152
3153 // Render 3D overlays that should be drawn in front
3154 {
3155 PerformanceTimer perfTimer("3dOverlaysFront");
3156 glClear(GL_DEPTH_BUFFER_BIT);
3157 _overlays.render3D(true);
3158 }
3114}3159}
3115 3160
3116void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) {3161void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) {
@@ -3118,6 +3163,10 @@ void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTransl · 1 unmodified line
3118 _viewMatrixTranslation = viewMatrixTranslation;3163 _viewMatrixTranslation = viewMatrixTranslation;
3119}3164}
3120 3165
3166void Application::setViewTransform(const Transform& view) {
3167 _viewTransform = view;
3168}
3169
3121void Application::loadTranslatedViewMatrix(const glm::vec3& translation) {3170void Application::loadTranslatedViewMatrix(const glm::vec3& translation) {
3122 glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix);3171 glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix);
3123 glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y,3172 glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y,
@@ -3181,12 +3230,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 57 unmodified lines
3181 if (billboard) {3230 if (billboard) {
3182 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees3231 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
3183 _mirrorCamera.setPosition(_myAvatar->getPosition() +3232 _mirrorCamera.setPosition(_myAvatar->getPosition() +
3184 _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());3233 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
3185 3234
3186 } else if (_rearMirrorTools->getZoomLevel() == BODY) {3235 } else if (_rearMirrorTools->getZoomLevel() == BODY) {
3187 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees3236 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
3188 _mirrorCamera.setPosition(_myAvatar->getChestPosition() +3237 _mirrorCamera.setPosition(_myAvatar->getChestPosition() +
3189 _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());3238 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
3190 3239
3191 } else { // HEAD zoom level3240 } else { // HEAD zoom level
3192 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees3241 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
@@ -3194,11 +3243,11 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 1 unmodified line
3194 // as a hack until we have a better way of dealing with coordinate precision issues, reposition the3243 // as a hack until we have a better way of dealing with coordinate precision issues, reposition the
3195 // face/body so that the average eye position lies at the origin3244 // face/body so that the average eye position lies at the origin
3196 eyeRelativeCamera = true;3245 eyeRelativeCamera = true;
3197 _mirrorCamera.setPosition(_myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());3246 _mirrorCamera.setPosition(_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
3198 3247
3199 } else {3248 } else {
3200 _mirrorCamera.setPosition(_myAvatar->getHead()->getEyePosition() +3249 _mirrorCamera.setPosition(_myAvatar->getHead()->getEyePosition() +
3201 _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());3250 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
3202 }3251 }
3203 }3252 }
3204 _mirrorCamera.setAspectRatio((float)region.width() / region.height());3253 _mirrorCamera.setAspectRatio((float)region.width() / region.height());
@@ -3465,7 +3514,6 @@ void Application::deleteVoxelAt(const VoxelDetail& voxel) { · 260 unmodified lines
3465 }3514 }
3466}3515}
3467 3516
3468
3469void Application::resetSensors() {3517void Application::resetSensors() {
3470 _mouseX = _glWidget->width() / 2;3518 _mouseX = _glWidget->width() / 2;
3471 _mouseY = _glWidget->height() / 2;3519 _mouseY = _glWidget->height() / 2;
@@ -3479,7 +3527,11 @@ void Application::resetSensors() { · 7 unmodified lines
3479 _prioVR.reset();3527 _prioVR.reset();
3480 //_leapmotion.reset();3528 //_leapmotion.reset();
3481 3529
3482 QCursor::setPos(_mouseX, _mouseY);3530 QScreen* currentScreen = _window->windowHandle()->screen();
3531 QWindow* mainWindow = _window->windowHandle();
3532 QPoint windowCenter = mainWindow->geometry().center();
3533 QCursor::setPos(currentScreen, windowCenter);
3534
3483 _myAvatar->reset();3535 _myAvatar->reset();
3484 3536
3485 QMetaObject::invokeMethod(&_audio, "reset", Qt::QueuedConnection);3537 QMetaObject::invokeMethod(&_audio, "reset", Qt::QueuedConnection);
@@ -3898,7 +3950,9 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 412 unmodified lines
3898 connect(scriptEngine, SIGNAL(loadScript(const QString&, bool)), this, SLOT(loadScript(const QString&, bool)));3950 connect(scriptEngine, SIGNAL(loadScript(const QString&, bool)), this, SLOT(loadScript(const QString&, bool)));
3899 3951
3900 scriptEngine->registerGlobalObject("Overlays", &_overlays);3952 scriptEngine->registerGlobalObject("Overlays", &_overlays);
3901 qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue, RayToOverlayIntersectionResultFromScriptValue);3953 qScriptRegisterMetaType(scriptEngine, OverlayPropertyResultToScriptValue, OverlayPropertyResultFromScriptValue);
3954 qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
3955 RayToOverlayIntersectionResultFromScriptValue);
3902 3956
3903 QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());3957 QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());
3904 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,3958 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
@@ -3906,11 +3960,14 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 1 unmodified line
3906 // register `location` on the global object.3960 // register `location` on the global object.
3907 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,3961 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
3908 LocationScriptingInterface::locationSetter);3962 LocationScriptingInterface::locationSetter);
3963
3964 scriptEngine->registerFunction("WebWindow", WebWindowClass::constructor, 1);
3909 3965
3910 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());3966 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
3911 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());3967 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
3912 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());3968 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
3913 scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);3969 scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
3970 scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
3914 scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector);3971 scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector);
3915 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());3972 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
3916 scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);3973 scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
@@ -3959,26 +4016,23 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 42 unmodified lines
3959 return _scriptEnginesHash[scriptURLString];4016 return _scriptEnginesHash[scriptURLString];
3960 }4017 }
3961 4018
3962 ScriptEngine* scriptEngine;4019 ScriptEngine* scriptEngine = new ScriptEngine(NO_SCRIPT, "", &_controllerScriptingInterface);
4020 scriptEngine->setUserLoaded(isUserLoaded);
4021
3963 if (scriptFilename.isNull()) {4022 if (scriptFilename.isNull()) {
3964 scriptEngine = new ScriptEngine(NO_SCRIPT, "", &_controllerScriptingInterface);4023 // this had better be the script editor (we should de-couple so somebody who thinks they are loading a script
4024 // doesn't just get an empty script engine)
4025
4026 // we can complete setup now since there isn't a script we have to load
4027 registerScriptEngineWithApplicationServices(scriptEngine);
3965 } else {4028 } else {
3966 // start the script on a new thread...4029 // connect to the appropriate signals of this script engine
3967 scriptEngine = new ScriptEngine(scriptUrl, &_controllerScriptingInterface);4030 connect(scriptEngine, &ScriptEngine::scriptLoaded, this, &Application::handleScriptEngineLoaded);
3968 4031 connect(scriptEngine, &ScriptEngine::errorLoadingScript, this, &Application::handleScriptLoadError);
3969 if (!scriptEngine->hasScript()) {4032
3970 qDebug() << "Application::loadScript(), script failed to load...";4033 // get the script engine object to load the script at the designated script URL
3971 QMessageBox::warning(getWindow(), "Error Loading Script", scriptURLString + " failed to load.");4034 scriptEngine->loadURL(scriptUrl);
3972 return NULL;
3973 }
3974
3975 _scriptEnginesHash.insertMulti(scriptURLString, scriptEngine);
3976 _runningScriptsWidget->setRunningScripts(getRunningScripts());
3977 UserActivityLogger::getInstance().loadedScript(scriptURLString);
3978 }4035 }
3979 scriptEngine->setUserLoaded(isUserLoaded);
3980
3981 registerScriptEngineWithApplicationServices(scriptEngine);
3982 4036
3983 // restore the main window's active state4037 // restore the main window's active state
3984 if (activateMainWindow && !loadScriptFromEditor) {4038 if (activateMainWindow && !loadScriptFromEditor) {
@@ -3989,6 +4043,22 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 4 unmodified lines
3989 return scriptEngine;4043 return scriptEngine;
3990}4044}
3991 4045
4046void Application::handleScriptEngineLoaded(const QString& scriptFilename) {
4047 ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(sender());
4048
4049 _scriptEnginesHash.insertMulti(scriptFilename, scriptEngine);
4050 _runningScriptsWidget->setRunningScripts(getRunningScripts());
4051 UserActivityLogger::getInstance().loadedScript(scriptFilename);
4052
4053 // register our application services and set it off on its own thread
4054 registerScriptEngineWithApplicationServices(scriptEngine);
4055}
4056
4057void Application::handleScriptLoadError(const QString& scriptFilename) {
4058 qDebug() << "Application::loadScript(), script failed to load...";
4059 QMessageBox::warning(getWindow(), "Error Loading Script", scriptFilename + " failed to load.");
4060}
4061
3992void Application::scriptFinished(const QString& scriptName) {4062void Application::scriptFinished(const QString& scriptName) {
3993 const QString& scriptURLString = QUrl(scriptName).toString();4063 const QString& scriptURLString = QUrl(scriptName).toString();
3994 QHash<QString, ScriptEngine*>::iterator it = _scriptEnginesHash.find(scriptURLString);4064 QHash<QString, ScriptEngine*>::iterator it = _scriptEnginesHash.find(scriptURLString);
@@ -4189,7 +4259,7 @@ void Application::toggleLogDialog() { · 194 unmodified lines
4189}4259}
4190 4260
4191void Application::initAvatarAndViewFrustum() {4261void Application::initAvatarAndViewFrustum() {
4192 updateMyAvatar(0.f);4262 updateMyAvatar(0.0f);
4193}4263}
4194 4264
4195void Application::checkVersion() {4265void Application::checkVersion() {
@@ -4315,8 +4385,6 @@ bool Application::isVSyncOn() const { · 119 unmodified lines
4315 if (wglewGetExtension("WGL_EXT_swap_control")) {4385 if (wglewGetExtension("WGL_EXT_swap_control")) {
4316 int swapInterval = wglGetSwapIntervalEXT();4386 int swapInterval = wglGetSwapIntervalEXT();
4317 return (swapInterval > 0);4387 return (swapInterval > 0);
4318 } else {
4319 return true;
4320 }4388 }
4321#elif defined(Q_OS_LINUX)4389#elif defined(Q_OS_LINUX)
4322 // TODO: write the poper code for linux4390 // TODO: write the poper code for linux
@@ -4327,10 +4395,9 @@ bool Application::isVSyncOn() const { · 4 unmodified lines
4327 } else {4395 } else {
4328 return true;4396 return true;
4329 }4397 }
4330 */4398 */
4331#else
4332 return true;
4333#endif4399#endif
4400 return true;
4334}4401}
4335 4402
4336bool Application::isVSyncEditable() const {4403bool Application::isVSyncEditable() const {
@@ -4345,7 +4412,6 @@ bool Application::isVSyncEditable() const { · 8 unmodified lines
4345 return true;4412 return true;
4346 }4413 }
4347 */4414 */
4348#else
4349#endif4415#endif
4350 return false;4416 return false;
4351}4417}
@@ -4367,7 +4433,7 @@ unsigned int Application::getRenderTargetFramerate() const { · 15 unmodified lines
4367 4433
4368float Application::getRenderResolutionScale() const {4434float Application::getRenderResolutionScale() const {
4369 if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) {4435 if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) {
4370 return 1.f;4436 return 1.0f;
4371 } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) {4437 } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) {
4372 return 0.666f;4438 return 0.666f;
4373 } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) {4439 } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) {
@@ -4377,6 +4443,6 @@ float Application::getRenderResolutionScale() const { · 3 unmodified lines
4377 } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) {4443 } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) {
4378 return 0.25f;4444 return 0.25f;
4379 } else {4445 } else {
4380 return 1.f;4446 return 1.0f;
4381 }4447 }
4382}4448}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t