Showing the changes to interface/src/Application.cpp (1 of 337 files). Show all
Unified · Split
| @@ -65,6 +65,7 @@ · 64 unmodified lines | ||
| 65 | 65 | #include <PacketHeaders.h> |
| 66 | 66 | #include <PerfStat.h> |
| 67 | 67 | #include <ResourceCache.h> |
| 68 | +#include <SoundCache.h> | |
| 68 | 69 | #include <UserActivityLogger.h> |
| 69 | 70 | #include <UUID.h> |
| 70 | 71 | |
| @@ -92,6 +93,7 @@ · 21 unmodified lines | ||
| 92 | 93 | #include "scripting/MenuScriptingInterface.h" |
| 93 | 94 | #include "scripting/SettingsScriptingInterface.h" |
| 94 | 95 | #include "scripting/WindowScriptingInterface.h" |
| 96 | +#include "scripting/WebWindowClass.h" | |
| 95 | 97 | |
| 96 | 98 | #include "ui/DataWebDialog.h" |
| 97 | 99 | #include "ui/InfoView.h" |
| @@ -108,7 +110,8 @@ static unsigned STARFIELD_SEED = 1; · 10 unmodified lines | ||
| 108 | 110 | |
| 109 | 111 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored |
| 110 | 112 | |
| 111 | −const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB | |
| 113 | + | |
| 114 | +const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB | |
| 112 | 115 | |
| 113 | 116 | static QTimer* idleTimer = NULL; |
| 114 | 117 | |
| @@ -121,7 +124,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 6 unmodified lines | ||
| 121 | 124 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); |
| 122 | 125 | |
| 123 | 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 | 161 | _lastQueriedViewFrustum(), |
| 159 | 162 | _lastQueriedTime(usecTimestampNow()), |
| 160 | 163 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 164 | + _viewTransform(), | |
| 161 | 165 | _scaleMirror(1.0f), |
| 162 | 166 | _rotateMirror(0.0f), |
| 163 | 167 | _raiseMirror(0.0f), |
| @@ -369,6 +373,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 205 unmodified lines | ||
| 369 | 373 | // enable mouse tracking; otherwise, we only get drag events |
| 370 | 374 | _glWidget->setMouseTracking(true); |
| 371 | 375 | |
| 376 | + _toolWindow = new ToolWindow(); | |
| 377 | + _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint); | |
| 378 | + _toolWindow->setWindowTitle("Tools"); | |
| 379 | + | |
| 372 | 380 | // initialization continues in initializeGL when OpenGL context is ready |
| 373 | 381 | |
| 374 | 382 | // 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 | 425 | _trayIcon->show(); |
| 418 | 426 | |
| 419 | 427 | // set the local loopback interface for local sounds from audio scripts |
| 420 | − AudioScriptingInterface::getInstance().setLocalLoopbackInterface(&_audio); | |
| 428 | + AudioScriptingInterface::getInstance().setLocalAudioInterface(&_audio); | |
| 421 | 429 | |
| 422 | 430 | #ifdef HAVE_RTMIDI |
| 423 | 431 | // setup the MIDIManager |
| @@ -430,6 +438,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 6 unmodified lines | ||
| 430 | 438 | |
| 431 | 439 | void Application::aboutToQuit() { |
| 432 | 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 | |
| 435 | 444 | Application::~Application() { |
| @@ -453,23 +462,22 @@ Application::~Application() { · 17 unmodified lines | ||
| 453 | 462 | // ask the datagram processing thread to quit and wait until it is done |
| 454 | 463 | _nodeThread->quit(); |
| 455 | 464 | _nodeThread->wait(); |
| 465 | + | |
| 466 | + // kill any audio injectors that are still around | |
| 467 | + AudioScriptingInterface::getInstance().stopAllInjectors(); | |
| 456 | 468 | |
| 457 | 469 | // stop the audio process |
| 458 | 470 | QMetaObject::invokeMethod(&_audio, "stop"); |
| 459 | − | |
| 471 | + | |
| 460 | 472 | // ask the audio thread to quit and wait until it is done |
| 461 | 473 | _audio.thread()->quit(); |
| 462 | 474 | _audio.thread()->wait(); |
| 463 | − | |
| 464 | − // kill any audio injectors that are still around | |
| 465 | − AudioScriptingInterface::getInstance().stopAllInjectors(); | |
| 466 | 475 | |
| 467 | 476 | _octreeProcessor.terminate(); |
| 468 | 477 | _voxelHideShowThread.terminate(); |
| 469 | 478 | _voxelEditSender.terminate(); |
| 470 | 479 | _entityEditSender.terminate(); |
| 471 | 480 | |
| 472 | − | |
| 473 | 481 | VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown |
| 474 | 482 | Menu::getInstance()->deleteLater(); |
| 475 | 483 | |
| @@ -597,7 +605,7 @@ void Application::initializeGL() { · 121 unmodified lines | ||
| 597 | 605 | } |
| 598 | 606 | |
| 599 | 607 | // update before the first render |
| 600 | − update(1.f / _fps); | |
| 608 | + update(1.0f / _fps); | |
| 601 | 609 | |
| 602 | 610 | InfoView::showFirstTime(INFO_HELP_PATH); |
| 603 | 611 | } |
| @@ -643,25 +651,16 @@ void Application::paintGL() { · 39 unmodified lines | ||
| 643 | 651 | } |
| 644 | 652 | |
| 645 | 653 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 646 | − //Only behave like a true mirror when in the OR | |
| 647 | − if (OculusManager::isConnected()) { | |
| 648 | − _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | |
| 649 | − _myCamera.setPosition(_myAvatar->getHead()->getEyePosition() + | |
| 650 | − glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) + | |
| 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 | − } | |
| 654 | + _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | |
| 655 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 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); | |
| 660 | 659 | } |
| 661 | 660 | |
| 662 | 661 | // Update camera position |
| 663 | 662 | if (!OculusManager::isConnected()) { |
| 664 | − _myCamera.update(1.f / _fps); | |
| 663 | + _myCamera.update(1.0f / _fps); | |
| 665 | 664 | } |
| 666 | 665 | |
| 667 | 666 | // 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 | 686 | _viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation); |
| 688 | 687 | |
| 689 | − _viewFrustumOffsetCamera.update(1.f/_fps); | |
| 688 | + _viewFrustumOffsetCamera.update(1.0f/_fps); | |
| 690 | 689 | whichCamera = &_viewFrustumOffsetCamera; |
| 691 | 690 | } |
| 692 | 691 | |
| @@ -705,7 +704,7 @@ void Application::paintGL() { · 12 unmodified lines | ||
| 705 | 704 | } else { |
| 706 | 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 | 709 | } else if (TV3DManager::isConnected()) { |
| 711 | 710 | |
| @@ -724,11 +723,11 @@ void Application::paintGL() { · 12 unmodified lines | ||
| 724 | 723 | displaySide(*whichCamera); |
| 725 | 724 | glPopMatrix(); |
| 726 | 725 | |
| 727 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 728 | − renderRearViewMirror(_mirrorViewRect); | |
| 729 | − | |
| 730 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 726 | + if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 731 | 727 | _rearMirrorTools->render(true); |
| 728 | + | |
| 729 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 730 | + renderRearViewMirror(_mirrorViewRect); | |
| 732 | 731 | } |
| 733 | 732 | |
| 734 | 733 | _glowEffect.render(); |
| @@ -786,7 +785,7 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) · 51 unmodified lines | ||
| 786 | 785 | // Tell our viewFrustum about this change, using the application camera |
| 787 | 786 | if (updateViewFrustum) { |
| 788 | 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 | 790 | // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the |
| 792 | 791 | // _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 | 842 | QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); |
| 844 | 843 | |
| 845 | 844 | if (!fileEvent->url().isEmpty()) { |
| 846 | − AddressManager::getInstance().handleLookupString(fileEvent->url().toLocalFile()); | |
| 845 | + AddressManager::getInstance().handleLookupString(fileEvent->url().toString()); | |
| 847 | 846 | } |
| 848 | 847 | |
| 849 | 848 | return false; |
| @@ -911,7 +910,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 61 unmodified lines | ||
| 911 | 910 | if (!_myAvatar->getDriveKeys(UP)) { |
| 912 | 911 | _myAvatar->jump(); |
| 913 | 912 | } |
| 914 | − _myAvatar->setDriveKeys(UP, 1.f); | |
| 913 | + _myAvatar->setDriveKeys(UP, 1.0f); | |
| 915 | 914 | break; |
| 916 | 915 | |
| 917 | 916 | case Qt::Key_Asterisk: |
| @@ -920,14 +919,14 @@ void Application::keyPressEvent(QKeyEvent* event) { · 2 unmodified lines | ||
| 920 | 919 | |
| 921 | 920 | case Qt::Key_C: |
| 922 | 921 | case Qt::Key_PageDown: |
| 923 | − _myAvatar->setDriveKeys(DOWN, 1.f); | |
| 922 | + _myAvatar->setDriveKeys(DOWN, 1.0f); | |
| 924 | 923 | break; |
| 925 | 924 | |
| 926 | 925 | case Qt::Key_W: |
| 927 | 926 | if (isOption && !isShifted && !isMeta) { |
| 928 | 927 | Menu::getInstance()->triggerOption(MenuOption::Wireframe); |
| 929 | 928 | } else { |
| 930 | − _myAvatar->setDriveKeys(FWD, 1.f); | |
| 929 | + _myAvatar->setDriveKeys(FWD, 1.0f); | |
| 931 | 930 | } |
| 932 | 931 | break; |
| 933 | 932 | |
| @@ -939,7 +938,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | ||
| 939 | 938 | } else if (!isOption && !isShifted && isMeta) { |
| 940 | 939 | takeSnapshot(); |
| 941 | 940 | } else { |
| 942 | − _myAvatar->setDriveKeys(BACK, 1.f); | |
| 941 | + _myAvatar->setDriveKeys(BACK, 1.0f); | |
| 943 | 942 | } |
| 944 | 943 | break; |
| 945 | 944 | |
| @@ -957,13 +956,13 @@ void Application::keyPressEvent(QKeyEvent* event) { · 11 unmodified lines | ||
| 957 | 956 | if (isShifted) { |
| 958 | 957 | Menu::getInstance()->triggerOption(MenuOption::Atmosphere); |
| 959 | 958 | } else { |
| 960 | − _myAvatar->setDriveKeys(ROT_LEFT, 1.f); | |
| 959 | + _myAvatar->setDriveKeys(ROT_LEFT, 1.0f); | |
| 961 | 960 | } |
| 962 | 961 | break; |
| 963 | 962 | |
| 964 | 963 | case Qt::Key_D: |
| 965 | 964 | if (!isMeta) { |
| 966 | − _myAvatar->setDriveKeys(ROT_RIGHT, 1.f); | |
| 965 | + _myAvatar->setDriveKeys(ROT_RIGHT, 1.0f); | |
| 967 | 966 | } |
| 968 | 967 | break; |
| 969 | 968 | |
| @@ -991,7 +990,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 21 unmodified lines | ||
| 991 | 990 | _raiseMirror += 0.05f; |
| 992 | 991 | } |
| 993 | 992 | } else { |
| 994 | − _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.f); | |
| 993 | + _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.0f); | |
| 995 | 994 | } |
| 996 | 995 | break; |
| 997 | 996 | |
| @@ -1003,23 +1002,23 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | ||
| 1003 | 1002 | _raiseMirror -= 0.05f; |
| 1004 | 1003 | } |
| 1005 | 1004 | } else { |
| 1006 | − _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.f); | |
| 1005 | + _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.0f); | |
| 1007 | 1006 | } |
| 1008 | 1007 | break; |
| 1009 | 1008 | |
| 1010 | 1009 | case Qt::Key_Left: |
| 1011 | 1010 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 1012 | − _rotateMirror += PI / 20.f; | |
| 1011 | + _rotateMirror += PI / 20.0f; | |
| 1013 | 1012 | } else { |
| 1014 | − _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.f); | |
| 1013 | + _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.0f); | |
| 1015 | 1014 | } |
| 1016 | 1015 | break; |
| 1017 | 1016 | |
| 1018 | 1017 | case Qt::Key_Right: |
| 1019 | 1018 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 1020 | − _rotateMirror -= PI / 20.f; | |
| 1019 | + _rotateMirror -= PI / 20.0f; | |
| 1021 | 1020 | } else { |
| 1022 | − _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.f); | |
| 1021 | + _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.0f); | |
| 1023 | 1022 | } |
| 1024 | 1023 | break; |
| 1025 | 1024 | |
| @@ -1170,48 +1169,48 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 144 unmodified lines | ||
| 1170 | 1169 | switch (event->key()) { |
| 1171 | 1170 | case Qt::Key_E: |
| 1172 | 1171 | case Qt::Key_PageUp: |
| 1173 | − _myAvatar->setDriveKeys(UP, 0.f); | |
| 1172 | + _myAvatar->setDriveKeys(UP, 0.0f); | |
| 1174 | 1173 | break; |
| 1175 | 1174 | |
| 1176 | 1175 | case Qt::Key_C: |
| 1177 | 1176 | case Qt::Key_PageDown: |
| 1178 | − _myAvatar->setDriveKeys(DOWN, 0.f); | |
| 1177 | + _myAvatar->setDriveKeys(DOWN, 0.0f); | |
| 1179 | 1178 | break; |
| 1180 | 1179 | |
| 1181 | 1180 | case Qt::Key_W: |
| 1182 | − _myAvatar->setDriveKeys(FWD, 0.f); | |
| 1181 | + _myAvatar->setDriveKeys(FWD, 0.0f); | |
| 1183 | 1182 | break; |
| 1184 | 1183 | |
| 1185 | 1184 | case Qt::Key_S: |
| 1186 | − _myAvatar->setDriveKeys(BACK, 0.f); | |
| 1185 | + _myAvatar->setDriveKeys(BACK, 0.0f); | |
| 1187 | 1186 | break; |
| 1188 | 1187 | |
| 1189 | 1188 | case Qt::Key_A: |
| 1190 | − _myAvatar->setDriveKeys(ROT_LEFT, 0.f); | |
| 1189 | + _myAvatar->setDriveKeys(ROT_LEFT, 0.0f); | |
| 1191 | 1190 | break; |
| 1192 | 1191 | |
| 1193 | 1192 | case Qt::Key_D: |
| 1194 | − _myAvatar->setDriveKeys(ROT_RIGHT, 0.f); | |
| 1193 | + _myAvatar->setDriveKeys(ROT_RIGHT, 0.0f); | |
| 1195 | 1194 | break; |
| 1196 | 1195 | |
| 1197 | 1196 | case Qt::Key_Up: |
| 1198 | − _myAvatar->setDriveKeys(FWD, 0.f); | |
| 1199 | − _myAvatar->setDriveKeys(UP, 0.f); | |
| 1197 | + _myAvatar->setDriveKeys(FWD, 0.0f); | |
| 1198 | + _myAvatar->setDriveKeys(UP, 0.0f); | |
| 1200 | 1199 | break; |
| 1201 | 1200 | |
| 1202 | 1201 | case Qt::Key_Down: |
| 1203 | − _myAvatar->setDriveKeys(BACK, 0.f); | |
| 1204 | − _myAvatar->setDriveKeys(DOWN, 0.f); | |
| 1202 | + _myAvatar->setDriveKeys(BACK, 0.0f); | |
| 1203 | + _myAvatar->setDriveKeys(DOWN, 0.0f); | |
| 1205 | 1204 | break; |
| 1206 | 1205 | |
| 1207 | 1206 | case Qt::Key_Left: |
| 1208 | − _myAvatar->setDriveKeys(LEFT, 0.f); | |
| 1209 | − _myAvatar->setDriveKeys(ROT_LEFT, 0.f); | |
| 1207 | + _myAvatar->setDriveKeys(LEFT, 0.0f); | |
| 1208 | + _myAvatar->setDriveKeys(ROT_LEFT, 0.0f); | |
| 1210 | 1209 | break; |
| 1211 | 1210 | |
| 1212 | 1211 | case Qt::Key_Right: |
| 1213 | − _myAvatar->setDriveKeys(RIGHT, 0.f); | |
| 1214 | − _myAvatar->setDriveKeys(ROT_RIGHT, 0.f); | |
| 1212 | + _myAvatar->setDriveKeys(RIGHT, 0.0f); | |
| 1213 | + _myAvatar->setDriveKeys(ROT_RIGHT, 0.0f); | |
| 1215 | 1214 | break; |
| 1216 | 1215 | case Qt::Key_Control: |
| 1217 | 1216 | case Qt::Key_Shift: |
| @@ -1515,7 +1514,7 @@ void Application::idle() { · 297 unmodified lines | ||
| 1515 | 1514 | PerformanceTimer perfTimer("update"); |
| 1516 | 1515 | PerformanceWarning warn(showWarnings, "Application::idle()... update()"); |
| 1517 | 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 | 1520 | PerformanceTimer perfTimer("updateGL"); |
| @@ -1534,11 +1533,6 @@ void Application::idle() { · 12 unmodified lines | ||
| 1534 | 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 | 1536 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. |
| 1543 | 1537 | idleTimer->start(2); |
| 1544 | 1538 | |
| @@ -1553,6 +1547,8 @@ void Application::checkBandwidthMeterClick() { · 8 unmodified lines | ||
| 1553 | 1547 | // ... to be called upon button release |
| 1554 | 1548 | |
| 1555 | 1549 | if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) && |
| 1550 | + Menu::getInstance()->isOptionChecked(MenuOption::Stats) && | |
| 1551 | + Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) && | |
| 1556 | 1552 | glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY))) |
| 1557 | 1553 | <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH |
| 1558 | 1554 | && _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) { |
| @@ -1564,6 +1560,10 @@ void Application::checkBandwidthMeterClick() { · 5 unmodified lines | ||
| 1564 | 1560 | } |
| 1565 | 1561 | |
| 1566 | 1562 | void Application::setFullscreen(bool fullscreen) { |
| 1563 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen) != fullscreen) { | |
| 1564 | + Menu::getInstance()->getActionForOption(MenuOption::Fullscreen)->setChecked(fullscreen); | |
| 1565 | + } | |
| 1566 | + | |
| 1567 | 1567 | if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { |
| 1568 | 1568 | if (fullscreen) { |
| 1569 | 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 | 1575 | _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) : |
| 1576 | 1576 | (_window->windowState() & ~Qt::WindowFullScreen)); |
| 1577 | + if (!_aboutToQuit) { | |
| 1578 | + _window->show(); | |
| 1579 | + } | |
| 1577 | 1580 | } |
| 1578 | 1581 | |
| 1579 | 1582 | void Application::setEnable3DTVMode(bool enable3DTVMode) { |
| @@ -1581,6 +1584,10 @@ void Application::setEnable3DTVMode(bool enable3DTVMode) { · 1 unmodified line | ||
| 1581 | 1584 | } |
| 1582 | 1585 | |
| 1583 | 1586 | void Application::setEnableVRMode(bool enableVRMode) { |
| 1587 | + if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) != enableVRMode) { | |
| 1588 | + Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(enableVRMode); | |
| 1589 | + } | |
| 1590 | + | |
| 1584 | 1591 | if (enableVRMode) { |
| 1585 | 1592 | if (!OculusManager::isConnected()) { |
| 1586 | 1593 | // 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 | 1598 | OculusManager::recalibrate(); |
| 1592 | 1599 | } else { |
| 1593 | 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 | 1608 | resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); |
| @@ -1649,8 +1661,8 @@ void Application::makeVoxel(glm::vec3 position, · 52 unmodified lines | ||
| 1649 | 1661 | } |
| 1650 | 1662 | |
| 1651 | 1663 | glm::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, | |
| 1653 | − (mouseVoxel.z + 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, | |
| 1665 | + (mouseVoxel.z + mouseVoxel.s / 2.0f) * TREE_SCALE); | |
| 1654 | 1666 | } |
| 1655 | 1667 | |
| 1656 | 1668 | FaceTracker* Application::getActiveFaceTracker() { |
| @@ -1863,7 +1875,7 @@ void Application::init() { · 206 unmodified lines | ||
| 1863 | 1875 | 3.0f * TREE_SCALE / 2.0f)); |
| 1864 | 1876 | _sharedVoxelSystemViewFrustum.setNearClip(TREE_SCALE / 2.0f); |
| 1865 | 1877 | _sharedVoxelSystemViewFrustum.setFarClip(3.0f * TREE_SCALE / 2.0f); |
| 1866 | − _sharedVoxelSystemViewFrustum.setFieldOfView(90.f); | |
| 1878 | + _sharedVoxelSystemViewFrustum.setFieldOfView(90.0f); | |
| 1867 | 1879 | _sharedVoxelSystemViewFrustum.setOrientation(glm::quat()); |
| 1868 | 1880 | _sharedVoxelSystemViewFrustum.calculate(); |
| 1869 | 1881 | _sharedVoxelSystem.setViewFrustum(&_sharedVoxelSystemViewFrustum); |
| @@ -1922,11 +1934,14 @@ void Application::init() { · 52 unmodified lines | ||
| 1922 | 1934 | // check if we have a URL in settings to load to jump back to |
| 1923 | 1935 | // we load this separate from the other settings so we don't double lookup a URL |
| 1924 | 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 | 1942 | unlockSettings(); |
| 1943 | + | |
| 1944 | + AddressManager::getInstance().handleLookupString(addressString); | |
| 1930 | 1945 | } |
| 1931 | 1946 | |
| 1932 | 1947 | qDebug() << "Loaded settings"; |
| @@ -2009,25 +2024,17 @@ void Application::init() { · 76 unmodified lines | ||
| 2009 | 2024 | |
| 2010 | 2025 | void Application::closeMirrorView() { |
| 2011 | 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 | |
| 2016 | 2031 | void Application::restoreMirrorView() { |
| 2017 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2018 | − Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 2019 | − } | |
| 2020 | − | |
| 2021 | 2032 | if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 2022 | 2033 | Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); |
| 2023 | 2034 | } |
| 2024 | 2035 | } |
| 2025 | 2036 | |
| 2026 | 2037 | void Application::shrinkMirrorView() { |
| 2027 | − if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2028 | − Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 2029 | − } | |
| 2030 | − | |
| 2031 | 2038 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 2032 | 2039 | Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); |
| 2033 | 2040 | } |
| @@ -2164,7 +2171,7 @@ void Application::updateMyAvatarLookAtPosition() { · 130 unmodified lines | ||
| 2164 | 2171 | } else { |
| 2165 | 2172 | // I am not looking at anyone else, so just look forward |
| 2166 | 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 | 2325 | updateDialogs(deltaTime); // update various stats dialogs if present |
| 2319 | 2326 | updateCursor(deltaTime); // Handle cursor updates |
| 2320 | 2327 | |
| 2321 | − { | |
| 2328 | + if (!_aboutToQuit) { | |
| 2322 | 2329 | PerformanceTimer perfTimer("entities"); |
| 2323 | 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 | |
| 2685 | +bool Application::isHMDMode() const { | |
| 2686 | + if (OculusManager::isConnected()) { | |
| 2687 | + return true; | |
| 2688 | + } else { | |
| 2689 | + return false; | |
| 2690 | + } | |
| 2691 | +} | |
| 2692 | + | |
| 2678 | 2693 | ///////////////////////////////////////////////////////////////////////////////////// |
| 2679 | 2694 | // loadViewFrustum() |
| 2680 | 2695 | // |
| @@ -2811,6 +2826,8 @@ void Application::updateShadowMap() { · 130 unmodified lines | ||
| 2811 | 2826 | |
| 2812 | 2827 | // store view matrix without translation, which we'll use for precision-sensitive objects |
| 2813 | 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 | 2832 | glEnable(GL_POLYGON_OFFSET_FILL); |
| 2816 | 2833 | 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 | 2845 | // render JS/scriptable overlays |
| 2829 | 2846 | { |
| 2830 | 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 | 2856 | glDisable(GL_POLYGON_OFFSET_FILL); |
| @@ -2883,7 +2905,7 @@ QImage Application::renderAvatarBillboard() { · 48 unmodified lines | ||
| 2883 | 2905 | return image; |
| 2884 | 2906 | } |
| 2885 | 2907 | |
| 2886 | −void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { | |
| 2908 | +void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) { | |
| 2887 | 2909 | PROFILE_RANGE(__FUNCTION__); |
| 2888 | 2910 | PerformanceTimer perfTimer("display"); |
| 2889 | 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 | 2940 | // store view matrix without translation, which we'll use for precision-sensitive objects |
| 2919 | 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 | 2963 | glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z); |
| 2922 | 2964 | |
| 2923 | 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 | 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 | 3041 | // Draw voxels |
| 3007 | 3042 | if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 3008 | 3043 | PerformanceTimer perfTimer("voxels"); |
| @@ -3024,13 +3059,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 15 unmodified lines | ||
| 3024 | 3059 | PerformanceTimer perfTimer("entities"); |
| 3025 | 3060 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 3026 | 3061 | "Application::displaySide() ... entities..."); |
| 3027 | − _entities.render(); | |
| 3062 | + _entities.render(RenderArgs::DEFAULT_RENDER_MODE, renderSide); | |
| 3028 | 3063 | } |
| 3029 | 3064 | |
| 3030 | 3065 | // render JS/scriptable overlays |
| 3031 | 3066 | { |
| 3032 | 3067 | PerformanceTimer perfTimer("3dOverlays"); |
| 3033 | − _overlays.render3D(); | |
| 3068 | + _overlays.render3D(false); | |
| 3034 | 3069 | } |
| 3035 | 3070 | |
| 3036 | 3071 | // 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 | 3082 | bool mirrorMode = (whichCamera.getMode() == CAMERA_MODE_MIRROR); |
| 3046 | 3083 | { |
| 3047 | 3084 | PerformanceTimer perfTimer("avatars"); |
| 3048 | 3085 | _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, |
| 3049 | 3086 | false, selfAvatarOnly); |
| 3050 | 3087 | } |
| 3051 | − | |
| 3088 | + | |
| 3089 | + | |
| 3052 | 3090 | { |
| 3053 | 3091 | PROFILE_RANGE("DeferredLighting"); |
| 3054 | 3092 | PerformanceTimer perfTimer("lighting"); |
| @@ -3107,10 +3145,17 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 52 unmodified lines | ||
| 3107 | 3145 | emit renderingInWorldInterface(); |
| 3108 | 3146 | } |
| 3109 | 3147 | } |
| 3110 | − | |
| 3148 | + | |
| 3111 | 3149 | if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) { |
| 3112 | 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 | |
| 3116 | 3161 | void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) { |
| @@ -3118,6 +3163,10 @@ void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTransl · 1 unmodified line | ||
| 3118 | 3163 | _viewMatrixTranslation = viewMatrixTranslation; |
| 3119 | 3164 | } |
| 3120 | 3165 | |
| 3166 | +void Application::setViewTransform(const Transform& view) { | |
| 3167 | + _viewTransform = view; | |
| 3168 | +} | |
| 3169 | + | |
| 3121 | 3170 | void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { |
| 3122 | 3171 | glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix); |
| 3123 | 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 | 3230 | if (billboard) { |
| 3182 | 3231 | _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees |
| 3183 | 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 | 3235 | } else if (_rearMirrorTools->getZoomLevel() == BODY) { |
| 3187 | 3236 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 3188 | 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 | 3240 | } else { // HEAD zoom level |
| 3192 | 3241 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| @@ -3194,11 +3243,11 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 1 unmodified line | ||
| 3194 | 3243 | // as a hack until we have a better way of dealing with coordinate precision issues, reposition the |
| 3195 | 3244 | // face/body so that the average eye position lies at the origin |
| 3196 | 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 | 3248 | } else { |
| 3200 | 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 | 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 | − | |
| 3469 | 3517 | void Application::resetSensors() { |
| 3470 | 3518 | _mouseX = _glWidget->width() / 2; |
| 3471 | 3519 | _mouseY = _glWidget->height() / 2; |
| @@ -3479,7 +3527,11 @@ void Application::resetSensors() { · 7 unmodified lines | ||
| 3479 | 3527 | _prioVR.reset(); |
| 3480 | 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 | 3535 | _myAvatar->reset(); |
| 3484 | 3536 | |
| 3485 | 3537 | QMetaObject::invokeMethod(&_audio, "reset", Qt::QueuedConnection); |
| @@ -3898,7 +3950,9 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 412 unmodified lines | ||
| 3898 | 3950 | connect(scriptEngine, SIGNAL(loadScript(const QString&, bool)), this, SLOT(loadScript(const QString&, bool))); |
| 3899 | 3951 | |
| 3900 | 3952 | scriptEngine->registerGlobalObject("Overlays", &_overlays); |
| 3901 | − qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue, RayToOverlayIntersectionResultFromScriptValue); | |
| 3953 | + qScriptRegisterMetaType(scriptEngine, OverlayPropertyResultToScriptValue, OverlayPropertyResultFromScriptValue); | |
| 3954 | + qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue, | |
| 3955 | + RayToOverlayIntersectionResultFromScriptValue); | |
| 3902 | 3956 | |
| 3903 | 3957 | QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance()); |
| 3904 | 3958 | scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, |
| @@ -3906,11 +3960,14 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 1 unmodified line | ||
| 3906 | 3960 | // register `location` on the global object. |
| 3907 | 3961 | scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, |
| 3908 | 3962 | LocationScriptingInterface::locationSetter); |
| 3963 | + | |
| 3964 | + scriptEngine->registerFunction("WebWindow", WebWindowClass::constructor, 1); | |
| 3909 | 3965 | |
| 3910 | 3966 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 3911 | 3967 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 3912 | 3968 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); |
| 3913 | 3969 | scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); |
| 3970 | + scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); | |
| 3914 | 3971 | scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector); |
| 3915 | 3972 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 3916 | 3973 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); |
| @@ -3959,26 +4016,23 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 42 unmodified lines | ||
| 3959 | 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 | 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 | 4028 | } else { |
| 3966 | − // start the script on a new thread... | |
| 3967 | − scriptEngine = new ScriptEngine(scriptUrl, &_controllerScriptingInterface); | |
| 3968 | − | |
| 3969 | − if (!scriptEngine->hasScript()) { | |
| 3970 | − qDebug() << "Application::loadScript(), script failed to load..."; | |
| 3971 | − QMessageBox::warning(getWindow(), "Error Loading Script", scriptURLString + " failed to load."); | |
| 3972 | − return NULL; | |
| 3973 | − } | |
| 3974 | − | |
| 3975 | − _scriptEnginesHash.insertMulti(scriptURLString, scriptEngine); | |
| 3976 | − _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3977 | − UserActivityLogger::getInstance().loadedScript(scriptURLString); | |
| 4029 | + // connect to the appropriate signals of this script engine | |
| 4030 | + connect(scriptEngine, &ScriptEngine::scriptLoaded, this, &Application::handleScriptEngineLoaded); | |
| 4031 | + connect(scriptEngine, &ScriptEngine::errorLoadingScript, this, &Application::handleScriptLoadError); | |
| 4032 | + | |
| 4033 | + // get the script engine object to load the script at the designated script URL | |
| 4034 | + scriptEngine->loadURL(scriptUrl); | |
| 3978 | 4035 | } |
| 3979 | − scriptEngine->setUserLoaded(isUserLoaded); | |
| 3980 | − | |
| 3981 | − registerScriptEngineWithApplicationServices(scriptEngine); | |
| 3982 | 4036 | |
| 3983 | 4037 | // restore the main window's active state |
| 3984 | 4038 | if (activateMainWindow && !loadScriptFromEditor) { |
| @@ -3989,6 +4043,22 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 4 unmodified lines | ||
| 3989 | 4043 | return scriptEngine; |
| 3990 | 4044 | } |
| 3991 | 4045 | |
| 4046 | +void 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 | + | |
| 4057 | +void 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 | + | |
| 3992 | 4062 | void Application::scriptFinished(const QString& scriptName) { |
| 3993 | 4063 | const QString& scriptURLString = QUrl(scriptName).toString(); |
| 3994 | 4064 | QHash<QString, ScriptEngine*>::iterator it = _scriptEnginesHash.find(scriptURLString); |
| @@ -4189,7 +4259,7 @@ void Application::toggleLogDialog() { · 194 unmodified lines | ||
| 4189 | 4259 | } |
| 4190 | 4260 | |
| 4191 | 4261 | void Application::initAvatarAndViewFrustum() { |
| 4192 | − updateMyAvatar(0.f); | |
| 4262 | + updateMyAvatar(0.0f); | |
| 4193 | 4263 | } |
| 4194 | 4264 | |
| 4195 | 4265 | void Application::checkVersion() { |
| @@ -4315,8 +4385,6 @@ bool Application::isVSyncOn() const { · 119 unmodified lines | ||
| 4315 | 4385 | if (wglewGetExtension("WGL_EXT_swap_control")) { |
| 4316 | 4386 | int swapInterval = wglGetSwapIntervalEXT(); |
| 4317 | 4387 | return (swapInterval > 0); |
| 4318 | − } else { | |
| 4319 | − return true; | |
| 4320 | 4388 | } |
| 4321 | 4389 | #elif defined(Q_OS_LINUX) |
| 4322 | 4390 | // TODO: write the poper code for linux |
| @@ -4327,10 +4395,9 @@ bool Application::isVSyncOn() const { · 4 unmodified lines | ||
| 4327 | 4395 | } else { |
| 4328 | 4396 | return true; |
| 4329 | 4397 | } |
| 4330 | − */ | |
| 4331 | −#else | |
| 4332 | − return true; | |
| 4398 | + */ | |
| 4333 | 4399 | #endif |
| 4400 | + return true; | |
| 4334 | 4401 | } |
| 4335 | 4402 | |
| 4336 | 4403 | bool Application::isVSyncEditable() const { |
| @@ -4345,7 +4412,6 @@ bool Application::isVSyncEditable() const { · 8 unmodified lines | ||
| 4345 | 4412 | return true; |
| 4346 | 4413 | } |
| 4347 | 4414 | */ |
| 4348 | −#else | |
| 4349 | 4415 | #endif |
| 4350 | 4416 | return false; |
| 4351 | 4417 | } |
| @@ -4367,7 +4433,7 @@ unsigned int Application::getRenderTargetFramerate() const { · 15 unmodified lines | ||
| 4367 | 4433 | |
| 4368 | 4434 | float Application::getRenderResolutionScale() const { |
| 4369 | 4435 | if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) { |
| 4370 | − return 1.f; | |
| 4436 | + return 1.0f; | |
| 4371 | 4437 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) { |
| 4372 | 4438 | return 0.666f; |
| 4373 | 4439 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) { |
| @@ -4377,6 +4443,6 @@ float Application::getRenderResolutionScale() const { · 3 unmodified lines | ||
| 4377 | 4443 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) { |
| 4378 | 4444 | return 0.25f; |
| 4379 | 4445 | } else { |
| 4380 | − return 1.f; | |
| 4446 | + return 1.0f; | |
| 4381 | 4447 | } |
| 4382 | 4448 | } |