Showing the changes to interface/src/Application.cpp (1 of 27 files). Show all
Unified · Split
| @@ -26,17 +26,11 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "InterfaceConfig.h" |
| 27 | 27 | |
| 28 | 28 | #include <QActionGroup> |
| 29 | −#include <QBoxLayout> | |
| 30 | 29 | #include <QColorDialog> |
| 31 | −#include <QDialogButtonBox> | |
| 32 | 30 | #include <QDesktopWidget> |
| 33 | −#include <QDoubleSpinBox> | |
| 34 | 31 | #include <QCheckBox> |
| 35 | −#include <QFormLayout> | |
| 36 | −#include <QGLWidget> | |
| 37 | 32 | #include <QImage> |
| 38 | 33 | #include <QKeyEvent> |
| 39 | −#include <QLineEdit> | |
| 40 | 34 | #include <QMainWindow> |
| 41 | 35 | #include <QMenuBar> |
| 42 | 36 | #include <QMouseEvent> |
| @@ -64,6 +58,7 @@ · 21 unmodified lines | ||
| 64 | 58 | #include "Application.h" |
| 65 | 59 | #include "LogDisplay.h" |
| 66 | 60 | #include "LeapManager.h" |
| 61 | +#include "Menu.h" | |
| 67 | 62 | #include "OculusManager.h" |
| 68 | 63 | #include "Util.h" |
| 69 | 64 | #include "renderer/ProgramObject.h" |
| @@ -79,11 +74,6 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt"; · 9 unmodified lines | ||
| 79 | 74 | |
| 80 | 75 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored |
| 81 | 76 | |
| 82 | −// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found) | |
| 83 | −// this is basically in the center of the ground plane. Slightly adjusted. This was asked for by | |
| 84 | −// Grayson as he's building a street around here for demo dinner 2 | |
| 85 | −const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE); | |
| 86 | − | |
| 87 | 77 | const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff |
| 88 | 78 | // in the idle loop? (60 FPS is default) |
| 89 | 79 | static QTimer* idleTimer = NULL; |
| @@ -92,87 +82,6 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 2 unmodified lines | ||
| 92 | 82 | // Startup optimistically with small jitter buffer that |
| 93 | 83 | // will start playback on the second received audio packet. |
| 94 | 84 | |
| 95 | −// customized canvas that simply forwards requests/events to the singleton application | |
| 96 | −class GLCanvas : public QGLWidget { | |
| 97 | −public: | |
| 98 | − GLCanvas(); | |
| 99 | −protected: | |
| 100 | − | |
| 101 | − virtual void initializeGL(); | |
| 102 | − virtual void paintGL(); | |
| 103 | − virtual void resizeGL(int width, int height); | |
| 104 | − | |
| 105 | − virtual void keyPressEvent(QKeyEvent* event); | |
| 106 | − virtual void keyReleaseEvent(QKeyEvent* event); | |
| 107 | − | |
| 108 | − virtual void mouseMoveEvent(QMouseEvent* event); | |
| 109 | − virtual void mousePressEvent(QMouseEvent* event); | |
| 110 | − virtual void mouseReleaseEvent(QMouseEvent* event); | |
| 111 | − | |
| 112 | − virtual bool event(QEvent* event); | |
| 113 | − | |
| 114 | − virtual void wheelEvent(QWheelEvent* event); | |
| 115 | −}; | |
| 116 | − | |
| 117 | −GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)) { | |
| 118 | −} | |
| 119 | − | |
| 120 | −void GLCanvas::initializeGL() { | |
| 121 | − Application::getInstance()->initializeGL(); | |
| 122 | − setAttribute(Qt::WA_AcceptTouchEvents); | |
| 123 | −} | |
| 124 | − | |
| 125 | −void GLCanvas::paintGL() { | |
| 126 | − Application::getInstance()->paintGL(); | |
| 127 | −} | |
| 128 | − | |
| 129 | −void GLCanvas::resizeGL(int width, int height) { | |
| 130 | − Application::getInstance()->resizeGL(width, height); | |
| 131 | −} | |
| 132 | − | |
| 133 | −void GLCanvas::keyPressEvent(QKeyEvent* event) { | |
| 134 | − Application::getInstance()->keyPressEvent(event); | |
| 135 | −} | |
| 136 | − | |
| 137 | −void GLCanvas::keyReleaseEvent(QKeyEvent* event) { | |
| 138 | − Application::getInstance()->keyReleaseEvent(event); | |
| 139 | −} | |
| 140 | − | |
| 141 | −void GLCanvas::mouseMoveEvent(QMouseEvent* event) { | |
| 142 | − Application::getInstance()->mouseMoveEvent(event); | |
| 143 | −} | |
| 144 | − | |
| 145 | −void GLCanvas::mousePressEvent(QMouseEvent* event) { | |
| 146 | − Application::getInstance()->mousePressEvent(event); | |
| 147 | −} | |
| 148 | − | |
| 149 | −void GLCanvas::mouseReleaseEvent(QMouseEvent* event) { | |
| 150 | − Application::getInstance()->mouseReleaseEvent(event); | |
| 151 | −} | |
| 152 | − | |
| 153 | −int updateTime = 0; | |
| 154 | −bool GLCanvas::event(QEvent* event) { | |
| 155 | − switch (event->type()) { | |
| 156 | − case QEvent::TouchBegin: | |
| 157 | − Application::getInstance()->touchBeginEvent(static_cast<QTouchEvent*>(event)); | |
| 158 | − event->accept(); | |
| 159 | − return true; | |
| 160 | − case QEvent::TouchEnd: | |
| 161 | − Application::getInstance()->touchEndEvent(static_cast<QTouchEvent*>(event)); | |
| 162 | − return true; | |
| 163 | − case QEvent::TouchUpdate: | |
| 164 | − Application::getInstance()->touchUpdateEvent(static_cast<QTouchEvent*>(event)); | |
| 165 | − return true; | |
| 166 | − default: | |
| 167 | − break; | |
| 168 | − } | |
| 169 | − return QGLWidget::event(event); | |
| 170 | −} | |
| 171 | − | |
| 172 | −void GLCanvas::wheelEvent(QWheelEvent* event) { | |
| 173 | − Application::getInstance()->wheelEvent(event); | |
| 174 | −} | |
| 175 | − | |
| 176 | 85 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 177 | 86 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); |
| 178 | 87 | LogDisplay::instance.addMessage(message.toLocal8Bit().constData()); |
| @@ -182,21 +91,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines | ||
| 182 | 91 | QApplication(argc, argv), |
| 183 | 92 | _window(new QMainWindow(desktop())), |
| 184 | 93 | _glWidget(new GLCanvas()), |
| 185 | − _bandwidthDialog(NULL), | |
| 186 | − _voxelStatsDialog(NULL), | |
| 187 | 94 | _displayLevels(false), |
| 188 | 95 | _frameCount(0), |
| 189 | 96 | _fps(120.0f), |
| 190 | 97 | _justStarted(true), |
| 191 | − _particleSystemInitialized(false), | |
| 192 | − _coolDemoParticleEmitter(-1), | |
| 193 | 98 | _wantToKillLocalVoxels(false), |
| 194 | − _frustumDrawingMode(FRUSTUM_DRAW_MODE_ALL), | |
| 195 | − _viewFrustumOffsetYaw(-135.0), | |
| 196 | − _viewFrustumOffsetPitch(0.0), | |
| 197 | − _viewFrustumOffsetRoll(0.0), | |
| 198 | − _viewFrustumOffsetDistance(25.0), | |
| 199 | − _viewFrustumOffsetUp(0.0), | |
| 200 | 99 | _audioScope(256, 200, true), |
| 201 | 100 | _mouseX(0), |
| 202 | 101 | _mouseY(0), |
| @@ -254,7 +153,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 51 unmodified lines | ||
| 254 | 153 | } |
| 255 | 154 | |
| 256 | 155 | // setup QSettings |
| 257 | −#ifdef Q_WS_MAC | |
| 156 | +#ifdef Q_OS_MAC | |
| 258 | 157 | QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; |
| 259 | 158 | #else |
| 260 | 159 | QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources"; |
| @@ -311,13 +210,16 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 50 unmodified lines | ||
| 311 | 210 | |
| 312 | 211 | _window->setCentralWidget(_glWidget); |
| 313 | 212 | |
| 314 | −#if defined(Q_WS_MAC) && defined(QT_NO_DEBUG) | |
| 213 | +#if defined(Q_OS_MAC) && defined(QT_NO_DEBUG) | |
| 315 | 214 | // if this is a release OS X build use fervor to check for an update |
| 316 | 215 | FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml"); |
| 317 | 216 | FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); |
| 318 | 217 | #endif |
| 319 | 218 | |
| 320 | − initMenu(); | |
| 219 | + // call Menu getInstance static method to set up the menu | |
| 220 | + _window->setMenuBar(Menu::getInstance()); | |
| 221 | + | |
| 222 | + _networkAccessManager = new QNetworkAccessManager(this); | |
| 321 | 223 | |
| 322 | 224 | QRect available = desktop()->availableGeometry(); |
| 323 | 225 | _window->resize(available.size()); |
| @@ -456,14 +358,16 @@ void Application::paintGL() { · 132 unmodified lines | ||
| 456 | 358 | // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera |
| 457 | 359 | Camera whichCamera = _myCamera; |
| 458 | 360 | |
| 459 | − if (_frustumOn->isChecked()) { | |
| 361 | + if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { | |
| 362 | + | |
| 363 | + ViewFrustumOffset viewFrustumOffset = Menu::getInstance()->getViewFrustumOffset(); | |
| 460 | 364 | |
| 461 | 365 | // set the camera to third-person view but offset so we can see the frustum |
| 462 | 366 | _viewFrustumOffsetCamera.setTargetPosition(_myCamera.getTargetPosition()); |
| 463 | 367 | _viewFrustumOffsetCamera.setTargetRotation(_myCamera.getTargetRotation() * glm::quat(glm::radians(glm::vec3( |
| 464 | − _viewFrustumOffsetPitch, _viewFrustumOffsetYaw, _viewFrustumOffsetRoll)))); | |
| 465 | − _viewFrustumOffsetCamera.setUpShift (_viewFrustumOffsetUp ); | |
| 466 | − _viewFrustumOffsetCamera.setDistance (_viewFrustumOffsetDistance); | |
| 368 | + viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll)))); | |
| 369 | + _viewFrustumOffsetCamera.setUpShift(viewFrustumOffset.up); | |
| 370 | + _viewFrustumOffsetCamera.setDistance(viewFrustumOffset.distance); | |
| 467 | 371 | _viewFrustumOffsetCamera.initialize(); // force immediate snap to ideal position and orientation |
| 468 | 372 | _viewFrustumOffsetCamera.update(1.f/_fps); |
| 469 | 373 | whichCamera = _viewFrustumOffsetCamera; |
| @@ -493,7 +397,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 23 unmodified lines | ||
| 493 | 397 | camera.setFieldOfView(2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf)); |
| 494 | 398 | } else { |
| 495 | 399 | camera.setAspectRatio(aspectRatio); |
| 496 | − camera.setFieldOfView(_fieldOfView); | |
| 400 | + camera.setFieldOfView(Menu::getInstance()->getFieldOfView()); | |
| 497 | 401 | } |
| 498 | 402 | } |
| 499 | 403 | |
| @@ -523,7 +427,7 @@ void Application::resizeGL(int width, int height) { · 23 unmodified lines | ||
| 523 | 427 | |
| 524 | 428 | // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the |
| 525 | 429 | // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum |
| 526 | − if (_frustumOn->isChecked()) { | |
| 430 | + if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { | |
| 527 | 431 | nearVal = _viewFrustumOffsetCamera.getNearClip(); |
| 528 | 432 | farVal = _viewFrustumOffsetCamera.getFarClip(); |
| 529 | 433 | } |
| @@ -539,7 +443,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 9 unmodified lines | ||
| 539 | 443 | for (int i = 0; i < numNodeTypes; ++i) { |
| 540 | 444 | |
| 541 | 445 | // Intercept data to voxel server when voxels are disabled |
| 542 | − if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && ! self->_renderVoxels->isChecked()) { | |
| 446 | + if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { | |
| 543 | 447 | continue; |
| 544 | 448 | } |
| 545 | 449 | |
| @@ -581,53 +485,25 @@ void Application::keyPressEvent(QKeyEvent* event) { · 35 unmodified lines | ||
| 581 | 485 | } |
| 582 | 486 | |
| 583 | 487 | //this is for switching between modes for the leap rave glove test |
| 584 | − if (_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()) { | |
| 488 | + if (Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand) | |
| 489 | + || Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove)) { | |
| 585 | 490 | _myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event); |
| 586 | 491 | } |
| 587 | 492 | |
| 588 | − bool isMeta = event->modifiers().testFlag(Qt::MetaModifier); | |
| 589 | 493 | bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier); |
| 590 | 494 | switch (event->key()) { |
| 591 | 495 | case Qt::Key_BracketLeft: |
| 592 | − _viewFrustumOffsetYaw -= 0.5; | |
| 593 | − break; | |
| 594 | − | |
| 595 | 496 | case Qt::Key_BracketRight: |
| 596 | − _viewFrustumOffsetYaw += 0.5; | |
| 597 | − break; | |
| 598 | − | |
| 599 | 497 | case Qt::Key_BraceLeft: |
| 600 | − _viewFrustumOffsetPitch -= 0.5; | |
| 601 | − break; | |
| 602 | − | |
| 603 | 498 | case Qt::Key_BraceRight: |
| 604 | − _viewFrustumOffsetPitch += 0.5; | |
| 605 | − break; | |
| 606 | − | |
| 607 | 499 | case Qt::Key_ParenLeft: |
| 608 | − _viewFrustumOffsetRoll -= 0.5; | |
| 609 | − break; | |
| 610 | − | |
| 611 | 500 | case Qt::Key_ParenRight: |
| 612 | − _viewFrustumOffsetRoll += 0.5; | |
| 613 | − break; | |
| 614 | − | |
| 615 | 501 | case Qt::Key_Less: |
| 616 | − _viewFrustumOffsetDistance -= 0.5; | |
| 617 | − break; | |
| 618 | − | |
| 619 | 502 | case Qt::Key_Greater: |
| 620 | − _viewFrustumOffsetDistance += 0.5; | |
| 621 | − break; | |
| 622 | − | |
| 623 | 503 | case Qt::Key_Comma: |
| 624 | − _viewFrustumOffsetUp -= 0.05; | |
| 625 | − break; | |
| 626 | − | |
| 627 | 504 | case Qt::Key_Period: |
| 628 | − _viewFrustumOffsetUp += 0.05; | |
| 505 | + Menu::getInstance()->handleViewFrustumOffsetKeyModifier(event->key()); | |
| 629 | 506 | break; |
| 630 | − | |
| 631 | 507 | case Qt::Key_Semicolon: |
| 632 | 508 | _audio.ping(); |
| 633 | 509 | break; |
| @@ -647,9 +523,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines | ||
| 647 | 523 | |
| 648 | 524 | case Qt::Key_C: |
| 649 | 525 | if (isShifted) { |
| 650 | − _occlusionCulling->trigger(); | |
| 651 | − } else if (isMeta) { | |
| 652 | − chooseVoxelPaintColor(); | |
| 526 | + Menu::getInstance()->triggerOption(MenuOption::OcclusionCulling); | |
| 653 | 527 | } else { |
| 654 | 528 | _myAvatar.setDriveKeys(DOWN, 1); |
| 655 | 529 | } |
| @@ -661,7 +535,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | ||
| 661 | 535 | |
| 662 | 536 | case Qt::Key_S: |
| 663 | 537 | if (isShifted) { |
| 664 | − doTreeStats(); | |
| 538 | + _voxels.collectStatsForTreesAndVBOs(); | |
| 665 | 539 | } else { |
| 666 | 540 | _myAvatar.setDriveKeys(BACK, 1); |
| 667 | 541 | } |
| @@ -674,15 +548,15 @@ void Application::keyPressEvent(QKeyEvent* event) { · 6 unmodified lines | ||
| 674 | 548 | |
| 675 | 549 | case Qt::Key_G: |
| 676 | 550 | if (isShifted) { |
| 677 | − _gravityUse->trigger(); | |
| 551 | + Menu::getInstance()->triggerOption(MenuOption::Gravity); | |
| 678 | 552 | } else { |
| 679 | − _eyedropperMode->trigger(); | |
| 553 | + Menu::getInstance()->triggerOption(MenuOption::VoxelGetColorMode); | |
| 680 | 554 | } |
| 681 | 555 | break; |
| 682 | 556 | |
| 683 | 557 | case Qt::Key_A: |
| 684 | 558 | if (isShifted) { |
| 685 | − _renderAtmosphereOn->trigger(); | |
| 559 | + Menu::getInstance()->triggerOption(MenuOption::Atmosphere); | |
| 686 | 560 | } else { |
| 687 | 561 | _myAvatar.setDriveKeys(ROT_LEFT, 1); |
| 688 | 562 | } |
| @@ -775,56 +649,53 @@ void Application::keyPressEvent(QKeyEvent* event) { · 86 unmodified lines | ||
| 775 | 649 | } |
| 776 | 650 | resizeGL(_glWidget->width(), _glWidget->height()); |
| 777 | 651 | break; |
| 778 | − case Qt::Key_N: | |
| 779 | − _noise->trigger(); | |
| 780 | − break; | |
| 781 | 652 | case Qt::Key_H: |
| 782 | − _lookingInMirror->trigger(); | |
| 653 | + Menu::getInstance()->triggerOption(MenuOption::Mirror); | |
| 783 | 654 | break; |
| 784 | 655 | case Qt::Key_F: |
| 785 | 656 | if (isShifted) { |
| 786 | − _frustumOn->trigger(); | |
| 657 | + Menu::getInstance()->triggerOption(MenuOption::DisplayFrustum); | |
| 787 | 658 | } else { |
| 788 | − _fullScreenMode->trigger(); | |
| 659 | + Menu::getInstance()->triggerOption(MenuOption::Fullscreen); | |
| 789 | 660 | } |
| 790 | 661 | break; |
| 791 | 662 | case Qt::Key_V: |
| 792 | 663 | if (isShifted) { |
| 793 | − _renderVoxels->trigger(); | |
| 664 | + Menu::getInstance()->triggerOption(MenuOption::Voxels); | |
| 794 | 665 | } else { |
| 795 | − _addVoxelMode->trigger(); | |
| 666 | + Menu::getInstance()->triggerOption(MenuOption::VoxelAddMode); | |
| 796 | 667 | } |
| 797 | 668 | break; |
| 798 | 669 | case Qt::Key_P: |
| 799 | − _manualFirstPerson->trigger(); | |
| 670 | + Menu::getInstance()->triggerOption(MenuOption::FirstPerson); | |
| 800 | 671 | break; |
| 801 | 672 | case Qt::Key_R: |
| 802 | 673 | if (isShifted) { |
| 803 | − _frustumRenderModeAction->trigger(); | |
| 674 | + Menu::getInstance()->triggerOption(MenuOption::FrustumRenderMode); | |
| 804 | 675 | } else { |
| 805 | − _deleteVoxelMode->trigger(); | |
| 676 | + Menu::getInstance()->triggerOption(MenuOption::VoxelDeleteMode); | |
| 806 | 677 | } |
| 807 | 678 | break; |
| 808 | 679 | case Qt::Key_B: |
| 809 | − _colorVoxelMode->trigger(); | |
| 680 | + Menu::getInstance()->triggerOption(MenuOption::VoxelColorMode); | |
| 810 | 681 | break; |
| 811 | 682 | case Qt::Key_O: |
| 812 | − _selectVoxelMode->trigger(); | |
| 683 | + Menu::getInstance()->triggerOption(MenuOption::VoxelSelectMode); | |
| 813 | 684 | break; |
| 814 | 685 | case Qt::Key_Slash: |
| 815 | − _renderStatsOn->trigger(); | |
| 686 | + Menu::getInstance()->triggerOption(MenuOption::Stats); | |
| 816 | 687 | break; |
| 817 | 688 | case Qt::Key_Backspace: |
| 818 | 689 | case Qt::Key_Delete: |
| 819 | − if (_selectVoxelMode->isChecked()) { | |
| 690 | + if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) { | |
| 820 | 691 | deleteVoxelUnderCursor(); |
| 821 | 692 | } |
| 822 | 693 | break; |
| 823 | 694 | case Qt::Key_Plus: |
| 824 | − increaseAvatarSize(); | |
| 695 | + _myAvatar.increaseSize(); | |
| 825 | 696 | break; |
| 826 | 697 | case Qt::Key_Minus: |
| 827 | − decreaseAvatarSize(); | |
| 698 | + _myAvatar.decreaseSize(); | |
| 828 | 699 | break; |
| 829 | 700 | |
| 830 | 701 | case Qt::Key_1: |
| @@ -835,7 +706,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines | ||
| 835 | 706 | case Qt::Key_6: |
| 836 | 707 | case Qt::Key_7: |
| 837 | 708 | case Qt::Key_8: |
| 838 | − _swatch.handleEvent(event->key(), _eyedropperMode->isChecked()); | |
| 709 | + _swatch.handleEvent(event->key(), Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode)); | |
| 839 | 710 | break; |
| 840 | 711 | default: |
| 841 | 712 | event->ignore(); |
| @@ -914,7 +785,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 72 unmodified lines | ||
| 914 | 785 | if (event->buttons().testFlag(Qt::LeftButton)) { |
| 915 | 786 | maybeEditVoxelUnderCursor(); |
| 916 | 787 | |
| 917 | − } else if (event->buttons().testFlag(Qt::RightButton) && checkedVoxelModeAction() != 0) { | |
| 788 | + } else if (event->buttons().testFlag(Qt::RightButton) && Menu::getInstance()->isVoxelModeActionChecked()) { | |
| 918 | 789 | deleteVoxelUnderCursor(); |
| 919 | 790 | } |
| 920 | 791 | } |
| @@ -962,7 +833,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 41 unmodified lines | ||
| 962 | 833 | _isHoverVoxelSounding = true; |
| 963 | 834 | } |
| 964 | 835 | |
| 965 | − } else if (event->button() == Qt::RightButton && checkedVoxelModeAction() != 0) { | |
| 836 | + } else if (event->button() == Qt::RightButton && Menu::getInstance()->isVoxelModeActionChecked()) { | |
| 966 | 837 | deleteVoxelUnderCursor(); |
| 967 | 838 | } |
| 968 | 839 | } |
| @@ -1021,7 +892,7 @@ const bool USE_MOUSEWHEEL = false; · 52 unmodified lines | ||
| 1021 | 892 | void Application::wheelEvent(QWheelEvent* event) { |
| 1022 | 893 | // Wheel Events disabled for now because they are also activated by touch look pitch up/down. |
| 1023 | 894 | if (USE_MOUSEWHEEL && (activeWindow() == _window)) { |
| 1024 | − if (checkedVoxelModeAction() == 0) { | |
| 895 | + if (!Menu::getInstance()->isVoxelModeActionChecked()) { | |
| 1025 | 896 | event->ignore(); |
| 1026 | 897 | return; |
| 1027 | 898 | } |
| @@ -1081,7 +952,7 @@ void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& d · 53 unmodified lines | ||
| 1081 | 952 | void Application::timer() { |
| 1082 | 953 | gettimeofday(&_timerEnd, NULL); |
| 1083 | 954 | |
| 1084 | − if (_testPing->isChecked()) { | |
| 955 | + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { | |
| 1085 | 956 | sendPingPackets(); |
| 1086 | 957 | } |
| 1087 | 958 | |
| @@ -1157,8 +1028,8 @@ void Application::terminate() { · 69 unmodified lines | ||
| 1157 | 1028 | |
| 1158 | 1029 | LeapManager::terminate(); |
| 1159 | 1030 | |
| 1160 | − if (_settingsAutosave->isChecked()) { | |
| 1161 | − saveSettings(); | |
| 1031 | + if (Menu::getInstance()->isOptionChecked(MenuOption::SettingsAutosave)) { | |
| 1032 | + Menu::getInstance()->saveSettings(); | |
| 1162 | 1033 | _settings->sync(); |
| 1163 | 1034 | } |
| 1164 | 1035 | |
| @@ -1171,24 +1042,6 @@ void Application::terminate() { · 6 unmodified lines | ||
| 1171 | 1042 | _voxelEditSender.terminate(); |
| 1172 | 1043 | } |
| 1173 | 1044 | |
| 1174 | −void Application::sendAvatarVoxelURLMessage(const QUrl& url) { | |
| 1175 | − uint16_t ownerID = NodeList::getInstance()->getOwnerID(); | |
| 1176 | − | |
| 1177 | − if (ownerID == UNKNOWN_NODE_ID) { | |
| 1178 | − return; // we don't yet know who we are | |
| 1179 | − } | |
| 1180 | − QByteArray message; | |
| 1181 | − | |
| 1182 | − char packetHeader[MAX_PACKET_HEADER_BYTES]; | |
| 1183 | − int numBytesPacketHeader = populateTypeAndVersion((unsigned char*) packetHeader, PACKET_TYPE_AVATAR_VOXEL_URL); | |
| 1184 | − | |
| 1185 | − message.append(packetHeader, numBytesPacketHeader); | |
| 1186 | − message.append((const char*)&ownerID, sizeof(ownerID)); | |
| 1187 | − message.append(url.toEncoded()); | |
| 1188 | − | |
| 1189 | − controlledBroadcastToNodes((unsigned char*)message.data(), message.size(), & NODE_TYPE_AVATAR_MIXER, 1); | |
| 1190 | −} | |
| 1191 | − | |
| 1192 | 1045 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| 1193 | 1046 | // record the packet for stats-tracking |
| 1194 | 1047 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); |
| @@ -1238,207 +1091,22 @@ void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_ · 43 unmodified lines | ||
| 1238 | 1091 | void Application::checkBandwidthMeterClick() { |
| 1239 | 1092 | // ... to be called upon button release |
| 1240 | 1093 | |
| 1241 | − if (_bandwidthDisplayOn->isChecked() && | |
| 1094 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) && | |
| 1242 | 1095 | glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY))) <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH && |
| 1243 | 1096 | _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) { |
| 1244 | 1097 | |
| 1245 | 1098 | // The bandwidth meter is visible, the click didn't get dragged too far and |
| 1246 | 1099 | // we actually hit the bandwidth meter |
| 1247 | − bandwidthDetails(); | |
| 1100 | + Menu::getInstance()->bandwidthDetails(); | |
| 1248 | 1101 | } |
| 1249 | 1102 | } |
| 1250 | 1103 | |
| 1251 | −void Application::bandwidthDetails() { | |
| 1252 | − | |
| 1253 | − if (! _bandwidthDialog) { | |
| 1254 | − _bandwidthDialog = new BandwidthDialog(_glWidget, getBandwidthMeter()); | |
| 1255 | − connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed())); | |
| 1256 | − | |
| 1257 | − _bandwidthDialog->show(); | |
| 1258 | − } | |
| 1259 | − _bandwidthDialog->raise(); | |
| 1260 | −} | |
| 1261 | − | |
| 1262 | −void Application::bandwidthDetailsClosed() { | |
| 1263 | − | |
| 1264 | − QDialog* dlg = _bandwidthDialog; | |
| 1265 | − _bandwidthDialog = NULL; | |
| 1266 | − delete dlg; | |
| 1267 | −} | |
| 1268 | − | |
| 1269 | −void Application::voxelStatsDetails() { | |
| 1270 | − if (!_voxelStatsDialog) { | |
| 1271 | − _voxelStatsDialog = new VoxelStatsDialog(_glWidget, &_voxelSceneStats); | |
| 1272 | − connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed())); | |
| 1273 | − _voxelStatsDialog->show(); | |
| 1274 | − } | |
| 1275 | − _voxelStatsDialog->raise(); | |
| 1276 | −} | |
| 1277 | − | |
| 1278 | −void Application::voxelStatsDetailsClosed() { | |
| 1279 | − QDialog* dlg = _voxelStatsDialog; | |
| 1280 | − _voxelStatsDialog = NULL; | |
| 1281 | − delete dlg; | |
| 1282 | −} | |
| 1283 | − | |
| 1284 | −void Application::editPreferences() { | |
| 1285 | − QDialog dialog(_glWidget); | |
| 1286 | − dialog.setWindowTitle("Interface Preferences"); | |
| 1287 | − QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom); | |
| 1288 | − dialog.setLayout(layout); | |
| 1289 | − | |
| 1290 | − QFormLayout* form = new QFormLayout(); | |
| 1291 | − layout->addLayout(form, 1); | |
| 1292 | − | |
| 1293 | − const int QLINE_MINIMUM_WIDTH = 400; | |
| 1294 | − | |
| 1295 | − QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname())); | |
| 1296 | − domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH); | |
| 1297 | − form->addRow("Domain server:", domainServerHostname); | |
| 1298 | − | |
| 1299 | − QLineEdit* avatarURL = new QLineEdit(_myAvatar.getVoxels()->getVoxelURL().toString()); | |
| 1300 | − avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH); | |
| 1301 | − form->addRow("Avatar URL:", avatarURL); | |
| 1302 | − | |
| 1303 | − QSpinBox* fieldOfView = new QSpinBox(); | |
| 1304 | − fieldOfView->setMaximum(180); | |
| 1305 | − fieldOfView->setMinimum(1); | |
| 1306 | − fieldOfView->setValue(_fieldOfView); | |
| 1307 | − form->addRow("Vertical Field of View (Degrees):", fieldOfView); | |
| 1308 | − | |
| 1309 | − QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox(); | |
| 1310 | − gyroCameraSensitivity->setValue(_gyroCameraSensitivity); | |
| 1311 | − form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity); | |
| 1312 | − | |
| 1313 | − QDoubleSpinBox* leanScale = new QDoubleSpinBox(); | |
| 1314 | − leanScale->setValue(_myAvatar.getLeanScale()); | |
| 1315 | − form->addRow("Lean Scale:", leanScale); | |
| 1316 | − | |
| 1317 | − QSpinBox* audioJitterBufferSamples = new QSpinBox(); | |
| 1318 | − audioJitterBufferSamples->setMaximum(10000); | |
| 1319 | − audioJitterBufferSamples->setMinimum(-10000); | |
| 1320 | − audioJitterBufferSamples->setValue(_audioJitterBufferSamples); | |
| 1321 | − form->addRow("Audio Jitter Buffer Samples (0 for automatic):", audioJitterBufferSamples); | |
| 1322 | − | |
| 1323 | − QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | |
| 1324 | − dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); | |
| 1325 | − dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject())); | |
| 1326 | − layout->addWidget(buttons); | |
| 1327 | − | |
| 1328 | − if (dialog.exec() != QDialog::Accepted) { | |
| 1329 | − return; | |
| 1330 | − } | |
| 1331 | − | |
| 1332 | − QByteArray newHostname; | |
| 1333 | − | |
| 1334 | − if (domainServerHostname->text().size() > 0) { | |
| 1335 | − // the user input a new hostname, use that | |
| 1336 | − newHostname = domainServerHostname->text().toLocal8Bit(); | |
| 1337 | − } else { | |
| 1338 | − // the user left the field blank, use the default hostname | |
| 1339 | − newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME); | |
| 1340 | − } | |
| 1341 | − | |
| 1342 | − // check if the domain server hostname is new | |
| 1343 | − if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) { | |
| 1344 | − | |
| 1345 | − NodeList::getInstance()->clear(); | |
| 1346 | − | |
| 1347 | − // kill the local voxels | |
| 1348 | − _voxels.killLocalVoxels(); | |
| 1349 | − | |
| 1350 | − // reset the environment to default | |
| 1351 | − _environment.resetToDefault(); | |
| 1352 | − | |
| 1353 | − // set the new hostname | |
| 1354 | − NodeList::getInstance()->setDomainHostname(newHostname.constData()); | |
| 1355 | − } | |
| 1356 | − | |
| 1357 | − QUrl url(avatarURL->text()); | |
| 1358 | − _myAvatar.getVoxels()->setVoxelURL(url); | |
| 1359 | − sendAvatarVoxelURLMessage(url); | |
| 1360 | − | |
| 1361 | − _gyroCameraSensitivity = gyroCameraSensitivity->value(); | |
| 1362 | − _myAvatar.setLeanScale(leanScale->value()); | |
| 1363 | − _audioJitterBufferSamples = audioJitterBufferSamples->value(); | |
| 1364 | − if (!shouldDynamicallySetJitterBuffer()) { | |
| 1365 | − _audio.setJitterBufferSamples(_audioJitterBufferSamples); | |
| 1366 | − } | |
| 1367 | − _fieldOfView = fieldOfView->value(); | |
| 1368 | − resizeGL(_glWidget->width(), _glWidget->height()); | |
| 1369 | − | |
| 1370 | −} | |
| 1371 | − | |
| 1372 | −void Application::pair() { | |
| 1373 | − PairingHandler::sendPairRequest(); | |
| 1374 | −} | |
| 1375 | − | |
| 1376 | −void Application::setRenderMirrored(bool mirrored) { | |
| 1377 | − if (mirrored) { | |
| 1378 | − _manualFirstPerson->setChecked(false); | |
| 1379 | − _manualThirdPerson->setChecked(false); | |
| 1380 | − } | |
| 1381 | −} | |
| 1382 | − | |
| 1383 | −void Application::setNoise(bool noise) { | |
| 1384 | − _myAvatar.setNoise(noise); | |
| 1385 | −} | |
| 1386 | − | |
| 1387 | 1104 | void Application::setFullscreen(bool fullscreen) { |
| 1388 | 1105 | _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) : |
| 1389 | 1106 | (_window->windowState() & ~Qt::WindowFullScreen)); |
| 1390 | 1107 | updateCursor(); |
| 1391 | 1108 | } |
| 1392 | 1109 | |
| 1393 | −void Application::setRenderFirstPerson(bool firstPerson) { | |
| 1394 | − if (firstPerson) { | |
| 1395 | − _lookingInMirror->setChecked(false); | |
| 1396 | − _manualThirdPerson->setChecked(false); | |
| 1397 | − } else { | |
| 1398 | − _manualThirdPerson->trigger(); | |
| 1399 | − } | |
| 1400 | −} | |
| 1401 | − | |
| 1402 | −void Application::setRenderThirdPerson(bool thirdPerson) { | |
| 1403 | − if (thirdPerson) { | |
| 1404 | − _lookingInMirror->setChecked(false); | |
| 1405 | − _manualFirstPerson->setChecked(false); | |
| 1406 | − } | |
| 1407 | −} | |
| 1408 | − | |
| 1409 | −void Application::increaseAvatarSize() { | |
| 1410 | − if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) { | |
| 1411 | − _myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale()); | |
| 1412 | − qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); | |
| 1413 | − } | |
| 1414 | −} | |
| 1415 | − | |
| 1416 | −void Application::decreaseAvatarSize() { | |
| 1417 | − if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) { | |
| 1418 | − _myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale()); | |
| 1419 | − qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); | |
| 1420 | − } | |
| 1421 | −} | |
| 1422 | − | |
| 1423 | −void Application::resetAvatarSize() { | |
| 1424 | − _myAvatar.setNewScale(1.f); | |
| 1425 | − qDebug("Reseted scale to %f\n", _myAvatar.getNewScale()); | |
| 1426 | −} | |
| 1427 | − | |
| 1428 | −void Application::setFrustumOffset(bool frustumOffset) { | |
| 1429 | − // reshape so that OpenGL will get the right lens details for the camera of choice | |
| 1430 | − resizeGL(_glWidget->width(), _glWidget->height()); | |
| 1431 | −} | |
| 1432 | − | |
| 1433 | −void Application::cycleFrustumRenderMode() { | |
| 1434 | − _frustumDrawingMode = (FrustumDrawMode)((_frustumDrawingMode + 1) % FRUSTUM_DRAW_MODE_COUNT); | |
| 1435 | − updateFrustumRenderModeAction(); | |
| 1436 | −} | |
| 1437 | − | |
| 1438 | −void Application::setRenderWarnings(bool renderWarnings) { | |
| 1439 | − _voxels.setRenderPipelineWarnings(renderWarnings); | |
| 1440 | −} | |
| 1441 | − | |
| 1442 | 1110 | void Application::setRenderVoxels(bool voxelRender) { |
| 1443 | 1111 | _voxelEditSender.setShouldSend(voxelRender); |
| 1444 | 1112 | if (!voxelRender) { |
| @@ -1450,75 +1118,6 @@ void Application::doKillLocalVoxels() { · 5 unmodified lines | ||
| 1450 | 1118 | _wantToKillLocalVoxels = true; |
| 1451 | 1119 | } |
| 1452 | 1120 | |
| 1453 | −void Application::doRandomizeVoxelColors() { | |
| 1454 | − _voxels.randomizeVoxelColors(); | |
| 1455 | −} | |
| 1456 | − | |
| 1457 | −void Application::doFalseRandomizeVoxelColors() { | |
| 1458 | − _voxels.falseColorizeRandom(); | |
| 1459 | −} | |
| 1460 | − | |
| 1461 | −void Application::doFalseRandomizeEveryOtherVoxelColors() { | |
| 1462 | − _voxels.falseColorizeRandomEveryOther(); | |
| 1463 | −} | |
| 1464 | − | |
| 1465 | −void Application::doFalseColorizeByDistance() { | |
| 1466 | − loadViewFrustum(_myCamera, _viewFrustum); | |
| 1467 | − _voxels.falseColorizeDistanceFromView(&_viewFrustum); | |
| 1468 | −} | |
| 1469 | − | |
| 1470 | −void Application::doFalseColorizeInView() { | |
| 1471 | − loadViewFrustum(_myCamera, _viewFrustum); | |
| 1472 | − // we probably want to make sure the viewFrustum is initialized first | |
| 1473 | − _voxels.falseColorizeInView(&_viewFrustum); | |
| 1474 | −} | |
| 1475 | − | |
| 1476 | −void Application::doFalseColorizeOccluded() { | |
| 1477 | − CoverageMap::wantDebugging = true; | |
| 1478 | − _voxels.falseColorizeOccluded(); | |
| 1479 | −} | |
| 1480 | − | |
| 1481 | −void Application::doFalseColorizeOccludedV2() { | |
| 1482 | − _voxels.falseColorizeOccludedV2(); | |
| 1483 | −} | |
| 1484 | − | |
| 1485 | −void Application::doFalseColorizeBySource() { | |
| 1486 | − _voxels.falseColorizeBySource(); | |
| 1487 | −} | |
| 1488 | − | |
| 1489 | −void Application::doTrueVoxelColors() { | |
| 1490 | − _voxels.trueColorize(); | |
| 1491 | −} | |
| 1492 | − | |
| 1493 | −void Application::doTreeStats() { | |
| 1494 | − _voxels.collectStatsForTreesAndVBOs(); | |
| 1495 | −} | |
| 1496 | − | |
| 1497 | −void Application::disableLowResMoving(bool disableLowResMoving) { | |
| 1498 | − _myAvatar.setWantLowResMoving(!disableLowResMoving); | |
| 1499 | −} | |
| 1500 | − | |
| 1501 | −void Application::setWantsMonochrome(bool wantsMonochrome) { | |
| 1502 | − _myAvatar.setWantColor(!wantsMonochrome); | |
| 1503 | −} | |
| 1504 | − | |
| 1505 | −void Application::disableDeltaSending(bool disableDeltaSending) { | |
| 1506 | − _myAvatar.setWantDelta(!disableDeltaSending); | |
| 1507 | −} | |
| 1508 | − | |
| 1509 | −void Application::disableOcclusionCulling(bool disableOcclusionCulling) { | |
| 1510 | − _myAvatar.setWantOcclusionCulling(!disableOcclusionCulling); | |
| 1511 | −} | |
| 1512 | − | |
| 1513 | −void Application::updateVoxelModeActions() { | |
| 1514 | − // only the sender can be checked | |
| 1515 | − foreach (QAction* action, _voxelModeActions->actions()) { | |
| 1516 | − if (action->isChecked() && action != sender()) { | |
| 1517 | − action->setChecked(false); | |
| 1518 | − } | |
| 1519 | − } | |
| 1520 | −} | |
| 1521 | − | |
| 1522 | 1121 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { |
| 1523 | 1122 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| 1524 | 1123 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| @@ -1533,27 +1132,6 @@ void Application::increaseVoxelSize() { · 8 unmodified lines | ||
| 1533 | 1132 | _mouseVoxelScale *= 2; |
| 1534 | 1133 | } |
| 1535 | 1134 | |
| 1536 | −void Application::resetSwatchColors() { | |
| 1537 | − _swatch.reset(); | |
| 1538 | −} | |
| 1539 | − | |
| 1540 | −static QIcon createSwatchIcon(const QColor& color) { | |
| 1541 | − QPixmap map(16, 16); | |
| 1542 | − map.fill(color); | |
| 1543 | − return QIcon(map); | |
| 1544 | −} | |
| 1545 | − | |
| 1546 | −void Application::chooseVoxelPaintColor() { | |
| 1547 | − QColor selected = QColorDialog::getColor(_voxelPaintColor->data().value<QColor>(), _glWidget, "Voxel Paint Color"); | |
| 1548 | − if (selected.isValid()) { | |
| 1549 | − _voxelPaintColor->setData(selected); | |
| 1550 | − _voxelPaintColor->setIcon(createSwatchIcon(selected)); | |
| 1551 | − } | |
| 1552 | − | |
| 1553 | − // restore the main window's active state | |
| 1554 | − _window->activateWindow(); | |
| 1555 | −} | |
| 1556 | − | |
| 1557 | 1135 | const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500; |
| 1558 | 1136 | struct SendVoxelsOperationArgs { |
| 1559 | 1137 | unsigned char* newBaseOctCode; |
| @@ -1839,197 +1417,6 @@ void Application::pasteVoxels() { · 279 unmodified lines | ||
| 1839 | 1417 | } |
| 1840 | 1418 | } |
| 1841 | 1419 | |
| 1842 | −void Application::initMenu() { | |
| 1843 | − QMenuBar* menuBar = new QMenuBar(); | |
| 1844 | − _window->setMenuBar(menuBar); | |
| 1845 | − | |
| 1846 | − QMenu* fileMenu = menuBar->addMenu("File"); | |
| 1847 | − QAction* quitAction = fileMenu->addAction("Quit", this, SLOT(quit()), Qt::CTRL | Qt::Key_Q); | |
| 1848 | − quitAction->setMenuRole(QAction::QuitRole); | |
| 1849 | − | |
| 1850 | − QMenu* editMenu = menuBar->addMenu("Edit"); | |
| 1851 | − QAction* preferencesAction = editMenu->addAction("Preferences...", this, SLOT(editPreferences()), Qt::CTRL | Qt::Key_Comma); | |
| 1852 | − preferencesAction->setMenuRole(QAction::PreferencesRole); | |
| 1853 | − | |
| 1854 | − QMenu* pairMenu = menuBar->addMenu("Pair"); | |
| 1855 | − pairMenu->addAction("Pair", this, SLOT(pair())); | |
| 1856 | − | |
| 1857 | − QMenu* optionsMenu = menuBar->addMenu("Options"); | |
| 1858 | − (_lookingInMirror = optionsMenu->addAction("Mirror", this, SLOT(setRenderMirrored(bool)), Qt::Key_H))->setCheckable(true); | |
| 1859 | − | |
| 1860 | − | |
| 1861 | − (_noise = optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N))->setCheckable(true); | |
| 1862 | − (_gyroLook = optionsMenu->addAction("Smooth Gyro Look"))->setCheckable(true); | |
| 1863 | − _gyroLook->setChecked(true); | |
| 1864 | − (_showHeadMouse = optionsMenu->addAction("Head Mouse"))->setCheckable(true); | |
| 1865 | − _showHeadMouse->setChecked(false); | |
| 1866 | − (_transmitterDrives = optionsMenu->addAction("Transmitter Drive"))->setCheckable(true); | |
| 1867 | − _transmitterDrives->setChecked(true); | |
| 1868 | − (_gravityUse = optionsMenu->addAction("Use Gravity"))->setCheckable(true); | |
| 1869 | − _gravityUse->setChecked(true); | |
| 1870 | − _gravityUse->setShortcut(Qt::SHIFT | Qt::Key_G); | |
| 1871 | − (_testPing = optionsMenu->addAction("Test Ping"))->setCheckable(true); | |
| 1872 | − _testPing->setChecked(true); | |
| 1873 | − (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); | |
| 1874 | − optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); | |
| 1875 | − optionsMenu->addAction("Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true); | |
| 1876 | − (_wantCollisionsOn = optionsMenu->addAction("Turn collisions On", this, SLOT(toggleWantCollisionsOn())))->setCheckable(true); | |
| 1877 | − _wantCollisionsOn->setChecked(true); | |
| 1878 | − optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode())); | |
| 1879 | − optionsMenu->addAction("Webcam Texture", _webcam.getGrabber(), SLOT(setDepthOnly(bool)))->setCheckable(true); | |
| 1880 | − optionsMenu->addAction("Go Home", this, SLOT(goHome()), Qt::CTRL | Qt::Key_G); | |
| 1881 | − | |
| 1882 | − QMenu* audioMenu = menuBar->addMenu("Audio"); | |
| 1883 | − (_echoAudioMode = audioMenu->addAction("Echo Audio"))->setCheckable(true); | |
| 1884 | − _rawAudioMicrophoneMix = audioMenu->addAction("Mix RAW Song", this, SLOT(toggleMixedSong())); | |
| 1885 | − | |
| 1886 | − QMenu* renderMenu = menuBar->addMenu("Render"); | |
| 1887 | − (_renderVoxels = renderMenu->addAction("Voxels", this, SLOT(setRenderVoxels(bool)), Qt::SHIFT | Qt::Key_V))->setCheckable(true); | |
| 1888 | − _renderVoxels->setChecked(true); | |
| 1889 | − (_renderVoxelTextures = renderMenu->addAction("Voxel Textures"))->setCheckable(true); | |
| 1890 | − (_renderStarsOn = renderMenu->addAction("Stars"))->setCheckable(true); | |
| 1891 | − _renderStarsOn->setChecked(true); | |
| 1892 | − _renderStarsOn->setShortcut(Qt::Key_Asterisk); | |
| 1893 | − (_renderAtmosphereOn = renderMenu->addAction("Atmosphere"))->setCheckable(true); | |
| 1894 | − _renderAtmosphereOn->setChecked(true); | |
| 1895 | − _renderAtmosphereOn->setShortcut(Qt::SHIFT | Qt::Key_A); | |
| 1896 | − (_renderGroundPlaneOn = renderMenu->addAction("Ground Plane"))->setCheckable(true); | |
| 1897 | − _renderGroundPlaneOn->setChecked(true); | |
| 1898 | − (_renderAvatarsOn = renderMenu->addAction("Avatars"))->setCheckable(true); | |
| 1899 | − _renderAvatarsOn->setChecked(true); | |
| 1900 | − (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true); | |
| 1901 | − _renderAvatarBalls->setChecked(false); | |
| 1902 | − renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode())); | |
| 1903 | − renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode())); | |
| 1904 | − renderMenu->addAction("Cycle Glow Mode", &_glowEffect, SLOT(cycleRenderMode())); | |
| 1905 | − (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true); | |
| 1906 | − _renderFrameTimerOn->setChecked(false); | |
| 1907 | − (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true); | |
| 1908 | − _renderLookatOn->setChecked(false); | |
| 1909 | − (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true); | |
| 1910 | − _renderLookatIndicatorOn->setChecked(true); | |
| 1911 | − (_renderParticleSystemOn = renderMenu->addAction("Particle System"))->setCheckable(true); | |
| 1912 | − (_manualFirstPerson = renderMenu->addAction( | |
| 1913 | − "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true); | |
| 1914 | − (_manualThirdPerson = renderMenu->addAction( | |
| 1915 | − "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); | |
| 1916 | − renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus); | |
| 1917 | − renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus); | |
| 1918 | − renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize())); | |
| 1919 | − | |
| 1920 | − | |
| 1921 | − QMenu* toolsMenu = menuBar->addMenu("Tools"); | |
| 1922 | − (_renderStatsOn = toolsMenu->addAction("Stats"))->setCheckable(true); | |
| 1923 | − _renderStatsOn->setShortcut(Qt::Key_Slash); | |
| 1924 | − (_logOn = toolsMenu->addAction("Log"))->setCheckable(true); | |
| 1925 | − _logOn->setChecked(false); | |
| 1926 | − _logOn->setShortcut(Qt::CTRL | Qt::Key_L); | |
| 1927 | − (_oscilloscopeOn = toolsMenu->addAction("Audio Oscilloscope"))->setCheckable(true); | |
| 1928 | − _oscilloscopeOn->setChecked(true); | |
| 1929 | − (_bandwidthDisplayOn = toolsMenu->addAction("Bandwidth Display"))->setCheckable(true); | |
| 1930 | − _bandwidthDisplayOn->setChecked(true); | |
| 1931 | − toolsMenu->addAction("Bandwidth Details", this, SLOT(bandwidthDetails())); | |
| 1932 | − toolsMenu->addAction("Voxel Stats Details", this, SLOT(voxelStatsDetails())); | |
| 1933 | − | |
| 1934 | − | |
| 1935 | − QMenu* voxelMenu = menuBar->addMenu("Voxels"); | |
| 1936 | − _voxelModeActions = new QActionGroup(this); | |
| 1937 | − _voxelModeActions->setExclusive(false); // exclusivity implies one is always checked | |
| 1938 | − | |
| 1939 | − (_addVoxelMode = voxelMenu->addAction( | |
| 1940 | − "Add Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_V))->setCheckable(true); | |
| 1941 | − _voxelModeActions->addAction(_addVoxelMode); | |
| 1942 | − (_deleteVoxelMode = voxelMenu->addAction( | |
| 1943 | − "Delete Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_R))->setCheckable(true); | |
| 1944 | − _voxelModeActions->addAction(_deleteVoxelMode); | |
| 1945 | − (_colorVoxelMode = voxelMenu->addAction( | |
| 1946 | − "Color Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_B))->setCheckable(true); | |
| 1947 | − _voxelModeActions->addAction(_colorVoxelMode); | |
| 1948 | − (_selectVoxelMode = voxelMenu->addAction( | |
| 1949 | − "Select Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_O))->setCheckable(true); | |
| 1950 | − _voxelModeActions->addAction(_selectVoxelMode); | |
| 1951 | − (_eyedropperMode = voxelMenu->addAction( | |
| 1952 | − "Get Color Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_G))->setCheckable(true); | |
| 1953 | − _voxelModeActions->addAction(_eyedropperMode); | |
| 1954 | − | |
| 1955 | − voxelMenu->addAction("Decrease Voxel Size", this, SLOT(decreaseVoxelSize()), QKeySequence::ZoomOut); | |
| 1956 | − voxelMenu->addAction("Increase Voxel Size", this, SLOT(increaseVoxelSize()), QKeySequence::ZoomIn); | |
| 1957 | − voxelMenu->addAction("Reset Swatch Colors", this, SLOT(resetSwatchColors())); | |
| 1958 | − | |
| 1959 | − _voxelPaintColor = voxelMenu->addAction("Voxel Paint Color", this, | |
| 1960 | − SLOT(chooseVoxelPaintColor()), Qt::META | Qt::Key_C); | |
| 1961 | − _swatch.setAction(_voxelPaintColor); | |
| 1962 | − | |
| 1963 | − QColor paintColor(128, 128, 128); | |
| 1964 | − _voxelPaintColor->setData(paintColor); | |
| 1965 | − _voxelPaintColor->setIcon(createSwatchIcon(paintColor)); | |
| 1966 | − (_destructiveAddVoxel = voxelMenu->addAction("Create Voxel is Destructive"))->setCheckable(true); | |
| 1967 | − | |
| 1968 | − voxelMenu->addAction("Export Voxels", this, SLOT(exportVoxels()), Qt::CTRL | Qt::Key_E); | |
| 1969 | − voxelMenu->addAction("Import Voxels", this, SLOT(importVoxels()), Qt::CTRL | Qt::Key_I); | |
| 1970 | − voxelMenu->addAction("Import Voxels to Clipboard", this, SLOT(importVoxelsToClipboard()), Qt::SHIFT | Qt::CTRL | Qt::Key_I); | |
| 1971 | − voxelMenu->addAction("Cut Voxels", this, SLOT(cutVoxels()), Qt::CTRL | Qt::Key_X); | |
| 1972 | − voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C); | |
| 1973 | − voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V); | |
| 1974 | − | |
| 1975 | − QMenu* debugMenu = menuBar->addMenu("Debug"); | |
| 1976 | − | |
| 1977 | − QMenu* frustumMenu = debugMenu->addMenu("View Frustum Debugging Tools"); | |
| 1978 | − (_frustumOn = frustumMenu->addAction("Display Frustum"))->setCheckable(true); | |
| 1979 | − _frustumOn->setShortcut(Qt::SHIFT | Qt::Key_F); | |
| 1980 | − _frustumRenderModeAction = frustumMenu->addAction( | |
| 1981 | − "Render Mode", this, SLOT(cycleFrustumRenderMode()), Qt::SHIFT | Qt::Key_R); | |
| 1982 | − updateFrustumRenderModeAction(); | |
| 1983 | − | |
| 1984 | − debugMenu->addAction("Run Timing Tests", this, SLOT(runTests())); | |
| 1985 | − debugMenu->addAction("Calculate Tree Stats", this, SLOT(doTreeStats()), Qt::SHIFT | Qt::Key_S); | |
| 1986 | − | |
| 1987 | − QMenu* renderDebugMenu = debugMenu->addMenu("Render Debugging Tools"); | |
| 1988 | − (_renderPipelineWarnings = renderDebugMenu->addAction("Show Render Pipeline Warnings", | |
| 1989 | − this, SLOT(setRenderWarnings(bool))))->setCheckable(true); | |
| 1990 | − renderDebugMenu->addAction("Kill Local Voxels", this, SLOT(doKillLocalVoxels()), Qt::CTRL | Qt::Key_K); | |
| 1991 | − renderDebugMenu->addAction("Randomize Voxel TRUE Colors", this, SLOT(doRandomizeVoxelColors()), Qt::CTRL | Qt::Key_R); | |
| 1992 | − renderDebugMenu->addAction("FALSE Color Voxels Randomly", this, SLOT(doFalseRandomizeVoxelColors())); | |
| 1993 | − renderDebugMenu->addAction("FALSE Color Voxel Every Other Randomly", this, SLOT(doFalseRandomizeEveryOtherVoxelColors())); | |
| 1994 | − renderDebugMenu->addAction("FALSE Color Voxels by Distance", this, SLOT(doFalseColorizeByDistance())); | |
| 1995 | − renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView())); | |
| 1996 | − renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O); | |
| 1997 | − renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P); | |
| 1998 | − renderDebugMenu->addAction("FALSE Color By Source", this, SLOT(doFalseColorizeBySource()), Qt::CTRL | Qt::SHIFT | Qt::Key_S); | |
| 1999 | − renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T); | |
| 2000 | − | |
| 2001 | − (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true); | |
| 2002 | − | |
| 2003 | − debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true); | |
| 2004 | − debugMenu->addAction("Disable Lower Resolution While Moving", this, SLOT(disableLowResMoving(bool)))->setCheckable(true); | |
| 2005 | − debugMenu->addAction("Disable Delta Sending", this, SLOT(disableDeltaSending(bool)))->setCheckable(true); | |
| 2006 | − (_occlusionCulling = debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)), | |
| 2007 | − Qt::SHIFT | Qt::Key_C))->setCheckable(true); | |
| 2008 | − | |
| 2009 | − (_renderCoverageMap = debugMenu->addAction("Render Coverage Map"))->setCheckable(true); | |
| 2010 | − _renderCoverageMap->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_O); | |
| 2011 | − (_renderCoverageMapV2 = debugMenu->addAction("Render Coverage Map V2"))->setCheckable(true); | |
| 2012 | − _renderCoverageMapV2->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_P); | |
| 2013 | − | |
| 2014 | − (_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true); | |
| 2015 | − (_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true); | |
| 2016 | − | |
| 2017 | − QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools"); | |
| 2018 | − audioDebugMenu->addAction("Listen Mode Normal", this, SLOT(setListenModeNormal()), Qt::CTRL | Qt::Key_1); | |
| 2019 | − audioDebugMenu->addAction("Listen Mode Point/Radius", this, SLOT(setListenModePoint()), Qt::CTRL | Qt::Key_2); | |
| 2020 | − audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3); | |
| 2021 | − | |
| 2022 | − QMenu* settingsMenu = menuBar->addMenu("Settings"); | |
| 2023 | − (_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true); | |
| 2024 | − _settingsAutosave->setChecked(true); | |
| 2025 | − settingsMenu->addAction("Load settings", this, SLOT(loadSettings())); | |
| 2026 | − settingsMenu->addAction("Save settings", this, SLOT(saveSettings())); | |
| 2027 | − settingsMenu->addAction("Import settings", this, SLOT(importSettings())); | |
| 2028 | − settingsMenu->addAction("Export settings", this, SLOT(exportSettings())); | |
| 2029 | − | |
| 2030 | − _networkAccessManager = new QNetworkAccessManager(this); | |
| 2031 | −} | |
| 2032 | − | |
| 2033 | 1420 | void Application::setListenModeNormal() { |
| 2034 | 1421 | _audio.setListenMode(AudioRingBuffer::NORMAL); |
| 2035 | 1422 | } |
| @@ -2053,63 +1440,6 @@ void Application::setListenModeSingleSource() { · 17 unmodified lines | ||
| 2053 | 1440 | } |
| 2054 | 1441 | } |
| 2055 | 1442 | |
| 2056 | −void Application::toggleMixedSong() { | |
| 2057 | − if (_audio.getSongFileBytes() == 0) { | |
| 2058 | − QString filename = QFileDialog::getOpenFileName(_glWidget, | |
| 2059 | − tr("Choose RAW Audio file"), | |
| 2060 | − QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), | |
| 2061 | − tr("RAW Audio file (*.raw)")); | |
| 2062 | − | |
| 2063 | − QByteArray filenameArray = filename.toLocal8Bit(); | |
| 2064 | − _audio.importSongToMixWithMicrophone(filenameArray.data()); | |
| 2065 | − resetSongMixMenuItem(); | |
| 2066 | − } else { | |
| 2067 | − _audio.stopMixingSongWithMicrophone(); | |
| 2068 | − resetSongMixMenuItem(); | |
| 2069 | − } | |
| 2070 | −} | |
| 2071 | − | |
| 2072 | −void Application::toggleWantCollisionsOn() { | |
| 2073 | − _myAvatar.setWantCollisionsOn(_wantCollisionsOn->isChecked()); | |
| 2074 | −} | |
| 2075 | − | |
| 2076 | −void Application::resetSongMixMenuItem() { | |
| 2077 | − if (_audio.getSongFileBytes() == 0) { | |
| 2078 | − _rawAudioMicrophoneMix->setText("Mix RAW Song"); | |
| 2079 | − } else { | |
| 2080 | − _rawAudioMicrophoneMix->setText("Stop Mixing Song"); | |
| 2081 | − } | |
| 2082 | − | |
| 2083 | −} | |
| 2084 | − | |
| 2085 | −void Application::updateFrustumRenderModeAction() { | |
| 2086 | − switch (_frustumDrawingMode) { | |
| 2087 | − default: | |
| 2088 | − case FRUSTUM_DRAW_MODE_ALL: | |
| 2089 | − _frustumRenderModeAction->setText("Render Mode - All"); | |
| 2090 | − break; | |
| 2091 | − case FRUSTUM_DRAW_MODE_VECTORS: | |
| 2092 | − _frustumRenderModeAction->setText("Render Mode - Vectors"); | |
| 2093 | − break; | |
| 2094 | − case FRUSTUM_DRAW_MODE_PLANES: | |
| 2095 | − _frustumRenderModeAction->setText("Render Mode - Planes"); | |
| 2096 | − break; | |
| 2097 | − case FRUSTUM_DRAW_MODE_NEAR_PLANE: | |
| 2098 | − _frustumRenderModeAction->setText("Render Mode - Near"); | |
| 2099 | − break; | |
| 2100 | − case FRUSTUM_DRAW_MODE_FAR_PLANE: | |
| 2101 | − _frustumRenderModeAction->setText("Render Mode - Far"); | |
| 2102 | − break; | |
| 2103 | − case FRUSTUM_DRAW_MODE_KEYHOLE: | |
| 2104 | − _frustumRenderModeAction->setText("Render Mode - Keyhole"); | |
| 2105 | − break; | |
| 2106 | − } | |
| 2107 | −} | |
| 2108 | − | |
| 2109 | −void Application::runTests() { | |
| 2110 | − runTimingTests(); | |
| 2111 | −} | |
| 2112 | − | |
| 2113 | 1443 | void Application::initDisplay() { |
| 2114 | 1444 | glEnable(GL_BLEND); |
| 2115 | 1445 | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); |
| @@ -2141,7 +1471,9 @@ void Application::init() { · 25 unmodified lines | ||
| 2141 | 1471 | |
| 2142 | 1472 | OculusManager::connect(); |
| 2143 | 1473 | if (OculusManager::isConnected()) { |
| 2144 | − QMetaObject::invokeMethod(_fullScreenMode, "trigger", Qt::QueuedConnection); | |
| 1474 | + QMetaObject::invokeMethod(Menu::getInstance()->getActionForOption(MenuOption::Fullscreen), | |
| 1475 | + "trigger", | |
| 1476 | + Qt::QueuedConnection); | |
| 2145 | 1477 | } |
| 2146 | 1478 | |
| 2147 | 1479 | LeapManager::initialize(); |
| @@ -2149,22 +1481,22 @@ void Application::init() { · 1 unmodified line | ||
| 2149 | 1481 | gettimeofday(&_timerStart, NULL); |
| 2150 | 1482 | gettimeofday(&_lastTimeUpdated, NULL); |
| 2151 | 1483 | |
| 2152 | − loadSettings(); | |
| 2153 | − if (!shouldDynamicallySetJitterBuffer()) { | |
| 2154 | − _audio.setJitterBufferSamples(_audioJitterBufferSamples); | |
| 1484 | + Menu::getInstance()->loadSettings(); | |
| 1485 | + if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) { | |
| 1486 | + _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); | |
| 2155 | 1487 | } |
| 2156 | 1488 | |
| 2157 | 1489 | qDebug("Loaded settings.\n"); |
| 2158 | 1490 | |
| 2159 | − sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); | |
| 1491 | + Avatar::sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); | |
| 2160 | 1492 | |
| 2161 | 1493 | _palette.init(_glWidget->width(), _glWidget->height()); |
| 2162 | − _palette.addAction(_addVoxelMode, 0, 0); | |
| 2163 | − _palette.addAction(_deleteVoxelMode, 0, 1); | |
| 1494 | + _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelAddMode), 0, 0); | |
| 1495 | + _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelDeleteMode), 0, 1); | |
| 2164 | 1496 | _palette.addTool(&_swatch); |
| 2165 | − _palette.addAction(_colorVoxelMode, 0, 2); | |
| 2166 | − _palette.addAction(_eyedropperMode, 0, 3); | |
| 2167 | − _palette.addAction(_selectVoxelMode, 0, 4); | |
| 1497 | + _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelColorMode), 0, 2); | |
| 1498 | + _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelGetColorMode), 0, 3); | |
| 1499 | + _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelSelectMode), 0, 4); | |
| 2168 | 1500 | |
| 2169 | 1501 | _pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg", |
| 2170 | 1502 | _glWidget->width(), |
| @@ -2391,7 +1723,7 @@ void Application::update(float deltaTime) { · 220 unmodified lines | ||
| 2391 | 1723 | } |
| 2392 | 1724 | |
| 2393 | 1725 | _mouseVoxel.s = 0.0f; |
| 2394 | − if (checkedVoxelModeAction() != 0 && | |
| 1726 | + if (Menu::getInstance()->isVoxelModeActionChecked() && | |
| 2395 | 1727 | (fabs(_myAvatar.getVelocity().x) + |
| 2396 | 1728 | fabs(_myAvatar.getVelocity().y) + |
| 2397 | 1729 | fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) { |
| @@ -2416,7 +1748,7 @@ void Application::update(float deltaTime) { · 18 unmodified lines | ||
| 2416 | 1748 | _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / _mouseVoxelScale); |
| 2417 | 1749 | _mouseVoxel.s = _mouseVoxelScale; |
| 2418 | 1750 | } |
| 2419 | − if (_addVoxelMode->isChecked()) { | |
| 1751 | + if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) { | |
| 2420 | 1752 | // use the face to determine the side on which to create a neighbor |
| 2421 | 1753 | _mouseVoxel.x += faceVector.x * _mouseVoxel.s; |
| 2422 | 1754 | _mouseVoxel.y += faceVector.y * _mouseVoxel.s; |
| @@ -2426,7 +1758,8 @@ void Application::update(float deltaTime) { · 3 unmodified lines | ||
| 2426 | 1758 | } else { |
| 2427 | 1759 | _mouseVoxel.s = 0.0f; |
| 2428 | 1760 | } |
| 2429 | − } else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) { | |
| 1761 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) | |
| 1762 | + || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { | |
| 2430 | 1763 | // place the voxel a fixed distance away |
| 2431 | 1764 | float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; |
| 2432 | 1765 | glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); |
| @@ -2436,16 +1769,16 @@ void Application::update(float deltaTime) { · 3 unmodified lines | ||
| 2436 | 1769 | _mouseVoxel.s = _mouseVoxelScale; |
| 2437 | 1770 | } |
| 2438 | 1771 | |
| 2439 | − if (_deleteVoxelMode->isChecked()) { | |
| 1772 | + if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) { | |
| 2440 | 1773 | // red indicates deletion |
| 2441 | 1774 | _mouseVoxel.red = 255; |
| 2442 | 1775 | _mouseVoxel.green = _mouseVoxel.blue = 0; |
| 2443 | − } else if (_selectVoxelMode->isChecked()) { | |
| 1776 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { | |
| 2444 | 1777 | // yellow indicates deletion |
| 2445 | 1778 | _mouseVoxel.red = _mouseVoxel.green = 255; |
| 2446 | 1779 | _mouseVoxel.blue = 0; |
| 2447 | 1780 | } else { // _addVoxelMode->isChecked() || _colorVoxelMode->isChecked() |
| 2448 | − QColor paintColor = _voxelPaintColor->data().value<QColor>(); | |
| 1781 | + QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value<QColor>(); | |
| 2449 | 1782 | _mouseVoxel.red = paintColor.red(); |
| 2450 | 1783 | _mouseVoxel.green = paintColor.green(); |
| 2451 | 1784 | _mouseVoxel.blue = paintColor.blue(); |
| @@ -2475,8 +1808,8 @@ void Application::update(float deltaTime) { · 23 unmodified lines | ||
| 2475 | 1808 | } |
| 2476 | 1809 | |
| 2477 | 1810 | // Leap finger-sensing device |
| 2478 | − LeapManager::enableFakeFingers(_simulateLeapHand->isChecked()); | |
| 2479 | − _myAvatar.getHand().setRaveGloveActive(_testRaveGlove->isChecked()); | |
| 1811 | + LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand)); | |
| 1812 | + _myAvatar.getHand().setRaveGloveActive(Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove)); | |
| 2480 | 1813 | LeapManager::nextFrame(_myAvatar); |
| 2481 | 1814 | |
| 2482 | 1815 | // Read serial port interface devices |
| @@ -2516,60 +1849,47 @@ void Application::update(float deltaTime) { · 33 unmodified lines | ||
| 2516 | 1849 | } |
| 2517 | 1850 | |
| 2518 | 1851 | // Simulate myself |
| 2519 | − if (_gravityUse->isChecked()) { | |
| 1852 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) { | |
| 2520 | 1853 | _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition())); |
| 2521 | 1854 | } |
| 2522 | 1855 | else { |
| 2523 | 1856 | _myAvatar.setGravity(glm::vec3(0.0f, 0.0f, 0.0f)); |
| 2524 | 1857 | } |
| 2525 | 1858 | |
| 2526 | − if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) { | |
| 2527 | − _myAvatar.simulate(deltaTime, &_myTransmitter, _gyroCameraSensitivity); | |
| 1859 | + if (Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) { | |
| 1860 | + _myAvatar.simulate(deltaTime, &_myTransmitter, Menu::getInstance()->getGyroCameraSensitivity()); | |
| 2528 | 1861 | } else { |
| 2529 | − _myAvatar.simulate(deltaTime, NULL, _gyroCameraSensitivity); | |
| 1862 | + _myAvatar.simulate(deltaTime, NULL, Menu::getInstance()->getGyroCameraSensitivity()); | |
| 2530 | 1863 | } |
| 2531 | 1864 | |
| 2532 | 1865 | if (!OculusManager::isConnected()) { |
| 2533 | − if (_lookingInMirror->isChecked()) { | |
| 1866 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2534 | 1867 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { |
| 2535 | 1868 | _myCamera.setMode(CAMERA_MODE_MIRROR); |
| 2536 | 1869 | _myCamera.setModeShiftRate(100.0f); |
| 2537 | 1870 | } |
| 2538 | − } else if (_manualFirstPerson->isChecked()) { | |
| 1871 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { | |
| 2539 | 1872 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { |
| 2540 | 1873 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 2541 | 1874 | _myCamera.setModeShiftRate(1.0f); |
| 2542 | 1875 | } |
| 2543 | − } else if (_manualThirdPerson->isChecked()) { | |
| 1876 | + } else { | |
| 2544 | 1877 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 2545 | 1878 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 2546 | 1879 | _myCamera.setModeShiftRate(1.0f); |
| 2547 | 1880 | } |
| 2548 | − } else { | |
| 2549 | − const float THIRD_PERSON_SHIFT_VELOCITY = 1000.0f; | |
| 2550 | − const float TIME_BEFORE_SHIFT_INTO_FIRST_PERSON = 0.75f; | |
| 2551 | − const float TIME_BEFORE_SHIFT_INTO_THIRD_PERSON = 0.1f; | |
| 2552 | − | |
| 2553 | − if ((_myAvatar.getElapsedTimeStopped() > TIME_BEFORE_SHIFT_INTO_FIRST_PERSON) | |
| 2554 | − && (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON)) { | |
| 2555 | − _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | |
| 2556 | − _myCamera.setModeShiftRate(1.0f); | |
| 2557 | − } | |
| 2558 | − if ((_myAvatar.getSpeed() > THIRD_PERSON_SHIFT_VELOCITY) | |
| 2559 | − && (_myAvatar.getElapsedTimeMoving() > TIME_BEFORE_SHIFT_INTO_THIRD_PERSON) | |
| 2560 | − && (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON)) { | |
| 2561 | − _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); | |
| 2562 | − _myCamera.setModeShiftRate(1000.0f); | |
| 2563 | − } | |
| 2564 | 1881 | } |
| 2565 | 1882 | } |
| 2566 | 1883 | |
| 2567 | 1884 | // Update bandwidth dialog, if any |
| 2568 | − if (_bandwidthDialog) { | |
| 2569 | − _bandwidthDialog->update(); | |
| 1885 | + BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog(); | |
| 1886 | + if (bandwidthDialog) { | |
| 1887 | + bandwidthDialog->update(); | |
| 2570 | 1888 | } |
| 2571 | − if (_voxelStatsDialog) { | |
| 2572 | − _voxelStatsDialog->update(); | |
| 1889 | + | |
| 1890 | + VoxelStatsDialog* voxelStatsDialog = Menu::getInstance()->getVoxelStatsDialog(); | |
| 1891 | + if (voxelStatsDialog) { | |
| 1892 | + voxelStatsDialog->update(); | |
| 2573 | 1893 | } |
| 2574 | 1894 | |
| 2575 | 1895 | // Update audio stats for procedural sounds |
| @@ -2578,10 +1898,6 @@ void Application::update(float deltaTime) { · 2 unmodified lines | ||
| 2578 | 1898 | _audio.setLastVelocity(_myAvatar.getVelocity()); |
| 2579 | 1899 | _audio.eventuallyAnalyzePing(); |
| 2580 | 1900 | #endif |
| 2581 | − | |
| 2582 | − if (_renderParticleSystemOn->isChecked()) { | |
| 2583 | − updateParticleSystem(deltaTime); | |
| 2584 | − } | |
| 2585 | 1901 | } |
| 2586 | 1902 | |
| 2587 | 1903 | void Application::updateAvatar(float deltaTime) { |
| @@ -2592,7 +1908,7 @@ void Application::updateAvatar(float deltaTime) { · 4 unmodified lines | ||
| 2592 | 1908 | _yawFromTouch = 0.f; |
| 2593 | 1909 | |
| 2594 | 1910 | // Update my avatar's state from gyros and/or webcam |
| 2595 | − _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(), | |
| 1911 | + _myAvatar.updateFromGyrosAndOrWebcam(Menu::getInstance()->isOptionChecked(MenuOption::GyroLook), | |
| 2596 | 1912 | _pitchFromTouch); |
| 2597 | 1913 | |
| 2598 | 1914 | if (_serialHeadSensor.isActive()) { |
| @@ -2616,17 +1932,20 @@ void Application::updateAvatar(float deltaTime) { · 17 unmodified lines | ||
| 2616 | 1932 | _headMouseY = min(_headMouseY, _glWidget->height()); |
| 2617 | 1933 | |
| 2618 | 1934 | const float MIDPOINT_OF_SCREEN = 0.5; |
| 2619 | − | |
| 2620 | − // Set lookAtPosition if an avatar is at the center of the screen | |
| 2621 | − glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; | |
| 2622 | − _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); | |
| 2623 | − | |
| 2624 | − glm::vec3 eyePosition; | |
| 2625 | 1935 | |
| 2626 | − _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); | |
| 2627 | − if (_isLookingAtOtherAvatar) { | |
| 2628 | − glm::vec3 myLookAtFromMouse(eyePosition); | |
| 2629 | − _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); | |
| 1936 | + // Only use gyro to set lookAt if mouse hasn't selected an avatar | |
| 1937 | + if (!_isLookingAtOtherAvatar) { | |
| 1938 | + | |
| 1939 | + // Set lookAtPosition if an avatar is at the center of the screen | |
| 1940 | + glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; | |
| 1941 | + _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); | |
| 1942 | + | |
| 1943 | + glm::vec3 eyePosition; | |
| 1944 | + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); | |
| 1945 | + if (_isLookingAtOtherAvatar) { | |
| 1946 | + glm::vec3 myLookAtFromMouse(eyePosition); | |
| 1947 | + _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); | |
| 1948 | + } | |
| 2630 | 1949 | } |
| 2631 | 1950 | |
| 2632 | 1951 | } |
| @@ -2678,7 +1997,7 @@ void Application::updateAvatar(float deltaTime) { · 45 unmodified lines | ||
| 2678 | 1997 | // once in a while, send my voxel url |
| 2679 | 1998 | const float AVATAR_VOXEL_URL_SEND_INTERVAL = 1.0f; // seconds |
| 2680 | 1999 | if (shouldDo(AVATAR_VOXEL_URL_SEND_INTERVAL, deltaTime)) { |
| 2681 | − sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); | |
| 2000 | + Avatar::sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); | |
| 2682 | 2001 | } |
| 2683 | 2002 | } |
| 2684 | 2003 | } |
| @@ -2888,7 +2207,7 @@ void Application::displaySide(Camera& whichCamera) { · 203 unmodified lines | ||
| 2888 | 2207 | // transform by eye offset |
| 2889 | 2208 | |
| 2890 | 2209 | // flip x if in mirror mode (also requires reversing winding order for backface culling) |
| 2891 | − if (_lookingInMirror->isChecked()) { | |
| 2210 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2892 | 2211 | glScalef(-1.0f, 1.0f, 1.0f); |
| 2893 | 2212 | glFrontFace(GL_CW); |
| 2894 | 2213 | |
| @@ -2918,7 +2237,7 @@ void Application::displaySide(Camera& whichCamera) { · 23 unmodified lines | ||
| 2918 | 2237 | // prepare the glow effect |
| 2919 | 2238 | _glowEffect.prepare(); |
| 2920 | 2239 | |
| 2921 | − if (_renderStarsOn->isChecked()) { | |
| 2240 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { | |
| 2922 | 2241 | if (!_stars.getFileLoaded()) { |
| 2923 | 2242 | _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); |
| 2924 | 2243 | } |
| @@ -2926,7 +2245,7 @@ void Application::displaySide(Camera& whichCamera) { · 1 unmodified line | ||
| 2926 | 2245 | |
| 2927 | 2246 | // compute starfield alpha based on distance from atmosphere |
| 2928 | 2247 | float alpha = 1.0f; |
| 2929 | − if (_renderAtmosphereOn->isChecked()) { | |
| 2248 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 2930 | 2249 | const EnvironmentData& closestData = _environment.getClosestData(whichCamera.getPosition()); |
| 2931 | 2250 | float height = glm::distance(whichCamera.getPosition(), closestData.getAtmosphereCenter()); |
| 2932 | 2251 | if (height < closestData.getAtmosphereInnerRadius()) { |
| @@ -2943,7 +2262,7 @@ void Application::displaySide(Camera& whichCamera) { · 10 unmodified lines | ||
| 2943 | 2262 | } |
| 2944 | 2263 | |
| 2945 | 2264 | // draw the sky dome |
| 2946 | − if (_renderAtmosphereOn->isChecked()) { | |
| 2265 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 2947 | 2266 | _environment.renderAtmospheres(whichCamera); |
| 2948 | 2267 | } |
| 2949 | 2268 | |
| @@ -2965,7 +2284,7 @@ void Application::displaySide(Camera& whichCamera) { · 15 unmodified lines | ||
| 2965 | 2284 | glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR); |
| 2966 | 2285 | |
| 2967 | 2286 | //draw a grid ground plane.... |
| 2968 | − if (_renderGroundPlaneOn->isChecked()) { | |
| 2287 | + if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) { | |
| 2969 | 2288 | // draw grass plane with fog |
| 2970 | 2289 | glEnable(GL_FOG); |
| 2971 | 2290 | glEnable(GL_NORMALIZE); |
| @@ -2988,8 +2307,8 @@ void Application::displaySide(Camera& whichCamera) { · 16 unmodified lines | ||
| 2988 | 2307 | //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude()); |
| 2989 | 2308 | } |
| 2990 | 2309 | // Draw voxels |
| 2991 | − if (_renderVoxels->isChecked()) { | |
| 2992 | − _voxels.render(_renderVoxelTextures->isChecked()); | |
| 2310 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { | |
| 2311 | + _voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures)); | |
| 2993 | 2312 | } |
| 2994 | 2313 | |
| 2995 | 2314 | // restore default, white specular |
| @@ -3001,7 +2320,7 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines | ||
| 3001 | 2320 | glPushMatrix(); |
| 3002 | 2321 | glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); |
| 3003 | 2322 | renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); |
| 3004 | − if (_addVoxelMode->isChecked()) { | |
| 2323 | + if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) { | |
| 3005 | 2324 | // use a contrasting color so that we can see what we're doing |
| 3006 | 2325 | glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128); |
| 3007 | 2326 | } else { |
| @@ -3019,7 +2338,7 @@ void Application::displaySide(Camera& whichCamera) { · 11 unmodified lines | ||
| 3019 | 2338 | |
| 3020 | 2339 | _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera); |
| 3021 | 2340 | |
| 3022 | − if (_renderAvatarsOn->isChecked()) { | |
| 2341 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) { | |
| 3023 | 2342 | // Render avatars of other nodes |
| 3024 | 2343 | NodeList* nodeList = NodeList::getInstance(); |
| 3025 | 2344 | |
| @@ -3031,11 +2350,12 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines | ||
| 3031 | 2350 | if (!avatar->isInitialized()) { |
| 3032 | 2351 | avatar->init(); |
| 3033 | 2352 | } |
| 2353 | + // Set lookAt to myCamera on client side if other avatars are looking at client | |
| 3034 | 2354 | if (isLookingAtMyAvatar(avatar)) { |
| 3035 | 2355 | avatar->getHead().setLookAtPosition(_myCamera.getPosition()); |
| 3036 | 2356 | } |
| 3037 | − avatar->render(false, _renderAvatarBalls->isChecked()); | |
| 3038 | − avatar->setDisplayingLookatVectors(_renderLookatOn->isChecked()); | |
| 2357 | + avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls)); | |
| 2358 | + avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); | |
| 3039 | 2359 | } |
| 3040 | 2360 | |
| 3041 | 2361 | node->unlock(); |
| @@ -3045,28 +2365,26 @@ void Application::displaySide(Camera& whichCamera) { · 3 unmodified lines | ||
| 3045 | 2365 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 3046 | 2366 | _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); |
| 3047 | 2367 | } |
| 3048 | − _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); | |
| 3049 | − | |
| 3050 | − _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); | |
| 2368 | + _myAvatar.render(Menu::getInstance()->isOptionChecked(MenuOption::Mirror), | |
| 2369 | + Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls)); | |
| 2370 | + _myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); | |
| 3051 | 2371 | |
| 3052 | − if (_renderLookatIndicatorOn->isChecked() && _isLookingAtOtherAvatar) { | |
| 2372 | + if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _isLookingAtOtherAvatar) { | |
| 3053 | 2373 | renderLookatIndicator(_lookatOtherPosition, whichCamera); |
| 3054 | 2374 | } |
| 3055 | 2375 | } |
| 3056 | 2376 | |
| 3057 | 2377 | _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera); |
| 3058 | 2378 | |
| 3059 | − if (_renderParticleSystemOn->isChecked()) { | |
| 3060 | − if (_particleSystemInitialized) { | |
| 3061 | − _particleSystem.render(); | |
| 3062 | − } | |
| 3063 | − } | |
| 3064 | − | |
| 3065 | 2379 | // Render the world box |
| 3066 | − if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { renderWorldBox(); } | |
| 2380 | + if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { | |
| 2381 | + renderWorldBox(); | |
| 2382 | + } | |
| 3067 | 2383 | |
| 3068 | 2384 | // brad's frustum for debugging |
| 3069 | − if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); | |
| 2385 | + if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { | |
| 2386 | + renderViewFrustum(_viewFrustum); | |
| 2387 | + } | |
| 3070 | 2388 | |
| 3071 | 2389 | // render voxel fades if they exist |
| 3072 | 2390 | if (_voxelFades.size() > 0) { |
| @@ -3104,14 +2422,16 @@ void Application::displayOverlay() { · 31 unmodified lines | ||
| 3104 | 2422 | |
| 3105 | 2423 | #ifndef _WIN32 |
| 3106 | 2424 | _audio.render(_glWidget->width(), _glWidget->height()); |
| 3107 | − if (_oscilloscopeOn->isChecked()) { | |
| 2425 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) { | |
| 3108 | 2426 | _audioScope.render(20, _glWidget->height() - 200); |
| 3109 | 2427 | } |
| 3110 | 2428 | #endif |
| 3111 | 2429 | |
| 3112 | 2430 | //noiseTest(_glWidget->width(), _glWidget->height()); |
| 3113 | 2431 | |
| 3114 | − if (_showHeadMouse->isChecked() && !_lookingInMirror->isChecked() && USING_INVENSENSE_MPU9150) { | |
| 2432 | + if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse) | |
| 2433 | + && !Menu::getInstance()->isOptionChecked(MenuOption::Mirror) | |
| 2434 | + && USING_INVENSENSE_MPU9150) { | |
| 3115 | 2435 | // Display small target box at center or head mouse target that can also be used to measure LOD |
| 3116 | 2436 | glColor3f(1.0, 1.0, 1.0); |
| 3117 | 2437 | glDisable(GL_LINE_SMOOTH); |
| @@ -3137,14 +2457,26 @@ void Application::displayOverlay() { · 19 unmodified lines | ||
| 3137 | 2457 | glLineWidth(1.0f); |
| 3138 | 2458 | glPointSize(1.0f); |
| 3139 | 2459 | |
| 3140 | − if (_renderStatsOn->isChecked()) { displayStats(); } | |
| 2460 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { | |
| 2461 | + displayStats(); | |
| 2462 | + } | |
| 3141 | 2463 | |
| 3142 | 2464 | // testing rendering coverage map |
| 3143 | − if (_renderCoverageMapV2->isChecked()) { renderCoverageMapV2(); } | |
| 3144 | − if (_renderCoverageMap->isChecked()) { renderCoverageMap(); } | |
| 3145 | − if (_bandwidthDisplayOn->isChecked()) { _bandwidthMeter.render(_glWidget->width(), _glWidget->height()); } | |
| 2465 | + if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMapV2)) { | |
| 2466 | + renderCoverageMapV2(); | |
| 2467 | + } | |
| 2468 | + | |
| 2469 | + if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMap)) { | |
| 2470 | + renderCoverageMap(); | |
| 2471 | + } | |
| 2472 | + | |
| 2473 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) { | |
| 2474 | + _bandwidthMeter.render(_glWidget->width(), _glWidget->height()); | |
| 2475 | + } | |
| 3146 | 2476 | |
| 3147 | − if (_logOn->isChecked()) { LogDisplay::instance.render(_glWidget->width(), _glWidget->height()); } | |
| 2477 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Log)) { | |
| 2478 | + LogDisplay::instance.render(_glWidget->width(), _glWidget->height()); | |
| 2479 | + } | |
| 3148 | 2480 | |
| 3149 | 2481 | // Show chat entry field |
| 3150 | 2482 | if (_chatEntryOn) { |
| @@ -3152,7 +2484,7 @@ void Application::displayOverlay() { · 1 unmodified line | ||
| 3152 | 2484 | } |
| 3153 | 2485 | |
| 3154 | 2486 | // Show on-screen msec timer |
| 3155 | − if (_renderFrameTimerOn->isChecked()) { | |
| 2487 | + if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) { | |
| 3156 | 2488 | char frameTimer[10]; |
| 3157 | 2489 | uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); |
| 3158 | 2490 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); |
| @@ -3160,7 +2492,6 @@ void Application::displayOverlay() { · 1 unmodified line | ||
| 3160 | 2492 | drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1); |
| 3161 | 2493 | } |
| 3162 | 2494 | |
| 3163 | − | |
| 3164 | 2495 | // Stats at upper right of screen about who domain server is telling us about |
| 3165 | 2496 | glPointSize(1.0f); |
| 3166 | 2497 | char nodes[100]; |
| @@ -3180,8 +2511,11 @@ void Application::displayOverlay() { · 13 unmodified lines | ||
| 3180 | 2511 | |
| 3181 | 2512 | _palette.render(_glWidget->width(), _glWidget->height()); |
| 3182 | 2513 | |
| 3183 | − if (_eyedropperMode->isChecked() && _voxelPaintColor->data().value<QColor>() != _swatch.getColor()) { | |
| 3184 | − QColor color = _voxelPaintColor->data().value<QColor>(); | |
| 2514 | + QAction* paintColorAction = NULL; | |
| 2515 | + if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode) | |
| 2516 | + && (paintColorAction = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor))->data().value<QColor>() | |
| 2517 | + != _swatch.getColor()) { | |
| 2518 | + QColor color = paintColorAction->data().value<QColor>(); | |
| 3185 | 2519 | TextRenderer textRenderer(SANS_FONT_FAMILY, 11, 50); |
| 3186 | 2520 | const char line1[] = "Assign this color to a swatch"; |
| 3187 | 2521 | const char line2[] = "by choosing a key from 1 to 8."; |
| @@ -3238,7 +2572,7 @@ void Application::displayStats() { · 50 unmodified lines | ||
| 3238 | 2572 | _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f); |
| 3239 | 2573 | drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats); |
| 3240 | 2574 | |
| 3241 | − if (_testPing->isChecked()) { | |
| 2575 | + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { | |
| 3242 | 2576 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; |
| 3243 | 2577 | |
| 3244 | 2578 | NodeList* nodeList = NodeList::getInstance(); |
| @@ -3532,7 +2866,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 287 unmodified lines | ||
| 3532 | 2866 | glLineWidth(1.0); |
| 3533 | 2867 | glBegin(GL_LINES); |
| 3534 | 2868 | |
| 3535 | − if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_VECTORS) { | |
| 2869 | + if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL | |
| 2870 | + || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_VECTORS) { | |
| 3536 | 2871 | // Calculate the origin direction vectors |
| 3537 | 2872 | glm::vec3 lookingAt = position + (direction * 0.2f); |
| 3538 | 2873 | glm::vec3 lookingAtUp = position + (up * 0.2f); |
| @@ -3554,8 +2889,9 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 15 unmodified lines | ||
| 3554 | 2889 | glVertex3f(lookingAtRight.x, lookingAtRight.y, lookingAtRight.z); |
| 3555 | 2890 | } |
| 3556 | 2891 | |
| 3557 | − if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | |
| 3558 | − || _frustumDrawingMode == FRUSTUM_DRAW_MODE_NEAR_PLANE) { | |
| 2892 | + if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL | |
| 2893 | + || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES | |
| 2894 | + || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_NEAR_PLANE) { | |
| 3559 | 2895 | // Drawing the bounds of the frustum |
| 3560 | 2896 | // viewFrustum.getNear plane - bottom edge |
| 3561 | 2897 | glColor3f(1,0,0); |
| @@ -3575,8 +2911,9 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 13 unmodified lines | ||
| 3575 | 2911 | glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); |
| 3576 | 2912 | } |
| 3577 | 2913 | |
| 3578 | − if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | |
| 3579 | − || _frustumDrawingMode == FRUSTUM_DRAW_MODE_FAR_PLANE) { | |
| 2914 | + if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL | |
| 2915 | + || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES | |
| 2916 | + || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) { | |
| 3580 | 2917 | // viewFrustum.getFar plane - bottom edge |
| 3581 | 2918 | glColor3f(0,1,0); // GREEN!!! |
| 3582 | 2919 | glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); |
| @@ -3595,7 +2932,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 12 unmodified lines | ||
| 3595 | 2932 | glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); |
| 3596 | 2933 | } |
| 3597 | 2934 | |
| 3598 | − if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES) { | |
| 2935 | + if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL | |
| 2936 | + || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES) { | |
| 3599 | 2937 | // RIGHT PLANE IS CYAN |
| 3600 | 2938 | // right plane - bottom edge - viewFrustum.getNear to distant |
| 3601 | 2939 | glColor3f(0,1,1); |
| @@ -3619,7 +2957,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 17 unmodified lines | ||
| 3619 | 2957 | glEnd(); |
| 3620 | 2958 | glEnable(GL_LIGHTING); |
| 3621 | 2959 | |
| 3622 | − if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_KEYHOLE) { | |
| 2960 | + if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL | |
| 2961 | + || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_KEYHOLE) { | |
| 3623 | 2962 | // Draw the keyhole |
| 3624 | 2963 | float keyholeRadius = viewFrustum.getKeyholeRadius(); |
| 3625 | 2964 | if (keyholeRadius > 0.0f) { |
| @@ -3689,15 +3028,18 @@ void Application::injectVoxelAddedSoundEffect() { · 63 unmodified lines | ||
| 3689 | 3028 | } |
| 3690 | 3029 | |
| 3691 | 3030 | bool Application::maybeEditVoxelUnderCursor() { |
| 3692 | − if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) { | |
| 3031 | + if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) | |
| 3032 | + || Menu::getInstance()->isOptionChecked(MenuOption::VoxelColorMode)) { | |
| 3693 | 3033 | if (_mouseVoxel.s != 0) { |
| 3694 | − PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ? | |
| 3695 | − PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL); | |
| 3034 | + PACKET_TYPE message = Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel) | |
| 3035 | + ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE | |
| 3036 | + : PACKET_TYPE_SET_VOXEL; | |
| 3696 | 3037 | _voxelEditSender.sendVoxelEditMessage(message, _mouseVoxel); |
| 3697 | 3038 | |
| 3698 | 3039 | // create the voxel locally so it appears immediately |
| 3699 | 3040 | _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, |
| 3700 | − _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel->isChecked()); | |
| 3041 | + _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, | |
| 3042 | + Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel)); | |
| 3701 | 3043 | |
| 3702 | 3044 | // Implement voxel fade effect |
| 3703 | 3045 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); |
| @@ -3716,7 +3058,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 12 unmodified lines | ||
| 3716 | 3058 | _justEditedVoxel = true; |
| 3717 | 3059 | |
| 3718 | 3060 | } |
| 3719 | − } else if (_deleteVoxelMode->isChecked()) { | |
| 3061 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) { | |
| 3720 | 3062 | deleteVoxelUnderCursor(); |
| 3721 | 3063 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); |
| 3722 | 3064 | const float VOXEL_BOUNDS_ADJUST = 0.01f; |
| @@ -3727,7 +3069,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 4 unmodified lines | ||
| 3727 | 3069 | fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; |
| 3728 | 3070 | _voxelFades.push_back(fade); |
| 3729 | 3071 | |
| 3730 | − } else if (_eyedropperMode->isChecked()) { | |
| 3072 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode)) { | |
| 3731 | 3073 | eyedropperVoxelUnderCursor(); |
| 3732 | 3074 | } else { |
| 3733 | 3075 | return false; |
| @@ -3768,18 +3110,13 @@ void Application::eyedropperVoxelUnderCursor() { · 34 unmodified lines | ||
| 3768 | 3110 | selectedNode->getColor()[BLUE_INDEX]); |
| 3769 | 3111 | |
| 3770 | 3112 | if (selectedColor.isValid()) { |
| 3771 | − _voxelPaintColor->setData(selectedColor); | |
| 3772 | − _voxelPaintColor->setIcon(createSwatchIcon(selectedColor)); | |
| 3113 | + QAction* voxelPaintColorAction = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor); | |
| 3114 | + voxelPaintColorAction->setData(selectedColor); | |
| 3115 | + voxelPaintColorAction->setIcon(Swatch::createIcon(selectedColor)); | |
| 3773 | 3116 | } |
| 3774 | 3117 | } |
| 3775 | 3118 | } |
| 3776 | 3119 | |
| 3777 | −void Application::goHome() { | |
| 3778 | − qDebug("Going Home!\n"); | |
| 3779 | − _myAvatar.setPosition(START_LOCATION); | |
| 3780 | −} | |
| 3781 | − | |
| 3782 | − | |
| 3783 | 3120 | void Application::toggleFollowMode() { |
| 3784 | 3121 | glm::vec3 mouseRayOrigin, mouseRayDirection; |
| 3785 | 3122 | _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(), |
| @@ -3834,17 +3171,6 @@ void Application::updateCursor() { · 48 unmodified lines | ||
| 3834 | 3171 | Qt::BlankCursor : Qt::ArrowCursor); |
| 3835 | 3172 | } |
| 3836 | 3173 | |
| 3837 | −// when QActionGroup is set to non-exclusive, it doesn't return anything as checked; | |
| 3838 | −// hence, we must check ourselves | |
| 3839 | −QAction* Application::checkedVoxelModeAction() const { | |
| 3840 | − foreach (QAction* action, _voxelModeActions->actions()) { | |
| 3841 | − if (action->isChecked()) { | |
| 3842 | − return action; | |
| 3843 | − } | |
| 3844 | − } | |
| 3845 | − return 0; | |
| 3846 | −} | |
| 3847 | − | |
| 3848 | 3174 | void Application::attachNewHeadToNode(Node* newNode) { |
| 3849 | 3175 | if (newNode->getLinkedData() == NULL) { |
| 3850 | 3176 | newNode->setLinkedData(new Avatar(newNode)); |
| @@ -3976,190 +3302,6 @@ void* Application::networkReceive(void* args) { · 125 unmodified lines | ||
| 3976 | 3302 | return NULL; |
| 3977 | 3303 | } |
| 3978 | 3304 | |
| 3979 | −void Application::scanMenuBar(settingsAction modifySetting, QSettings* set) { | |
| 3980 | − if (!_window->menuBar()) { | |
| 3981 | − return; | |
| 3982 | − } | |
| 3983 | − | |
| 3984 | − QList<QMenu*> menus = _window->menuBar()->findChildren<QMenu *>(); | |
| 3985 | − | |
| 3986 | − for (QList<QMenu *>::const_iterator it = menus.begin(); menus.end() != it; ++it) { | |
| 3987 | − scanMenu(*it, modifySetting, set); | |
| 3988 | − } | |
| 3989 | −} | |
| 3990 | − | |
| 3991 | −void Application::scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set) { | |
| 3992 | − QList<QAction*> actions = menu->actions(); | |
| 3993 | − | |
| 3994 | − set->beginGroup(menu->title()); | |
| 3995 | − for (QList<QAction *>::const_iterator it = actions.begin(); actions.end() != it; ++it) { | |
| 3996 | − if ((*it)->menu()) { | |
| 3997 | − scanMenu((*it)->menu(), modifySetting, set); | |
| 3998 | − } | |
| 3999 | − if ((*it)->isCheckable()) { | |
| 4000 | − modifySetting(set, *it); | |
| 4001 | − } | |
| 4002 | − } | |
| 4003 | − set->endGroup(); | |
| 4004 | −} | |
| 4005 | − | |
| 4006 | −void Application::loadAction(QSettings* set, QAction* action) { | |
| 4007 | − if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) { | |
| 4008 | − action->trigger(); | |
| 4009 | − } | |
| 4010 | −} | |
| 4011 | − | |
| 4012 | −void Application::saveAction(QSettings* set, QAction* action) { | |
| 4013 | − set->setValue(action->text(), action->isChecked()); | |
| 4014 | −} | |
| 4015 | − | |
| 4016 | −void Application::loadSettings(QSettings* settings) { | |
| 4017 | − if (!settings) { | |
| 4018 | − settings = getSettings(); | |
| 4019 | − } | |
| 4020 | − | |
| 4021 | − _gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f); | |
| 4022 | − _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0); | |
| 4023 | − _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES); | |
| 4024 | − | |
| 4025 | − settings->beginGroup("View Frustum Offset Camera"); | |
| 4026 | − // in case settings is corrupt or missing loadSetting() will check for NaN | |
| 4027 | − _viewFrustumOffsetYaw = loadSetting(settings, "viewFrustumOffsetYaw" , 0.0f); | |
| 4028 | − _viewFrustumOffsetPitch = loadSetting(settings, "viewFrustumOffsetPitch" , 0.0f); | |
| 4029 | − _viewFrustumOffsetRoll = loadSetting(settings, "viewFrustumOffsetRoll" , 0.0f); | |
| 4030 | − _viewFrustumOffsetDistance = loadSetting(settings, "viewFrustumOffsetDistance", 0.0f); | |
| 4031 | − _viewFrustumOffsetUp = loadSetting(settings, "viewFrustumOffsetUp" , 0.0f); | |
| 4032 | − settings->endGroup(); | |
| 4033 | − | |
| 4034 | − scanMenuBar(&Application::loadAction, settings); | |
| 4035 | − getAvatar()->loadData(settings); | |
| 4036 | − _swatch.loadData(settings); | |
| 4037 | −} | |
| 4038 | − | |
| 4039 | − | |
| 4040 | −void Application::saveSettings(QSettings* settings) { | |
| 4041 | − if (!settings) { | |
| 4042 | − settings = getSettings(); | |
| 4043 | − } | |
| 4044 | − | |
| 4045 | − settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity); | |
| 4046 | − settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); | |
| 4047 | − settings->setValue("fieldOfView", _fieldOfView); | |
| 4048 | − settings->beginGroup("View Frustum Offset Camera"); | |
| 4049 | − settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffsetYaw); | |
| 4050 | − settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffsetPitch); | |
| 4051 | − settings->setValue("viewFrustumOffsetRoll", _viewFrustumOffsetRoll); | |
| 4052 | − settings->setValue("viewFrustumOffsetDistance", _viewFrustumOffsetDistance); | |
| 4053 | − settings->setValue("viewFrustumOffsetUp", _viewFrustumOffsetUp); | |
| 4054 | − settings->endGroup(); | |
| 4055 | − | |
| 4056 | − scanMenuBar(&Application::saveAction, settings); | |
| 4057 | − getAvatar()->saveData(settings); | |
| 4058 | − _swatch.saveData(settings); | |
| 4059 | − | |
| 4060 | − // ask the NodeList to save its data | |
| 4061 | − NodeList::getInstance()->saveData(settings); | |
| 4062 | −} | |
| 4063 | − | |
| 4064 | −void Application::importSettings() { | |
| 4065 | − QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); | |
| 4066 | − QString fileName = QFileDialog::getOpenFileName(_window, | |
| 4067 | − tr("Open .ini config file"), | |
| 4068 | − locationDir, | |
| 4069 | − tr("Text files (*.ini)")); | |
| 4070 | − if (fileName != "") { | |
| 4071 | − QSettings tmp(fileName, QSettings::IniFormat); | |
| 4072 | − loadSettings(&tmp); | |
| 4073 | − } | |
| 4074 | −} | |
| 4075 | − | |
| 4076 | −void Application::exportSettings() { | |
| 4077 | − QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); | |
| 4078 | − QString fileName = QFileDialog::getSaveFileName(_window, | |
| 4079 | − tr("Save .ini config file"), | |
| 4080 | − locationDir, | |
| 4081 | − tr("Text files (*.ini)")); | |
| 4082 | − if (fileName != "") { | |
| 4083 | − QSettings tmp(fileName, QSettings::IniFormat); | |
| 4084 | − saveSettings(&tmp); | |
| 4085 | − tmp.sync(); | |
| 4086 | − } | |
| 4087 | −} | |
| 4088 | − | |
| 4089 | − | |
| 4090 | −void Application::updateParticleSystem(float deltaTime) { | |
| 4091 | − | |
| 4092 | − if (!_particleSystemInitialized) { | |
| 4093 | − | |
| 4094 | − const int LIFESPAN_IN_SECONDS = 100000.0f; | |
| 4095 | − const float EMIT_RATE_IN_SECONDS = 10000.0; | |
| 4096 | − // create a stable test emitter and spit out a bunch of particles | |
| 4097 | − _coolDemoParticleEmitter = _particleSystem.addEmitter(); | |
| 4098 | − | |
| 4099 | − if (_coolDemoParticleEmitter != -1) { | |
| 4100 | − | |
| 4101 | − _particleSystem.setShowingEmitter(_coolDemoParticleEmitter, true); | |
| 4102 | − glm::vec3 particleEmitterPosition = glm::vec3(5.0f, 1.0f, 5.0f); | |
| 4103 | − | |
| 4104 | − _particleSystem.setEmitterPosition (_coolDemoParticleEmitter, particleEmitterPosition); | |
| 4105 | − _particleSystem.setEmitterParticleLifespan(_coolDemoParticleEmitter, LIFESPAN_IN_SECONDS); | |
| 4106 | − _particleSystem.setEmitterThrust (_coolDemoParticleEmitter, 0.0f); | |
| 4107 | − _particleSystem.setEmitterRate (_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // to emit a pile o particles now | |
| 4108 | − } | |
| 4109 | − | |
| 4110 | − // signal that the particle system has been initialized | |
| 4111 | − _particleSystemInitialized = true; | |
| 4112 | − } else { | |
| 4113 | − // update the particle system | |
| 4114 | − | |
| 4115 | − static bool emitting = true; | |
| 4116 | − static float effectsTimer = 0.0f; | |
| 4117 | − effectsTimer += deltaTime; | |
| 4118 | − | |
| 4119 | − if (_coolDemoParticleEmitter != -1) { | |
| 4120 | − | |
| 4121 | − _particleSystem.setEmitterDirection(_coolDemoParticleEmitter, glm::vec3(0.0f, 1.0f, 0.0f)); | |
| 4122 | − | |
| 4123 | − ParticleSystem::ParticleAttributes attributes; | |
| 4124 | − | |
| 4125 | − attributes.radius = 0.01f; | |
| 4126 | − attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); | |
| 4127 | − attributes.gravity = 0.0f + 0.05f * sinf( effectsTimer * 0.52f ); | |
| 4128 | − attributes.airFriction = 2.5 + 2.0f * sinf( effectsTimer * 0.32f ); | |
| 4129 | − attributes.jitter = 0.05f + 0.05f * sinf( effectsTimer * 0.42f ); | |
| 4130 | − attributes.emitterAttraction = 0.015f + 0.015f * cosf( effectsTimer * 0.6f ); | |
| 4131 | − attributes.tornadoForce = 0.0f + 0.03f * sinf( effectsTimer * 0.7f ); | |
| 4132 | − attributes.neighborAttraction = 0.1f + 0.1f * cosf( effectsTimer * 0.8f ); | |
| 4133 | − attributes.neighborRepulsion = 0.2f + 0.2f * sinf( effectsTimer * 0.4f ); | |
| 4134 | − attributes.bounce = 1.0f; | |
| 4135 | − attributes.usingCollisionSphere = true; | |
| 4136 | − attributes.collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f ); | |
| 4137 | − attributes.collisionSphereRadius = 0.5f; | |
| 4138 | − attributes.usingCollisionPlane = true; | |
| 4139 | − attributes.collisionPlanePosition = glm::vec3( 5.0f, 0.0f, 5.0f ); | |
| 4140 | − attributes.collisionPlaneNormal = glm::vec3( 0.0f, 1.0f, 0.0f ); | |
| 4141 | − | |
| 4142 | − if (attributes.gravity < 0.0f) { | |
| 4143 | − attributes.gravity = 0.0f; | |
| 4144 | − } | |
| 4145 | − | |
| 4146 | − _particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes); | |
| 4147 | − } | |
| 4148 | − | |
| 4149 | − _particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f)); | |
| 4150 | − _particleSystem.simulate(deltaTime); | |
| 4151 | − | |
| 4152 | − const float EMIT_RATE_IN_SECONDS = 0.0; | |
| 4153 | − | |
| 4154 | − if (_coolDemoParticleEmitter != -1) { | |
| 4155 | − if (emitting) { | |
| 4156 | − _particleSystem.setEmitterRate(_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // stop emitter | |
| 4157 | − emitting = false; | |
| 4158 | − } | |
| 4159 | − } | |
| 4160 | − } | |
| 4161 | −} | |
| 4162 | − | |
| 4163 | 3305 | void Application::packetSentNotification(ssize_t length) { |
| 4164 | 3306 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); |
| 4165 | 3307 | } |