History

merge

atlante45 committed 13 years ago

Commit 6b58e1b2 parents 2eb29ee 94952fe28 files · +1580 −1443Browse files

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

Unified · Split

interface/src/Application.cpp+171−1031
@@ -26,17 +26,11 @@ · 25 unmodified lines
2626 #include "InterfaceConfig.h"
2727
2828 #include <QActionGroup>
29−#include <QBoxLayout>
3029 #include <QColorDialog>
31−#include <QDialogButtonBox>
3230 #include <QDesktopWidget>
33−#include <QDoubleSpinBox>
3431 #include <QCheckBox>
35−#include <QFormLayout>
36−#include <QGLWidget>
3732 #include <QImage>
3833 #include <QKeyEvent>
39−#include <QLineEdit>
4034 #include <QMainWindow>
4135 #include <QMenuBar>
4236 #include <QMouseEvent>
@@ -64,6 +58,7 @@ · 21 unmodified lines
6458 #include "Application.h"
6559 #include "LogDisplay.h"
6660 #include "LeapManager.h"
61+#include "Menu.h"
6762 #include "OculusManager.h"
6863 #include "Util.h"
6964 #include "renderer/ProgramObject.h"
@@ -79,11 +74,6 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt"; · 9 unmodified lines
7974
8075 static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
8176
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−
8777 const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff
8878 // in the idle loop? (60 FPS is default)
8979 static QTimer* idleTimer = NULL;
@@ -92,87 +82,6 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 2 unmodified lines
9282 // Startup optimistically with small jitter buffer that
9383 // will start playback on the second received audio packet.
9484
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−
17685 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
17786 fprintf(stdout, "%s", message.toLocal8Bit().constData());
17887 LogDisplay::instance.addMessage(message.toLocal8Bit().constData());
@@ -182,22 +91,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines
18291 QApplication(argc, argv),
18392 _window(new QMainWindow(desktop())),
18493 _glWidget(new GLCanvas()),
185− _bandwidthDialog(NULL),
186− _voxelStatsDialog(NULL),
18794 _displayLevels(false),
18895 _frameCount(0),
18996 _fps(120.0f),
19097 _justStarted(true),
191− _particleSystemInitialized(false),
192− _coolDemoParticleEmitter(-1),
19398 _voxelImporter(_window),
19499 _wantToKillLocalVoxels(false),
195− _frustumDrawingMode(FRUSTUM_DRAW_MODE_ALL),
196− _viewFrustumOffsetYaw(-135.0),
197− _viewFrustumOffsetPitch(0.0),
198− _viewFrustumOffsetRoll(0.0),
199− _viewFrustumOffsetDistance(25.0),
200− _viewFrustumOffsetUp(0.0),
201100 _audioScope(256, 200, true),
202101 _mouseX(0),
203102 _mouseY(0),
@@ -255,7 +154,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 51 unmodified lines
255154 }
256155
257156 // setup QSettings
258−#ifdef Q_WS_MAC
157+#ifdef Q_OS_MAC
259158 QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources";
260159 #else
261160 QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources";
@@ -312,13 +211,16 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 50 unmodified lines
312211
313212 _window->setCentralWidget(_glWidget);
314213
315−#if defined(Q_WS_MAC) && defined(QT_NO_DEBUG)
214+#if defined(Q_OS_MAC) && defined(QT_NO_DEBUG)
316215 // if this is a release OS X build use fervor to check for an update
317216 FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml");
318217 FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
319218 #endif
320219
321− initMenu();
220+ // call Menu getInstance static method to set up the menur
221+ Menu::getInstance();
222+
223+ _networkAccessManager = new QNetworkAccessManager(this);
322224
323225 QRect available = desktop()->availableGeometry();
324226 _window->resize(available.size());
@@ -454,14 +356,16 @@ void Application::paintGL() { · 129 unmodified lines
454356 // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera
455357 Camera whichCamera = _myCamera;
456358
457− if (_frustumOn->isChecked()) {
359+ if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
360+
361+ ViewFrustumOffset viewFrustumOffset = Menu::getInstance()->getViewFrustumOffset();
458362
459363 // set the camera to third-person view but offset so we can see the frustum
460364 _viewFrustumOffsetCamera.setTargetPosition(_myCamera.getTargetPosition());
461365 _viewFrustumOffsetCamera.setTargetRotation(_myCamera.getTargetRotation() * glm::quat(glm::radians(glm::vec3(
462− _viewFrustumOffsetPitch, _viewFrustumOffsetYaw, _viewFrustumOffsetRoll))));
463− _viewFrustumOffsetCamera.setUpShift (_viewFrustumOffsetUp );
464− _viewFrustumOffsetCamera.setDistance (_viewFrustumOffsetDistance);
366+ viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll))));
367+ _viewFrustumOffsetCamera.setUpShift(viewFrustumOffset.up);
368+ _viewFrustumOffsetCamera.setDistance(viewFrustumOffset.distance);
465369 _viewFrustumOffsetCamera.initialize(); // force immediate snap to ideal position and orientation
466370 _viewFrustumOffsetCamera.update(1.f/_fps);
467371 whichCamera = _viewFrustumOffsetCamera;
@@ -491,7 +395,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 23 unmodified lines
491395 camera.setFieldOfView(2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf));
492396 } else {
493397 camera.setAspectRatio(aspectRatio);
494− camera.setFieldOfView(_fieldOfView);
398+ camera.setFieldOfView(Menu::getInstance()->getFieldOfView());
495399 }
496400 }
497401
@@ -521,7 +425,7 @@ void Application::resizeGL(int width, int height) { · 23 unmodified lines
521425
522426 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
523427 // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum
524− if (_frustumOn->isChecked()) {
428+ if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
525429 nearVal = _viewFrustumOffsetCamera.getNearClip();
526430 farVal = _viewFrustumOffsetCamera.getFarClip();
527431 }
@@ -537,7 +441,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 9 unmodified lines
537441 for (int i = 0; i < numNodeTypes; ++i) {
538442
539443 // Intercept data to voxel server when voxels are disabled
540− if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && ! self->_renderVoxels->isChecked()) {
444+ if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
541445 continue;
542446 }
543447
@@ -579,53 +483,25 @@ void Application::keyPressEvent(QKeyEvent* event) { · 35 unmodified lines
579483 }
580484
581485 //this is for switching between modes for the leap rave glove test
582− if (_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()) {
486+ if (Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand)
487+ || Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove)) {
583488 _myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event);
584489 }
585490
586− bool isMeta = event->modifiers().testFlag(Qt::MetaModifier);
587491 bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
588492 switch (event->key()) {
589493 case Qt::Key_BracketLeft:
590− _viewFrustumOffsetYaw -= 0.5;
591− break;
592−
593494 case Qt::Key_BracketRight:
594− _viewFrustumOffsetYaw += 0.5;
595− break;
596−
597495 case Qt::Key_BraceLeft:
598− _viewFrustumOffsetPitch -= 0.5;
599− break;
600−
601496 case Qt::Key_BraceRight:
602− _viewFrustumOffsetPitch += 0.5;
603− break;
604−
605497 case Qt::Key_ParenLeft:
606− _viewFrustumOffsetRoll -= 0.5;
607− break;
608−
609498 case Qt::Key_ParenRight:
610− _viewFrustumOffsetRoll += 0.5;
611− break;
612−
613499 case Qt::Key_Less:
614− _viewFrustumOffsetDistance -= 0.5;
615− break;
616−
617500 case Qt::Key_Greater:
618− _viewFrustumOffsetDistance += 0.5;
619− break;
620−
621501 case Qt::Key_Comma:
622− _viewFrustumOffsetUp -= 0.05;
623− break;
624−
625502 case Qt::Key_Period:
626− _viewFrustumOffsetUp += 0.05;
503+ Menu::getInstance()->handleViewFrustumOffsetKeyModifier(event->key());
627504 break;
628−
629505 case Qt::Key_Semicolon:
630506 _audio.ping();
631507 break;
@@ -645,9 +521,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines
645521
646522 case Qt::Key_C:
647523 if (isShifted) {
648− _occlusionCulling->trigger();
649− } else if (isMeta) {
650− chooseVoxelPaintColor();
524+ Menu::getInstance()->triggerOption(MenuOption::OcclusionCulling);
651525 } else {
652526 _myAvatar.setDriveKeys(DOWN, 1);
653527 }
@@ -659,7 +533,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines
659533
660534 case Qt::Key_S:
661535 if (isShifted) {
662− doTreeStats();
536+ _voxels.collectStatsForTreesAndVBOs();
663537 } else {
664538 _myAvatar.setDriveKeys(BACK, 1);
665539 }
@@ -672,15 +546,15 @@ void Application::keyPressEvent(QKeyEvent* event) { · 6 unmodified lines
672546
673547 case Qt::Key_G:
674548 if (isShifted) {
675− _gravityUse->trigger();
549+ Menu::getInstance()->triggerOption(MenuOption::Gravity);
676550 } else {
677− _eyedropperMode->trigger();
551+ Menu::getInstance()->triggerOption(MenuOption::VoxelGetColorMode);
678552 }
679553 break;
680554
681555 case Qt::Key_A:
682556 if (isShifted) {
683− _renderAtmosphereOn->trigger();
557+ Menu::getInstance()->triggerOption(MenuOption::Atmosphere);
684558 } else {
685559 _myAvatar.setDriveKeys(ROT_LEFT, 1);
686560 }
@@ -773,56 +647,53 @@ void Application::keyPressEvent(QKeyEvent* event) { · 86 unmodified lines
773647 }
774648 resizeGL(_glWidget->width(), _glWidget->height());
775649 break;
776− case Qt::Key_N:
777− _noise->trigger();
778− break;
779650 case Qt::Key_H:
780− _lookingInMirror->trigger();
651+ Menu::getInstance()->triggerOption(MenuOption::Mirror);
781652 break;
782653 case Qt::Key_F:
783654 if (isShifted) {
784− _frustumOn->trigger();
655+ Menu::getInstance()->triggerOption(MenuOption::DisplayFrustum);
785656 } else {
786− _fullScreenMode->trigger();
657+ Menu::getInstance()->triggerOption(MenuOption::Fullscreen);
787658 }
788659 break;
789660 case Qt::Key_V:
790661 if (isShifted) {
791− _renderVoxels->trigger();
662+ Menu::getInstance()->triggerOption(MenuOption::Voxels);
792663 } else {
793− _addVoxelMode->trigger();
664+ Menu::getInstance()->triggerOption(MenuOption::VoxelAddMode);
794665 }
795666 break;
796667 case Qt::Key_P:
797− _manualFirstPerson->trigger();
668+ Menu::getInstance()->triggerOption(MenuOption::FirstPerson);
798669 break;
799670 case Qt::Key_R:
800671 if (isShifted) {
801− _frustumRenderModeAction->trigger();
672+ Menu::getInstance()->triggerOption(MenuOption::FrustumRenderMode);
802673 } else {
803− _deleteVoxelMode->trigger();
674+ Menu::getInstance()->triggerOption(MenuOption::VoxelDeleteMode);
804675 }
805676 break;
806677 case Qt::Key_B:
807− _colorVoxelMode->trigger();
678+ Menu::getInstance()->triggerOption(MenuOption::VoxelColorMode);
808679 break;
809680 case Qt::Key_O:
810− _selectVoxelMode->trigger();
681+ Menu::getInstance()->triggerOption(MenuOption::VoxelSelectMode);
811682 break;
812683 case Qt::Key_Slash:
813− _renderStatsOn->trigger();
684+ Menu::getInstance()->triggerOption(MenuOption::Stats);
814685 break;
815686 case Qt::Key_Backspace:
816687 case Qt::Key_Delete:
817− if (_selectVoxelMode->isChecked()) {
688+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) {
818689 deleteVoxelUnderCursor();
819690 }
820691 break;
821692 case Qt::Key_Plus:
822− increaseAvatarSize();
693+ _myAvatar.increaseSize();
823694 break;
824695 case Qt::Key_Minus:
825− decreaseAvatarSize();
696+ _myAvatar.decreaseSize();
826697 break;
827698
828699 case Qt::Key_1:
@@ -833,7 +704,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines
833704 case Qt::Key_6:
834705 case Qt::Key_7:
835706 case Qt::Key_8:
836− _swatch.handleEvent(event->key(), _eyedropperMode->isChecked());
707+ _swatch.handleEvent(event->key(), Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode));
837708 break;
838709 default:
839710 event->ignore();
@@ -912,7 +783,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 72 unmodified lines
912783 if (event->buttons().testFlag(Qt::LeftButton)) {
913784 maybeEditVoxelUnderCursor();
914785
915− } else if (event->buttons().testFlag(Qt::RightButton) && checkedVoxelModeAction() != 0) {
786+ } else if (event->buttons().testFlag(Qt::RightButton) && Menu::getInstance()->isVoxelModeActionChecked()) {
916787 deleteVoxelUnderCursor();
917788 }
918789 }
@@ -960,7 +831,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 41 unmodified lines
960831 _isHoverVoxelSounding = true;
961832 }
962833
963− } else if (event->button() == Qt::RightButton && checkedVoxelModeAction() != 0) {
834+ } else if (event->button() == Qt::RightButton && Menu::getInstance()->isVoxelModeActionChecked()) {
964835 deleteVoxelUnderCursor();
965836 }
966837 }
@@ -1019,7 +890,7 @@ const bool USE_MOUSEWHEEL = false; · 52 unmodified lines
1019890 void Application::wheelEvent(QWheelEvent* event) {
1020891 // Wheel Events disabled for now because they are also activated by touch look pitch up/down.
1021892 if (USE_MOUSEWHEEL && (activeWindow() == _window)) {
1022− if (checkedVoxelModeAction() == 0) {
893+ if (!Menu::getInstance()->isVoxelModeActionChecked()) {
1023894 event->ignore();
1024895 return;
1025896 }
@@ -1079,7 +950,7 @@ void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& d · 53 unmodified lines
1079950 void Application::timer() {
1080951 gettimeofday(&_timerEnd, NULL);
1081952
1082− if (_testPing->isChecked()) {
953+ if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
1083954 sendPingPackets();
1084955 }
1085956
@@ -1155,8 +1026,8 @@ void Application::terminate() { · 69 unmodified lines
11551026
11561027 LeapManager::terminate();
11571028
1158− if (_settingsAutosave->isChecked()) {
1159− saveSettings();
1029+ if (Menu::getInstance()->isOptionChecked(MenuOption::SettingsAutosave)) {
1030+ Menu::getInstance()->saveSettings();
11601031 _settings->sync();
11611032 }
11621033
@@ -1169,24 +1040,6 @@ void Application::terminate() { · 6 unmodified lines
11691040 _voxelEditSender.terminate();
11701041 }
11711042
1172−void Application::sendAvatarVoxelURLMessage(const QUrl& url) {
1173− uint16_t ownerID = NodeList::getInstance()->getOwnerID();
1174−
1175− if (ownerID == UNKNOWN_NODE_ID) {
1176− return; // we don't yet know who we are
1177− }
1178− QByteArray message;
1179−
1180− char packetHeader[MAX_PACKET_HEADER_BYTES];
1181− int numBytesPacketHeader = populateTypeAndVersion((unsigned char*) packetHeader, PACKET_TYPE_AVATAR_VOXEL_URL);
1182−
1183− message.append(packetHeader, numBytesPacketHeader);
1184− message.append((const char*)&ownerID, sizeof(ownerID));
1185− message.append(url.toEncoded());
1186−
1187− controlledBroadcastToNodes((unsigned char*)message.data(), message.size(), & NODE_TYPE_AVATAR_MIXER, 1);
1188−}
1189−
11901043 static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) {
11911044 // record the packet for stats-tracking
11921045 Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes);
@@ -1236,207 +1089,22 @@ void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_ · 43 unmodified lines
12361089 void Application::checkBandwidthMeterClick() {
12371090 // ... to be called upon button release
12381091
1239− if (_bandwidthDisplayOn->isChecked() &&
1092+ if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
12401093 glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY))) <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH &&
12411094 _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) {
12421095
12431096 // The bandwidth meter is visible, the click didn't get dragged too far and
12441097 // we actually hit the bandwidth meter
1245− bandwidthDetails();
1098+ Menu::getInstance()->bandwidthDetails();
12461099 }
12471100 }
12481101
1249−void Application::bandwidthDetails() {
1250−
1251− if (! _bandwidthDialog) {
1252− _bandwidthDialog = new BandwidthDialog(_glWidget, getBandwidthMeter());
1253− connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed()));
1254−
1255− _bandwidthDialog->show();
1256− }
1257− _bandwidthDialog->raise();
1258−}
1259−
1260−void Application::bandwidthDetailsClosed() {
1261−
1262− QDialog* dlg = _bandwidthDialog;
1263− _bandwidthDialog = NULL;
1264− delete dlg;
1265−}
1266−
1267−void Application::voxelStatsDetails() {
1268− if (!_voxelStatsDialog) {
1269− _voxelStatsDialog = new VoxelStatsDialog(_glWidget, &_voxelSceneStats);
1270− connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed()));
1271− _voxelStatsDialog->show();
1272− }
1273− _voxelStatsDialog->raise();
1274−}
1275−
1276−void Application::voxelStatsDetailsClosed() {
1277− QDialog* dlg = _voxelStatsDialog;
1278− _voxelStatsDialog = NULL;
1279− delete dlg;
1280−}
1281−
1282−void Application::editPreferences() {
1283− QDialog dialog(_glWidget);
1284− dialog.setWindowTitle("Interface Preferences");
1285− QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
1286− dialog.setLayout(layout);
1287−
1288− QFormLayout* form = new QFormLayout();
1289− layout->addLayout(form, 1);
1290−
1291− const int QLINE_MINIMUM_WIDTH = 400;
1292−
1293− QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname()));
1294− domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH);
1295− form->addRow("Domain server:", domainServerHostname);
1296−
1297− QLineEdit* avatarURL = new QLineEdit(_myAvatar.getVoxels()->getVoxelURL().toString());
1298− avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
1299− form->addRow("Avatar URL:", avatarURL);
1300−
1301− QSpinBox* fieldOfView = new QSpinBox();
1302− fieldOfView->setMaximum(180);
1303− fieldOfView->setMinimum(1);
1304− fieldOfView->setValue(_fieldOfView);
1305− form->addRow("Vertical Field of View (Degrees):", fieldOfView);
1306−
1307− QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox();
1308− gyroCameraSensitivity->setValue(_gyroCameraSensitivity);
1309− form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity);
1310−
1311− QDoubleSpinBox* leanScale = new QDoubleSpinBox();
1312− leanScale->setValue(_myAvatar.getLeanScale());
1313− form->addRow("Lean Scale:", leanScale);
1314−
1315− QSpinBox* audioJitterBufferSamples = new QSpinBox();
1316− audioJitterBufferSamples->setMaximum(10000);
1317− audioJitterBufferSamples->setMinimum(-10000);
1318− audioJitterBufferSamples->setValue(_audioJitterBufferSamples);
1319− form->addRow("Audio Jitter Buffer Samples (0 for automatic):", audioJitterBufferSamples);
1320−
1321− QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
1322− dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
1323− dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
1324− layout->addWidget(buttons);
1325−
1326− if (dialog.exec() != QDialog::Accepted) {
1327− return;
1328− }
1329−
1330− QByteArray newHostname;
1331−
1332− if (domainServerHostname->text().size() > 0) {
1333− // the user input a new hostname, use that
1334− newHostname = domainServerHostname->text().toLocal8Bit();
1335− } else {
1336− // the user left the field blank, use the default hostname
1337− newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME);
1338− }
1339−
1340− // check if the domain server hostname is new
1341− if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) {
1342−
1343− NodeList::getInstance()->clear();
1344−
1345− // kill the local voxels
1346− _voxels.killLocalVoxels();
1347−
1348− // reset the environment to default
1349− _environment.resetToDefault();
1350−
1351− // set the new hostname
1352− NodeList::getInstance()->setDomainHostname(newHostname.constData());
1353− }
1354−
1355− QUrl url(avatarURL->text());
1356− _myAvatar.getVoxels()->setVoxelURL(url);
1357− sendAvatarVoxelURLMessage(url);
1358−
1359− _gyroCameraSensitivity = gyroCameraSensitivity->value();
1360− _myAvatar.setLeanScale(leanScale->value());
1361− _audioJitterBufferSamples = audioJitterBufferSamples->value();
1362− if (!shouldDynamicallySetJitterBuffer()) {
1363− _audio.setJitterBufferSamples(_audioJitterBufferSamples);
1364− }
1365− _fieldOfView = fieldOfView->value();
1366− resizeGL(_glWidget->width(), _glWidget->height());
1367−
1368−}
1369−
1370−void Application::pair() {
1371− PairingHandler::sendPairRequest();
1372−}
1373−
1374−void Application::setRenderMirrored(bool mirrored) {
1375− if (mirrored) {
1376− _manualFirstPerson->setChecked(false);
1377− _manualThirdPerson->setChecked(false);
1378− }
1379−}
1380−
1381−void Application::setNoise(bool noise) {
1382− _myAvatar.setNoise(noise);
1383−}
1384−
13851102 void Application::setFullscreen(bool fullscreen) {
13861103 _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) :
13871104 (_window->windowState() & ~Qt::WindowFullScreen));
13881105 updateCursor();
13891106 }
13901107
1391−void Application::setRenderFirstPerson(bool firstPerson) {
1392− if (firstPerson) {
1393− _lookingInMirror->setChecked(false);
1394− _manualThirdPerson->setChecked(false);
1395− } else {
1396− _manualThirdPerson->trigger();
1397− }
1398−}
1399−
1400−void Application::setRenderThirdPerson(bool thirdPerson) {
1401− if (thirdPerson) {
1402− _lookingInMirror->setChecked(false);
1403− _manualFirstPerson->setChecked(false);
1404− }
1405−}
1406−
1407−void Application::increaseAvatarSize() {
1408− if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) {
1409− _myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale());
1410− qDebug("Changed scale to %f\n", _myAvatar.getNewScale());
1411− }
1412−}
1413−
1414−void Application::decreaseAvatarSize() {
1415− if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) {
1416− _myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale());
1417− qDebug("Changed scale to %f\n", _myAvatar.getNewScale());
1418− }
1419−}
1420−
1421−void Application::resetAvatarSize() {
1422− _myAvatar.setNewScale(1.f);
1423− qDebug("Reseted scale to %f\n", _myAvatar.getNewScale());
1424−}
1425−
1426−void Application::setFrustumOffset(bool frustumOffset) {
1427− // reshape so that OpenGL will get the right lens details for the camera of choice
1428− resizeGL(_glWidget->width(), _glWidget->height());
1429−}
1430−
1431−void Application::cycleFrustumRenderMode() {
1432− _frustumDrawingMode = (FrustumDrawMode)((_frustumDrawingMode + 1) % FRUSTUM_DRAW_MODE_COUNT);
1433− updateFrustumRenderModeAction();
1434−}
1435−
1436−void Application::setRenderWarnings(bool renderWarnings) {
1437− _voxels.setRenderPipelineWarnings(renderWarnings);
1438−}
1439−
14401108 void Application::setRenderVoxels(bool voxelRender) {
14411109 if (!voxelRender) {
14421110 doKillLocalVoxels();
@@ -1447,75 +1115,6 @@ void Application::doKillLocalVoxels() { · 4 unmodified lines
14471115 _wantToKillLocalVoxels = true;
14481116 }
14491117
1450−void Application::doRandomizeVoxelColors() {
1451− _voxels.randomizeVoxelColors();
1452−}
1453−
1454−void Application::doFalseRandomizeVoxelColors() {
1455− _voxels.falseColorizeRandom();
1456−}
1457−
1458−void Application::doFalseRandomizeEveryOtherVoxelColors() {
1459− _voxels.falseColorizeRandomEveryOther();
1460−}
1461−
1462−void Application::doFalseColorizeByDistance() {
1463− loadViewFrustum(_myCamera, _viewFrustum);
1464− _voxels.falseColorizeDistanceFromView(&_viewFrustum);
1465−}
1466−
1467−void Application::doFalseColorizeInView() {
1468− loadViewFrustum(_myCamera, _viewFrustum);
1469− // we probably want to make sure the viewFrustum is initialized first
1470− _voxels.falseColorizeInView(&_viewFrustum);
1471−}
1472−
1473−void Application::doFalseColorizeOccluded() {
1474− CoverageMap::wantDebugging = true;
1475− _voxels.falseColorizeOccluded();
1476−}
1477−
1478−void Application::doFalseColorizeOccludedV2() {
1479− _voxels.falseColorizeOccludedV2();
1480−}
1481−
1482−void Application::doFalseColorizeBySource() {
1483− _voxels.falseColorizeBySource();
1484−}
1485−
1486−void Application::doTrueVoxelColors() {
1487− _voxels.trueColorize();
1488−}
1489−
1490−void Application::doTreeStats() {
1491− _voxels.collectStatsForTreesAndVBOs();
1492−}
1493−
1494−void Application::disableLowResMoving(bool disableLowResMoving) {
1495− _myAvatar.setWantLowResMoving(!disableLowResMoving);
1496−}
1497−
1498−void Application::setWantsMonochrome(bool wantsMonochrome) {
1499− _myAvatar.setWantColor(!wantsMonochrome);
1500−}
1501−
1502−void Application::disableDeltaSending(bool disableDeltaSending) {
1503− _myAvatar.setWantDelta(!disableDeltaSending);
1504−}
1505−
1506−void Application::disableOcclusionCulling(bool disableOcclusionCulling) {
1507− _myAvatar.setWantOcclusionCulling(!disableOcclusionCulling);
1508−}
1509−
1510−void Application::updateVoxelModeActions() {
1511− // only the sender can be checked
1512− foreach (QAction* action, _voxelModeActions->actions()) {
1513− if (action->isChecked() && action != sender()) {
1514− action->setChecked(false);
1515− }
1516− }
1517−}
1518−
15191118 const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) {
15201119 return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE,
15211120 (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE,
@@ -1530,27 +1129,6 @@ void Application::increaseVoxelSize() { · 8 unmodified lines
15301129 _mouseVoxelScale *= 2;
15311130 }
15321131
1533−void Application::resetSwatchColors() {
1534− _swatch.reset();
1535−}
1536−
1537−static QIcon createSwatchIcon(const QColor& color) {
1538− QPixmap map(16, 16);
1539− map.fill(color);
1540− return QIcon(map);
1541−}
1542−
1543−void Application::chooseVoxelPaintColor() {
1544− QColor selected = QColorDialog::getColor(_voxelPaintColor->data().value<QColor>(), _glWidget, "Voxel Paint Color");
1545− if (selected.isValid()) {
1546− _voxelPaintColor->setData(selected);
1547− _voxelPaintColor->setIcon(createSwatchIcon(selected));
1548− }
1549−
1550− // restore the main window's active state
1551− _window->activateWindow();
1552−}
1553−
15541132 const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500;
15551133 struct SendVoxelsOperationArgs {
15561134 unsigned char* newBaseOctCode;
@@ -1823,196 +1401,6 @@ void Application::pasteVoxels() { · 266 unmodified lines
18231401 }
18241402 }
18251403
1826−void Application::initMenu() {
1827− QMenuBar* menuBar = new QMenuBar();
1828− _window->setMenuBar(menuBar);
1829−
1830− QMenu* fileMenu = menuBar->addMenu("File");
1831− QAction* quitAction = fileMenu->addAction("Quit", this, SLOT(quit()), Qt::CTRL | Qt::Key_Q);
1832− quitAction->setMenuRole(QAction::QuitRole);
1833−
1834− QMenu* editMenu = menuBar->addMenu("Edit");
1835− QAction* preferencesAction = editMenu->addAction("Preferences...", this, SLOT(editPreferences()), Qt::CTRL | Qt::Key_Comma);
1836− preferencesAction->setMenuRole(QAction::PreferencesRole);
1837−
1838− QMenu* pairMenu = menuBar->addMenu("Pair");
1839− pairMenu->addAction("Pair", this, SLOT(pair()));
1840−
1841− QMenu* optionsMenu = menuBar->addMenu("Options");
1842− (_lookingInMirror = optionsMenu->addAction("Mirror", this, SLOT(setRenderMirrored(bool)), Qt::Key_H))->setCheckable(true);
1843−
1844−
1845− (_noise = optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N))->setCheckable(true);
1846− (_gyroLook = optionsMenu->addAction("Smooth Gyro Look"))->setCheckable(true);
1847− _gyroLook->setChecked(true);
1848− (_showHeadMouse = optionsMenu->addAction("Head Mouse"))->setCheckable(true);
1849− _showHeadMouse->setChecked(false);
1850− (_transmitterDrives = optionsMenu->addAction("Transmitter Drive"))->setCheckable(true);
1851− _transmitterDrives->setChecked(true);
1852− (_gravityUse = optionsMenu->addAction("Use Gravity"))->setCheckable(true);
1853− _gravityUse->setChecked(true);
1854− _gravityUse->setShortcut(Qt::SHIFT | Qt::Key_G);
1855− (_testPing = optionsMenu->addAction("Test Ping"))->setCheckable(true);
1856− _testPing->setChecked(true);
1857− (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true);
1858− optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true);
1859− optionsMenu->addAction("Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true);
1860− (_wantCollisionsOn = optionsMenu->addAction("Turn collisions On", this, SLOT(toggleWantCollisionsOn())))->setCheckable(true);
1861− _wantCollisionsOn->setChecked(true);
1862− optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode()));
1863− optionsMenu->addAction("Webcam Texture", _webcam.getGrabber(), SLOT(setDepthOnly(bool)))->setCheckable(true);
1864− optionsMenu->addAction("Go Home", this, SLOT(goHome()), Qt::CTRL | Qt::Key_G);
1865−
1866− QMenu* audioMenu = menuBar->addMenu("Audio");
1867− (_echoAudioMode = audioMenu->addAction("Echo Audio"))->setCheckable(true);
1868− _rawAudioMicrophoneMix = audioMenu->addAction("Mix RAW Song", this, SLOT(toggleMixedSong()));
1869−
1870− QMenu* renderMenu = menuBar->addMenu("Render");
1871− (_renderVoxels = renderMenu->addAction("Voxels", this, SLOT(setRenderVoxels(bool)), Qt::SHIFT | Qt::Key_V))->setCheckable(true);
1872− _renderVoxels->setChecked(true);
1873− (_renderVoxelTextures = renderMenu->addAction("Voxel Textures"))->setCheckable(true);
1874− (_renderStarsOn = renderMenu->addAction("Stars"))->setCheckable(true);
1875− _renderStarsOn->setChecked(true);
1876− _renderStarsOn->setShortcut(Qt::Key_Asterisk);
1877− (_renderAtmosphereOn = renderMenu->addAction("Atmosphere"))->setCheckable(true);
1878− _renderAtmosphereOn->setChecked(true);
1879− _renderAtmosphereOn->setShortcut(Qt::SHIFT | Qt::Key_A);
1880− (_renderGroundPlaneOn = renderMenu->addAction("Ground Plane"))->setCheckable(true);
1881− _renderGroundPlaneOn->setChecked(true);
1882− (_renderAvatarsOn = renderMenu->addAction("Avatars"))->setCheckable(true);
1883− _renderAvatarsOn->setChecked(true);
1884− (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true);
1885− _renderAvatarBalls->setChecked(false);
1886− renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
1887− renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode()));
1888− renderMenu->addAction("Cycle Glow Mode", &_glowEffect, SLOT(cycleRenderMode()));
1889− (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
1890− _renderFrameTimerOn->setChecked(false);
1891− (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);
1892− _renderLookatOn->setChecked(false);
1893− (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true);
1894− _renderLookatIndicatorOn->setChecked(true);
1895− (_renderParticleSystemOn = renderMenu->addAction("Particle System"))->setCheckable(true);
1896− (_manualFirstPerson = renderMenu->addAction(
1897− "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);
1898− (_manualThirdPerson = renderMenu->addAction(
1899− "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true);
1900− renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus);
1901− renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus);
1902− renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize()));
1903−
1904−
1905− QMenu* toolsMenu = menuBar->addMenu("Tools");
1906− (_renderStatsOn = toolsMenu->addAction("Stats"))->setCheckable(true);
1907− _renderStatsOn->setShortcut(Qt::Key_Slash);
1908− (_logOn = toolsMenu->addAction("Log"))->setCheckable(true);
1909− _logOn->setChecked(false);
1910− _logOn->setShortcut(Qt::CTRL | Qt::Key_L);
1911− (_oscilloscopeOn = toolsMenu->addAction("Audio Oscilloscope"))->setCheckable(true);
1912− _oscilloscopeOn->setChecked(true);
1913− (_bandwidthDisplayOn = toolsMenu->addAction("Bandwidth Display"))->setCheckable(true);
1914− _bandwidthDisplayOn->setChecked(true);
1915− toolsMenu->addAction("Bandwidth Details", this, SLOT(bandwidthDetails()));
1916− toolsMenu->addAction("Voxel Stats Details", this, SLOT(voxelStatsDetails()));
1917−
1918−
1919− QMenu* voxelMenu = menuBar->addMenu("Voxels");
1920− _voxelModeActions = new QActionGroup(this);
1921− _voxelModeActions->setExclusive(false); // exclusivity implies one is always checked
1922−
1923− (_addVoxelMode = voxelMenu->addAction(
1924− "Add Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_V))->setCheckable(true);
1925− _voxelModeActions->addAction(_addVoxelMode);
1926− (_deleteVoxelMode = voxelMenu->addAction(
1927− "Delete Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_R))->setCheckable(true);
1928− _voxelModeActions->addAction(_deleteVoxelMode);
1929− (_colorVoxelMode = voxelMenu->addAction(
1930− "Color Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_B))->setCheckable(true);
1931− _voxelModeActions->addAction(_colorVoxelMode);
1932− (_selectVoxelMode = voxelMenu->addAction(
1933− "Select Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_O))->setCheckable(true);
1934− _voxelModeActions->addAction(_selectVoxelMode);
1935− (_eyedropperMode = voxelMenu->addAction(
1936− "Get Color Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_G))->setCheckable(true);
1937− _voxelModeActions->addAction(_eyedropperMode);
1938−
1939− voxelMenu->addAction("Decrease Voxel Size", this, SLOT(decreaseVoxelSize()), QKeySequence::ZoomOut);
1940− voxelMenu->addAction("Increase Voxel Size", this, SLOT(increaseVoxelSize()), QKeySequence::ZoomIn);
1941− voxelMenu->addAction("Reset Swatch Colors", this, SLOT(resetSwatchColors()));
1942−
1943− _voxelPaintColor = voxelMenu->addAction("Voxel Paint Color", this,
1944− SLOT(chooseVoxelPaintColor()), Qt::META | Qt::Key_C);
1945− _swatch.setAction(_voxelPaintColor);
1946−
1947− QColor paintColor(128, 128, 128);
1948− _voxelPaintColor->setData(paintColor);
1949− _voxelPaintColor->setIcon(createSwatchIcon(paintColor));
1950− (_destructiveAddVoxel = voxelMenu->addAction("Create Voxel is Destructive"))->setCheckable(true);
1951−
1952− voxelMenu->addAction("Export Voxels", this, SLOT(exportVoxels()), Qt::CTRL | Qt::Key_E);
1953− voxelMenu->addAction("Import Voxels", &_voxelImporter, SLOT(import()), Qt::CTRL | Qt::Key_I);
1954− voxelMenu->addAction("Cut Voxels", this, SLOT(cutVoxels()), Qt::CTRL | Qt::Key_X);
1955− voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C);
1956− voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V);
1957−
1958− QMenu* debugMenu = menuBar->addMenu("Debug");
1959−
1960− QMenu* frustumMenu = debugMenu->addMenu("View Frustum Debugging Tools");
1961− (_frustumOn = frustumMenu->addAction("Display Frustum"))->setCheckable(true);
1962− _frustumOn->setShortcut(Qt::SHIFT | Qt::Key_F);
1963− _frustumRenderModeAction = frustumMenu->addAction(
1964− "Render Mode", this, SLOT(cycleFrustumRenderMode()), Qt::SHIFT | Qt::Key_R);
1965− updateFrustumRenderModeAction();
1966−
1967− debugMenu->addAction("Run Timing Tests", this, SLOT(runTests()));
1968− debugMenu->addAction("Calculate Tree Stats", this, SLOT(doTreeStats()), Qt::SHIFT | Qt::Key_S);
1969−
1970− QMenu* renderDebugMenu = debugMenu->addMenu("Render Debugging Tools");
1971− (_renderPipelineWarnings = renderDebugMenu->addAction("Show Render Pipeline Warnings",
1972− this, SLOT(setRenderWarnings(bool))))->setCheckable(true);
1973− renderDebugMenu->addAction("Kill Local Voxels", this, SLOT(doKillLocalVoxels()), Qt::CTRL | Qt::Key_K);
1974− renderDebugMenu->addAction("Randomize Voxel TRUE Colors", this, SLOT(doRandomizeVoxelColors()), Qt::CTRL | Qt::Key_R);
1975− renderDebugMenu->addAction("FALSE Color Voxels Randomly", this, SLOT(doFalseRandomizeVoxelColors()));
1976− renderDebugMenu->addAction("FALSE Color Voxel Every Other Randomly", this, SLOT(doFalseRandomizeEveryOtherVoxelColors()));
1977− renderDebugMenu->addAction("FALSE Color Voxels by Distance", this, SLOT(doFalseColorizeByDistance()));
1978− renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView()));
1979− renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O);
1980− renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P);
1981− renderDebugMenu->addAction("FALSE Color By Source", this, SLOT(doFalseColorizeBySource()), Qt::CTRL | Qt::SHIFT | Qt::Key_S);
1982− renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T);
1983−
1984− (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true);
1985−
1986− debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true);
1987− debugMenu->addAction("Disable Lower Resolution While Moving", this, SLOT(disableLowResMoving(bool)))->setCheckable(true);
1988− debugMenu->addAction("Disable Delta Sending", this, SLOT(disableDeltaSending(bool)))->setCheckable(true);
1989− (_occlusionCulling = debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)),
1990− Qt::SHIFT | Qt::Key_C))->setCheckable(true);
1991−
1992− (_renderCoverageMap = debugMenu->addAction("Render Coverage Map"))->setCheckable(true);
1993− _renderCoverageMap->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_O);
1994− (_renderCoverageMapV2 = debugMenu->addAction("Render Coverage Map V2"))->setCheckable(true);
1995− _renderCoverageMapV2->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_P);
1996−
1997− (_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true);
1998− (_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true);
1999−
2000− QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools");
2001− audioDebugMenu->addAction("Listen Mode Normal", this, SLOT(setListenModeNormal()), Qt::CTRL | Qt::Key_1);
2002− audioDebugMenu->addAction("Listen Mode Point/Radius", this, SLOT(setListenModePoint()), Qt::CTRL | Qt::Key_2);
2003− audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3);
2004−
2005− QMenu* settingsMenu = menuBar->addMenu("Settings");
2006− (_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true);
2007− _settingsAutosave->setChecked(true);
2008− settingsMenu->addAction("Load settings", this, SLOT(loadSettings()));
2009− settingsMenu->addAction("Save settings", this, SLOT(saveSettings()));
2010− settingsMenu->addAction("Import settings", this, SLOT(importSettings()));
2011− settingsMenu->addAction("Export settings", this, SLOT(exportSettings()));
2012−
2013− _networkAccessManager = new QNetworkAccessManager(this);
2014−}
2015−
20161404 void Application::setListenModeNormal() {
20171405 _audio.setListenMode(AudioRingBuffer::NORMAL);
20181406 }
@@ -2036,63 +1424,6 @@ void Application::setListenModeSingleSource() { · 17 unmodified lines
20361424 }
20371425 }
20381426
2039−void Application::toggleMixedSong() {
2040− if (_audio.getSongFileBytes() == 0) {
2041− QString filename = QFileDialog::getOpenFileName(_glWidget,
2042− tr("Choose RAW Audio file"),
2043− QStandardPaths::writableLocation(QStandardPaths::DesktopLocation),
2044− tr("RAW Audio file (*.raw)"));
2045−
2046− QByteArray filenameArray = filename.toLocal8Bit();
2047− _audio.importSongToMixWithMicrophone(filenameArray.data());
2048− resetSongMixMenuItem();
2049− } else {
2050− _audio.stopMixingSongWithMicrophone();
2051− resetSongMixMenuItem();
2052− }
2053−}
2054−
2055−void Application::toggleWantCollisionsOn() {
2056− _myAvatar.setWantCollisionsOn(_wantCollisionsOn->isChecked());
2057−}
2058−
2059−void Application::resetSongMixMenuItem() {
2060− if (_audio.getSongFileBytes() == 0) {
2061− _rawAudioMicrophoneMix->setText("Mix RAW Song");
2062− } else {
2063− _rawAudioMicrophoneMix->setText("Stop Mixing Song");
2064− }
2065−
2066−}
2067−
2068−void Application::updateFrustumRenderModeAction() {
2069− switch (_frustumDrawingMode) {
2070− default:
2071− case FRUSTUM_DRAW_MODE_ALL:
2072− _frustumRenderModeAction->setText("Render Mode - All");
2073− break;
2074− case FRUSTUM_DRAW_MODE_VECTORS:
2075− _frustumRenderModeAction->setText("Render Mode - Vectors");
2076− break;
2077− case FRUSTUM_DRAW_MODE_PLANES:
2078− _frustumRenderModeAction->setText("Render Mode - Planes");
2079− break;
2080− case FRUSTUM_DRAW_MODE_NEAR_PLANE:
2081− _frustumRenderModeAction->setText("Render Mode - Near");
2082− break;
2083− case FRUSTUM_DRAW_MODE_FAR_PLANE:
2084− _frustumRenderModeAction->setText("Render Mode - Far");
2085− break;
2086− case FRUSTUM_DRAW_MODE_KEYHOLE:
2087− _frustumRenderModeAction->setText("Render Mode - Keyhole");
2088− break;
2089− }
2090−}
2091−
2092−void Application::runTests() {
2093− runTimingTests();
2094−}
2095−
20961427 void Application::initDisplay() {
20971428 glEnable(GL_BLEND);
20981429 glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
@@ -2124,7 +1455,9 @@ void Application::init() { · 25 unmodified lines
21241455
21251456 OculusManager::connect();
21261457 if (OculusManager::isConnected()) {
2127− QMetaObject::invokeMethod(_fullScreenMode, "trigger", Qt::QueuedConnection);
1458+ QMetaObject::invokeMethod(Menu::getInstance()->getActionForOption(MenuOption::Fullscreen),
1459+ "trigger",
1460+ Qt::QueuedConnection);
21281461 }
21291462
21301463 LeapManager::initialize();
@@ -2132,22 +1465,22 @@ void Application::init() { · 1 unmodified line
21321465 gettimeofday(&_timerStart, NULL);
21331466 gettimeofday(&_lastTimeUpdated, NULL);
21341467
2135− loadSettings();
2136− if (!shouldDynamicallySetJitterBuffer()) {
2137− _audio.setJitterBufferSamples(_audioJitterBufferSamples);
1468+ Menu::getInstance()->loadSettings();
1469+ if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) {
1470+ _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples());
21381471 }
21391472
21401473 qDebug("Loaded settings.\n");
21411474
2142− sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
1475+ Avatar::sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
21431476
21441477 _palette.init(_glWidget->width(), _glWidget->height());
2145− _palette.addAction(_addVoxelMode, 0, 0);
2146− _palette.addAction(_deleteVoxelMode, 0, 1);
1478+ _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelAddMode), 0, 0);
1479+ _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelDeleteMode), 0, 1);
21471480 _palette.addTool(&_swatch);
2148− _palette.addAction(_colorVoxelMode, 0, 2);
2149− _palette.addAction(_eyedropperMode, 0, 3);
2150− _palette.addAction(_selectVoxelMode, 0, 4);
1481+ _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelColorMode), 0, 2);
1482+ _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelGetColorMode), 0, 3);
1483+ _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelSelectMode), 0, 4);
21511484
21521485 _pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg",
21531486 _glWidget->width(),
@@ -2374,7 +1707,7 @@ void Application::update(float deltaTime) { · 220 unmodified lines
23741707 }
23751708
23761709 _mouseVoxel.s = 0.0f;
2377− if (checkedVoxelModeAction() != 0 &&
1710+ if (Menu::getInstance()->isVoxelModeActionChecked() &&
23781711 (fabs(_myAvatar.getVelocity().x) +
23791712 fabs(_myAvatar.getVelocity().y) +
23801713 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
@@ -2399,7 +1732,7 @@ void Application::update(float deltaTime) { · 18 unmodified lines
23991732 _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / _mouseVoxelScale);
24001733 _mouseVoxel.s = _mouseVoxelScale;
24011734 }
2402− if (_addVoxelMode->isChecked()) {
1735+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {
24031736 // use the face to determine the side on which to create a neighbor
24041737 _mouseVoxel.x += faceVector.x * _mouseVoxel.s;
24051738 _mouseVoxel.y += faceVector.y * _mouseVoxel.s;
@@ -2409,7 +1742,8 @@ void Application::update(float deltaTime) { · 3 unmodified lines
24091742 } else {
24101743 _mouseVoxel.s = 0.0f;
24111744 }
2412− } else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) {
1745+ } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)
1746+ || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
24131747 // place the voxel a fixed distance away
24141748 float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE;
24151749 glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f);
@@ -2419,16 +1753,16 @@ void Application::update(float deltaTime) { · 3 unmodified lines
24191753 _mouseVoxel.s = _mouseVoxelScale;
24201754 }
24211755
2422− if (_deleteVoxelMode->isChecked()) {
1756+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) {
24231757 // red indicates deletion
24241758 _mouseVoxel.red = 255;
24251759 _mouseVoxel.green = _mouseVoxel.blue = 0;
2426− } else if (_selectVoxelMode->isChecked()) {
1760+ } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
24271761 // yellow indicates deletion
24281762 _mouseVoxel.red = _mouseVoxel.green = 255;
24291763 _mouseVoxel.blue = 0;
24301764 } else { // _addVoxelMode->isChecked() || _colorVoxelMode->isChecked()
2431− QColor paintColor = _voxelPaintColor->data().value<QColor>();
1765+ QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value<QColor>();
24321766 _mouseVoxel.red = paintColor.red();
24331767 _mouseVoxel.green = paintColor.green();
24341768 _mouseVoxel.blue = paintColor.blue();
@@ -2458,8 +1792,8 @@ void Application::update(float deltaTime) { · 23 unmodified lines
24581792 }
24591793
24601794 // Leap finger-sensing device
2461− LeapManager::enableFakeFingers(_simulateLeapHand->isChecked());
2462− _myAvatar.getHand().setRaveGloveActive(_testRaveGlove->isChecked());
1795+ LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand));
1796+ _myAvatar.getHand().setRaveGloveActive(Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove));
24631797 LeapManager::nextFrame(_myAvatar);
24641798
24651799 // Read serial port interface devices
@@ -2499,60 +1833,47 @@ void Application::update(float deltaTime) { · 33 unmodified lines
24991833 }
25001834
25011835 // Simulate myself
2502− if (_gravityUse->isChecked()) {
1836+ if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
25031837 _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));
25041838 }
25051839 else {
25061840 _myAvatar.setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
25071841 }
25081842
2509− if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) {
2510− _myAvatar.simulate(deltaTime, &_myTransmitter, _gyroCameraSensitivity);
1843+ if (Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) {
1844+ _myAvatar.simulate(deltaTime, &_myTransmitter, Menu::getInstance()->getGyroCameraSensitivity());
25111845 } else {
2512− _myAvatar.simulate(deltaTime, NULL, _gyroCameraSensitivity);
1846+ _myAvatar.simulate(deltaTime, NULL, Menu::getInstance()->getGyroCameraSensitivity());
25131847 }
25141848
25151849 if (!OculusManager::isConnected()) {
2516− if (_lookingInMirror->isChecked()) {
1850+ if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
25171851 if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
25181852 _myCamera.setMode(CAMERA_MODE_MIRROR);
25191853 _myCamera.setModeShiftRate(100.0f);
25201854 }
2521− } else if (_manualFirstPerson->isChecked()) {
1855+ } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) {
25221856 if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) {
25231857 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
25241858 _myCamera.setModeShiftRate(1.0f);
25251859 }
2526− } else if (_manualThirdPerson->isChecked()) {
1860+ } else {
25271861 if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) {
25281862 _myCamera.setMode(CAMERA_MODE_THIRD_PERSON);
25291863 _myCamera.setModeShiftRate(1.0f);
25301864 }
2531− } else {
2532− const float THIRD_PERSON_SHIFT_VELOCITY = 1000.0f;
2533− const float TIME_BEFORE_SHIFT_INTO_FIRST_PERSON = 0.75f;
2534− const float TIME_BEFORE_SHIFT_INTO_THIRD_PERSON = 0.1f;
2535−
2536− if ((_myAvatar.getElapsedTimeStopped() > TIME_BEFORE_SHIFT_INTO_FIRST_PERSON)
2537− && (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON)) {
2538− _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
2539− _myCamera.setModeShiftRate(1.0f);
2540− }
2541− if ((_myAvatar.getSpeed() > THIRD_PERSON_SHIFT_VELOCITY)
2542− && (_myAvatar.getElapsedTimeMoving() > TIME_BEFORE_SHIFT_INTO_THIRD_PERSON)
2543− && (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON)) {
2544− _myCamera.setMode(CAMERA_MODE_THIRD_PERSON);
2545− _myCamera.setModeShiftRate(1000.0f);
2546− }
25471865 }
25481866 }
25491867
25501868 // Update bandwidth dialog, if any
2551− if (_bandwidthDialog) {
2552− _bandwidthDialog->update();
1869+ BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog();
1870+ if (bandwidthDialog) {
1871+ bandwidthDialog->update();
25531872 }
2554− if (_voxelStatsDialog) {
2555− _voxelStatsDialog->update();
1873+
1874+ VoxelStatsDialog* voxelStatsDialog = Menu::getInstance()->getVoxelStatsDialog();
1875+ if (voxelStatsDialog) {
1876+ voxelStatsDialog->update();
25561877 }
25571878
25581879 // Update audio stats for procedural sounds
@@ -2561,10 +1882,6 @@ void Application::update(float deltaTime) { · 2 unmodified lines
25611882 _audio.setLastVelocity(_myAvatar.getVelocity());
25621883 _audio.eventuallyAnalyzePing();
25631884 #endif
2564−
2565− if (_renderParticleSystemOn->isChecked()) {
2566− updateParticleSystem(deltaTime);
2567− }
25681885 }
25691886
25701887 void Application::updateAvatar(float deltaTime) {
@@ -2575,7 +1892,7 @@ void Application::updateAvatar(float deltaTime) { · 4 unmodified lines
25751892 _yawFromTouch = 0.f;
25761893
25771894 // Update my avatar's state from gyros and/or webcam
2578− _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),
1895+ _myAvatar.updateFromGyrosAndOrWebcam(Menu::getInstance()->isOptionChecked(MenuOption::GyroLook),
25791896 _pitchFromTouch);
25801897
25811898 if (_serialHeadSensor.isActive()) {
@@ -2599,17 +1916,20 @@ void Application::updateAvatar(float deltaTime) { · 17 unmodified lines
25991916 _headMouseY = min(_headMouseY, _glWidget->height());
26001917
26011918 const float MIDPOINT_OF_SCREEN = 0.5;
2602−
2603− // Set lookAtPosition if an avatar is at the center of the screen
2604− glm::vec3 screenCenterRayOrigin, screenCenterRayDirection;
2605− _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
2606−
2607− glm::vec3 eyePosition;
26081919
2609− _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
2610− if (_isLookingAtOtherAvatar) {
2611− glm::vec3 myLookAtFromMouse(eyePosition);
2612− _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
1920+ // Only use gyro to set lookAt if mouse hasn't selected an avatar
1921+ if (!_isLookingAtOtherAvatar) {
1922+
1923+ // Set lookAtPosition if an avatar is at the center of the screen
1924+ glm::vec3 screenCenterRayOrigin, screenCenterRayDirection;
1925+ _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
1926+
1927+ glm::vec3 eyePosition;
1928+ _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
1929+ if (_isLookingAtOtherAvatar) {
1930+ glm::vec3 myLookAtFromMouse(eyePosition);
1931+ _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
1932+ }
26131933 }
26141934
26151935 }
@@ -2661,7 +1981,7 @@ void Application::updateAvatar(float deltaTime) { · 45 unmodified lines
26611981 // once in a while, send my voxel url
26621982 const float AVATAR_VOXEL_URL_SEND_INTERVAL = 1.0f; // seconds
26631983 if (shouldDo(AVATAR_VOXEL_URL_SEND_INTERVAL, deltaTime)) {
2664− sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
1984+ Avatar::sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
26651985 }
26661986 }
26671987 }
@@ -2871,7 +2191,7 @@ void Application::displaySide(Camera& whichCamera) { · 203 unmodified lines
28712191 // transform by eye offset
28722192
28732193 // flip x if in mirror mode (also requires reversing winding order for backface culling)
2874− if (_lookingInMirror->isChecked()) {
2194+ if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
28752195 glScalef(-1.0f, 1.0f, 1.0f);
28762196 glFrontFace(GL_CW);
28772197
@@ -2901,7 +2221,7 @@ void Application::displaySide(Camera& whichCamera) { · 23 unmodified lines
29012221 // prepare the glow effect
29022222 _glowEffect.prepare();
29032223
2904− if (_renderStarsOn->isChecked()) {
2224+ if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
29052225 if (!_stars.getFileLoaded()) {
29062226 _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0);
29072227 }
@@ -2909,7 +2229,7 @@ void Application::displaySide(Camera& whichCamera) { · 1 unmodified line
29092229
29102230 // compute starfield alpha based on distance from atmosphere
29112231 float alpha = 1.0f;
2912− if (_renderAtmosphereOn->isChecked()) {
2232+ if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
29132233 const EnvironmentData& closestData = _environment.getClosestData(whichCamera.getPosition());
29142234 float height = glm::distance(whichCamera.getPosition(), closestData.getAtmosphereCenter());
29152235 if (height < closestData.getAtmosphereInnerRadius()) {
@@ -2926,7 +2246,7 @@ void Application::displaySide(Camera& whichCamera) { · 10 unmodified lines
29262246 }
29272247
29282248 // draw the sky dome
2929− if (_renderAtmosphereOn->isChecked()) {
2249+ if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
29302250 _environment.renderAtmospheres(whichCamera);
29312251 }
29322252
@@ -2948,7 +2268,7 @@ void Application::displaySide(Camera& whichCamera) { · 15 unmodified lines
29482268 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);
29492269
29502270 //draw a grid ground plane....
2951− if (_renderGroundPlaneOn->isChecked()) {
2271+ if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) {
29522272 // draw grass plane with fog
29532273 glEnable(GL_FOG);
29542274 glEnable(GL_NORMALIZE);
@@ -2971,8 +2291,8 @@ void Application::displaySide(Camera& whichCamera) { · 16 unmodified lines
29712291 //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
29722292 }
29732293 // Draw voxels
2974− if (_renderVoxels->isChecked()) {
2975− _voxels.render(_renderVoxelTextures->isChecked());
2294+ if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2295+ _voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
29762296 }
29772297
29782298 // restore default, white specular
@@ -2984,7 +2304,7 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines
29842304 glPushMatrix();
29852305 glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
29862306 renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
2987− if (_addVoxelMode->isChecked()) {
2307+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {
29882308 // use a contrasting color so that we can see what we're doing
29892309 glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128);
29902310 } else {
@@ -3002,7 +2322,7 @@ void Application::displaySide(Camera& whichCamera) { · 11 unmodified lines
30022322
30032323 _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
30042324
3005− if (_renderAvatarsOn->isChecked()) {
2325+ if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) {
30062326 // Render avatars of other nodes
30072327 NodeList* nodeList = NodeList::getInstance();
30082328
@@ -3014,11 +2334,12 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines
30142334 if (!avatar->isInitialized()) {
30152335 avatar->init();
30162336 }
2337+ // Set lookAt to myCamera on client side if other avatars are looking at client
30172338 if (isLookingAtMyAvatar(avatar)) {
30182339 avatar->getHead().setLookAtPosition(_myCamera.getPosition());
30192340 }
3020− avatar->render(false, _renderAvatarBalls->isChecked());
3021− avatar->setDisplayingLookatVectors(_renderLookatOn->isChecked());
2341+ avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
2342+ avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
30222343 }
30232344
30242345 node->unlock();
@@ -3028,28 +2349,26 @@ void Application::displaySide(Camera& whichCamera) { · 3 unmodified lines
30282349 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
30292350 _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition());
30302351 }
3031− _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked());
3032−
3033− _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked());
2352+ _myAvatar.render(Menu::getInstance()->isOptionChecked(MenuOption::Mirror),
2353+ Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
2354+ _myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
30342355
3035− if (_renderLookatIndicatorOn->isChecked() && _isLookingAtOtherAvatar) {
2356+ if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _isLookingAtOtherAvatar) {
30362357 renderLookatIndicator(_lookatOtherPosition, whichCamera);
30372358 }
30382359 }
30392360
30402361 _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera);
30412362
3042− if (_renderParticleSystemOn->isChecked()) {
3043− if (_particleSystemInitialized) {
3044− _particleSystem.render();
3045− }
3046− }
3047−
30482363 // Render the world box
3049− if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { renderWorldBox(); }
2364+ if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
2365+ renderWorldBox();
2366+ }
30502367
30512368 // brad's frustum for debugging
3052− if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum);
2369+ if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
2370+ renderViewFrustum(_viewFrustum);
2371+ }
30532372
30542373 // render voxel fades if they exist
30552374 if (_voxelFades.size() > 0) {
@@ -3087,14 +2406,16 @@ void Application::displayOverlay() { · 31 unmodified lines
30872406
30882407 #ifndef _WIN32
30892408 _audio.render(_glWidget->width(), _glWidget->height());
3090− if (_oscilloscopeOn->isChecked()) {
2409+ if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {
30912410 _audioScope.render(20, _glWidget->height() - 200);
30922411 }
30932412 #endif
30942413
30952414 //noiseTest(_glWidget->width(), _glWidget->height());
30962415
3097− if (_showHeadMouse->isChecked() && !_lookingInMirror->isChecked() && USING_INVENSENSE_MPU9150) {
2416+ if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)
2417+ && !Menu::getInstance()->isOptionChecked(MenuOption::Mirror)
2418+ && USING_INVENSENSE_MPU9150) {
30982419 // Display small target box at center or head mouse target that can also be used to measure LOD
30992420 glColor3f(1.0, 1.0, 1.0);
31002421 glDisable(GL_LINE_SMOOTH);
@@ -3120,14 +2441,26 @@ void Application::displayOverlay() { · 19 unmodified lines
31202441 glLineWidth(1.0f);
31212442 glPointSize(1.0f);
31222443
3123− if (_renderStatsOn->isChecked()) { displayStats(); }
2444+ if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
2445+ displayStats();
2446+ }
31242447
31252448 // testing rendering coverage map
3126− if (_renderCoverageMapV2->isChecked()) { renderCoverageMapV2(); }
3127− if (_renderCoverageMap->isChecked()) { renderCoverageMap(); }
3128− if (_bandwidthDisplayOn->isChecked()) { _bandwidthMeter.render(_glWidget->width(), _glWidget->height()); }
2449+ if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMapV2)) {
2450+ renderCoverageMapV2();
2451+ }
2452+
2453+ if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMap)) {
2454+ renderCoverageMap();
2455+ }
2456+
2457+ if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
2458+ _bandwidthMeter.render(_glWidget->width(), _glWidget->height());
2459+ }
31292460
3130− if (_logOn->isChecked()) { LogDisplay::instance.render(_glWidget->width(), _glWidget->height()); }
2461+ if (Menu::getInstance()->isOptionChecked(MenuOption::Log)) {
2462+ LogDisplay::instance.render(_glWidget->width(), _glWidget->height());
2463+ }
31312464
31322465 // Show chat entry field
31332466 if (_chatEntryOn) {
@@ -3135,7 +2468,7 @@ void Application::displayOverlay() { · 1 unmodified line
31352468 }
31362469
31372470 // Show on-screen msec timer
3138− if (_renderFrameTimerOn->isChecked()) {
2471+ if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) {
31392472 char frameTimer[10];
31402473 uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
31412474 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
@@ -3143,7 +2476,6 @@ void Application::displayOverlay() { · 1 unmodified line
31432476 drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1);
31442477 }
31452478
3146−
31472479 // Stats at upper right of screen about who domain server is telling us about
31482480 glPointSize(1.0f);
31492481 char nodes[100];
@@ -3163,8 +2495,11 @@ void Application::displayOverlay() { · 13 unmodified lines
31632495
31642496 _palette.render(_glWidget->width(), _glWidget->height());
31652497
3166− if (_eyedropperMode->isChecked() && _voxelPaintColor->data().value<QColor>() != _swatch.getColor()) {
3167− QColor color = _voxelPaintColor->data().value<QColor>();
2498+ QAction* paintColorAction = NULL;
2499+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode)
2500+ && (paintColorAction = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor))->data().value<QColor>()
2501+ != _swatch.getColor()) {
2502+ QColor color = paintColorAction->data().value<QColor>();
31682503 TextRenderer textRenderer(SANS_FONT_FAMILY, 11, 50);
31692504 const char line1[] = "Assign this color to a swatch";
31702505 const char line2[] = "by choosing a key from 1 to 8.";
@@ -3221,7 +2556,7 @@ void Application::displayStats() { · 50 unmodified lines
32212556 _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f);
32222557 drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);
32232558
3224− if (_testPing->isChecked()) {
2559+ if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
32252560 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
32262561
32272562 NodeList* nodeList = NodeList::getInstance();
@@ -3515,7 +2850,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 287 unmodified lines
35152850 glLineWidth(1.0);
35162851 glBegin(GL_LINES);
35172852
3518− if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_VECTORS) {
2853+ if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
2854+ || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_VECTORS) {
35192855 // Calculate the origin direction vectors
35202856 glm::vec3 lookingAt = position + (direction * 0.2f);
35212857 glm::vec3 lookingAtUp = position + (up * 0.2f);
@@ -3537,8 +2873,9 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 15 unmodified lines
35372873 glVertex3f(lookingAtRight.x, lookingAtRight.y, lookingAtRight.z);
35382874 }
35392875
3540− if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES
3541− || _frustumDrawingMode == FRUSTUM_DRAW_MODE_NEAR_PLANE) {
2876+ if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
2877+ || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES
2878+ || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_NEAR_PLANE) {
35422879 // Drawing the bounds of the frustum
35432880 // viewFrustum.getNear plane - bottom edge
35442881 glColor3f(1,0,0);
@@ -3558,8 +2895,9 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 13 unmodified lines
35582895 glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z);
35592896 }
35602897
3561− if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES
3562− || _frustumDrawingMode == FRUSTUM_DRAW_MODE_FAR_PLANE) {
2898+ if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
2899+ || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES
2900+ || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) {
35632901 // viewFrustum.getFar plane - bottom edge
35642902 glColor3f(0,1,0); // GREEN!!!
35652903 glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);
@@ -3578,7 +2916,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 12 unmodified lines
35782916 glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z);
35792917 }
35802918
3581− if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES) {
2919+ if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
2920+ || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES) {
35822921 // RIGHT PLANE IS CYAN
35832922 // right plane - bottom edge - viewFrustum.getNear to distant
35842923 glColor3f(0,1,1);
@@ -3602,7 +2941,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 17 unmodified lines
36022941 glEnd();
36032942 glEnable(GL_LIGHTING);
36042943
3605− if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_KEYHOLE) {
2944+ if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
2945+ || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_KEYHOLE) {
36062946 // Draw the keyhole
36072947 float keyholeRadius = viewFrustum.getKeyholeRadius();
36082948 if (keyholeRadius > 0.0f) {
@@ -3672,15 +3012,18 @@ void Application::injectVoxelAddedSoundEffect() { · 63 unmodified lines
36723012 }
36733013
36743014 bool Application::maybeEditVoxelUnderCursor() {
3675− if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) {
3015+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)
3016+ || Menu::getInstance()->isOptionChecked(MenuOption::VoxelColorMode)) {
36763017 if (_mouseVoxel.s != 0) {
3677− PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ?
3678− PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL);
3018+ PACKET_TYPE message = Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel)
3019+ ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE
3020+ : PACKET_TYPE_SET_VOXEL;
36793021 _voxelEditSender.sendVoxelEditMessage(message, _mouseVoxel);
36803022
36813023 // create the voxel locally so it appears immediately
36823024 _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s,
3683− _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel->isChecked());
3025+ _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue,
3026+ Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel));
36843027
36853028 // Implement voxel fade effect
36863029 VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f);
@@ -3699,7 +3042,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 12 unmodified lines
36993042 _justEditedVoxel = true;
37003043
37013044 }
3702− } else if (_deleteVoxelMode->isChecked()) {
3045+ } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) {
37033046 deleteVoxelUnderCursor();
37043047 VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f);
37053048 const float VOXEL_BOUNDS_ADJUST = 0.01f;
@@ -3710,7 +3053,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 4 unmodified lines
37103053 fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger;
37113054 _voxelFades.push_back(fade);
37123055
3713− } else if (_eyedropperMode->isChecked()) {
3056+ } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode)) {
37143057 eyedropperVoxelUnderCursor();
37153058 } else {
37163059 return false;
@@ -3751,18 +3094,13 @@ void Application::eyedropperVoxelUnderCursor() { · 34 unmodified lines
37513094 selectedNode->getColor()[BLUE_INDEX]);
37523095
37533096 if (selectedColor.isValid()) {
3754− _voxelPaintColor->setData(selectedColor);
3755− _voxelPaintColor->setIcon(createSwatchIcon(selectedColor));
3097+ QAction* voxelPaintColorAction = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor);
3098+ voxelPaintColorAction->setData(selectedColor);
3099+ voxelPaintColorAction->setIcon(Swatch::createIcon(selectedColor));
37563100 }
37573101 }
37583102 }
37593103
3760−void Application::goHome() {
3761− qDebug("Going Home!\n");
3762− _myAvatar.setPosition(START_LOCATION);
3763−}
3764−
3765−
37663104 void Application::toggleFollowMode() {
37673105 glm::vec3 mouseRayOrigin, mouseRayDirection;
37683106 _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(),
@@ -3817,17 +3155,6 @@ void Application::updateCursor() { · 48 unmodified lines
38173155 Qt::BlankCursor : Qt::ArrowCursor);
38183156 }
38193157
3820−// when QActionGroup is set to non-exclusive, it doesn't return anything as checked;
3821−// hence, we must check ourselves
3822−QAction* Application::checkedVoxelModeAction() const {
3823− foreach (QAction* action, _voxelModeActions->actions()) {
3824− if (action->isChecked()) {
3825− return action;
3826− }
3827− }
3828− return 0;
3829−}
3830−
38313158 void Application::attachNewHeadToNode(Node* newNode) {
38323159 if (newNode->getLinkedData() == NULL) {
38333160 newNode->setLinkedData(new Avatar(newNode));
@@ -3958,190 +3285,3 @@ void* Application::networkReceive(void* args) { · 124 unmodified lines
39583285 }
39593286 return NULL;
39603287 }
3961−
3962−void Application::scanMenuBar(settingsAction modifySetting, QSettings* set) {
3963− if (!_window->menuBar()) {
3964− return;
3965− }
3966−
3967− QList<QMenu*> menus = _window->menuBar()->findChildren<QMenu *>();
3968−
3969− for (QList<QMenu *>::const_iterator it = menus.begin(); menus.end() != it; ++it) {
3970− scanMenu(*it, modifySetting, set);
3971− }
3972−}
3973−
3974−void Application::scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set) {
3975− QList<QAction*> actions = menu->actions();
3976−
3977− set->beginGroup(menu->title());
3978− for (QList<QAction *>::const_iterator it = actions.begin(); actions.end() != it; ++it) {
3979− if ((*it)->menu()) {
3980− scanMenu((*it)->menu(), modifySetting, set);
3981− }
3982− if ((*it)->isCheckable()) {
3983− modifySetting(set, *it);
3984− }
3985− }
3986− set->endGroup();
3987−}
3988−
3989−void Application::loadAction(QSettings* set, QAction* action) {
3990− if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) {
3991− action->trigger();
3992− }
3993−}
3994−
3995−void Application::saveAction(QSettings* set, QAction* action) {
3996− set->setValue(action->text(), action->isChecked());
3997−}
3998−
3999−void Application::loadSettings(QSettings* settings) {
4000− if (!settings) {
4001− settings = getSettings();
4002− }
4003−
4004− _gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f);
4005− _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0);
4006− _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
4007−
4008− settings->beginGroup("View Frustum Offset Camera");
4009− // in case settings is corrupt or missing loadSetting() will check for NaN
4010− _viewFrustumOffsetYaw = loadSetting(settings, "viewFrustumOffsetYaw" , 0.0f);
4011− _viewFrustumOffsetPitch = loadSetting(settings, "viewFrustumOffsetPitch" , 0.0f);
4012− _viewFrustumOffsetRoll = loadSetting(settings, "viewFrustumOffsetRoll" , 0.0f);
4013− _viewFrustumOffsetDistance = loadSetting(settings, "viewFrustumOffsetDistance", 0.0f);
4014− _viewFrustumOffsetUp = loadSetting(settings, "viewFrustumOffsetUp" , 0.0f);
4015− settings->endGroup();
4016−
4017− scanMenuBar(&Application::loadAction, settings);
4018− getAvatar()->loadData(settings);
4019− _swatch.loadData(settings);
4020−}
4021−
4022−
4023−void Application::saveSettings(QSettings* settings) {
4024− if (!settings) {
4025− settings = getSettings();
4026− }
4027−
4028− settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity);
4029− settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples);
4030− settings->setValue("fieldOfView", _fieldOfView);
4031− settings->beginGroup("View Frustum Offset Camera");
4032− settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffsetYaw);
4033− settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffsetPitch);
4034− settings->setValue("viewFrustumOffsetRoll", _viewFrustumOffsetRoll);
4035− settings->setValue("viewFrustumOffsetDistance", _viewFrustumOffsetDistance);
4036− settings->setValue("viewFrustumOffsetUp", _viewFrustumOffsetUp);
4037− settings->endGroup();
4038−
4039− scanMenuBar(&Application::saveAction, settings);
4040− getAvatar()->saveData(settings);
4041− _swatch.saveData(settings);
4042−
4043− // ask the NodeList to save its data
4044− NodeList::getInstance()->saveData(settings);
4045−}
4046−
4047−void Application::importSettings() {
4048− QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
4049− QString fileName = QFileDialog::getOpenFileName(_window,
4050− tr("Open .ini config file"),
4051− locationDir,
4052− tr("Text files (*.ini)"));
4053− if (fileName != "") {
4054− QSettings tmp(fileName, QSettings::IniFormat);
4055− loadSettings(&tmp);
4056− }
4057−}
4058−
4059−void Application::exportSettings() {
4060− QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
4061− QString fileName = QFileDialog::getSaveFileName(_window,
4062− tr("Save .ini config file"),
4063− locationDir,
4064− tr("Text files (*.ini)"));
4065− if (fileName != "") {
4066− QSettings tmp(fileName, QSettings::IniFormat);
4067− saveSettings(&tmp);
4068− tmp.sync();
4069− }
4070−}
4071−
4072−
4073−void Application::updateParticleSystem(float deltaTime) {
4074−
4075− if (!_particleSystemInitialized) {
4076−
4077− const int LIFESPAN_IN_SECONDS = 100000.0f;
4078− const float EMIT_RATE_IN_SECONDS = 10000.0;
4079− // create a stable test emitter and spit out a bunch of particles
4080− _coolDemoParticleEmitter = _particleSystem.addEmitter();
4081−
4082− if (_coolDemoParticleEmitter != -1) {
4083−
4084− _particleSystem.setShowingEmitter(_coolDemoParticleEmitter, true);
4085− glm::vec3 particleEmitterPosition = glm::vec3(5.0f, 1.0f, 5.0f);
4086−
4087− _particleSystem.setEmitterPosition (_coolDemoParticleEmitter, particleEmitterPosition);
4088− _particleSystem.setEmitterParticleLifespan(_coolDemoParticleEmitter, LIFESPAN_IN_SECONDS);
4089− _particleSystem.setEmitterThrust (_coolDemoParticleEmitter, 0.0f);
4090− _particleSystem.setEmitterRate (_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // to emit a pile o particles now
4091− }
4092−
4093− // signal that the particle system has been initialized
4094− _particleSystemInitialized = true;
4095− } else {
4096− // update the particle system
4097−
4098− static bool emitting = true;
4099− static float effectsTimer = 0.0f;
4100− effectsTimer += deltaTime;
4101−
4102− if (_coolDemoParticleEmitter != -1) {
4103−
4104− _particleSystem.setEmitterDirection(_coolDemoParticleEmitter, glm::vec3(0.0f, 1.0f, 0.0f));
4105−
4106− ParticleSystem::ParticleAttributes attributes;
4107−
4108− attributes.radius = 0.01f;
4109− attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f);
4110− attributes.gravity = 0.0f + 0.05f * sinf( effectsTimer * 0.52f );
4111− attributes.airFriction = 2.5 + 2.0f * sinf( effectsTimer * 0.32f );
4112− attributes.jitter = 0.05f + 0.05f * sinf( effectsTimer * 0.42f );
4113− attributes.emitterAttraction = 0.015f + 0.015f * cosf( effectsTimer * 0.6f );
4114− attributes.tornadoForce = 0.0f + 0.03f * sinf( effectsTimer * 0.7f );
4115− attributes.neighborAttraction = 0.1f + 0.1f * cosf( effectsTimer * 0.8f );
4116− attributes.neighborRepulsion = 0.2f + 0.2f * sinf( effectsTimer * 0.4f );
4117− attributes.bounce = 1.0f;
4118− attributes.usingCollisionSphere = true;
4119− attributes.collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f );
4120− attributes.collisionSphereRadius = 0.5f;
4121− attributes.usingCollisionPlane = true;
4122− attributes.collisionPlanePosition = glm::vec3( 5.0f, 0.0f, 5.0f );
4123− attributes.collisionPlaneNormal = glm::vec3( 0.0f, 1.0f, 0.0f );
4124−
4125− if (attributes.gravity < 0.0f) {
4126− attributes.gravity = 0.0f;
4127− }
4128−
4129− _particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes);
4130− }
4131−
4132− _particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f));
4133− _particleSystem.simulate(deltaTime);
4134−
4135− const float EMIT_RATE_IN_SECONDS = 0.0;
4136−
4137− if (_coolDemoParticleEmitter != -1) {
4138− if (emitting) {
4139− _particleSystem.setEmitterRate(_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // stop emitter
4140− emitting = false;
4141− }
4142− }
4143− }
4144−}
4145−
4146−
4147−

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t