From fe7a359545afb2e5cacc4f8ea0e579c23d5ae66d Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 11 Apr 2014 15:55:48 -0700 Subject: [PATCH 01/15] Added tools to adjust avatar LOD to LOD tools dialog. Closes #2624. --- interface/src/Menu.cpp | 51 +++++++++++++++----------- interface/src/Menu.h | 14 ++++++++ interface/src/ui/LodToolsDialog.cpp | 56 +++++++++++++++++++++++++++++ interface/src/ui/LodToolsDialog.h | 9 +++++ 4 files changed, 110 insertions(+), 20 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 0d3c66e3e7..4b5d24e376 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -79,6 +79,9 @@ Menu::Menu() : _lodToolsDialog(NULL), _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM), _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE), + _automaticAvatarLOD(true), + _avatarLODDecreaseFPS(DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS), + _avatarLODIncreaseFPS(ADJUST_LOD_UP_FPS), _avatarLODDistanceMultiplier(DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER), _boundaryLevelAdjust(0), _maxVoxelPacketsPerSecond(DEFAULT_MAX_VOXEL_PPS), @@ -273,7 +276,7 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, true); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, true); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Particles, 0, true); - + addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options"); @@ -286,7 +289,6 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures); addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion); - addActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontFadeOnVoxelServerChanges); addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DisableAutoAdjustLOD); @@ -415,6 +417,11 @@ void Menu::loadSettings(QSettings* settings) { _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM); _maxVoxelPacketsPerSecond = loadSetting(settings, "maxVoxelsPPS", DEFAULT_MAX_VOXEL_PPS); _voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_OCTREE_SIZE_SCALE); + _automaticAvatarLOD = settings->value("automaticAvatarLOD", true).toBool(); + _avatarLODDecreaseFPS = loadSetting(settings, "avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS); + _avatarLODIncreaseFPS = loadSetting(settings, "avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS); + _avatarLODDistanceMultiplier = loadSetting(settings, "avatarLODDistanceMultiplier", + DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER); _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0); settings->beginGroup("View Frustum Offset Camera"); @@ -454,6 +461,10 @@ void Menu::saveSettings(QSettings* settings) { settings->setValue("maxVoxels", _maxVoxels); settings->setValue("maxVoxelsPPS", _maxVoxelPacketsPerSecond); settings->setValue("voxelSizeScale", _voxelSizeScale); + settings->setValue("automaticAvatarLOD", _automaticAvatarLOD); + settings->setValue("avatarLODDecreaseFPS", _avatarLODDecreaseFPS); + settings->setValue("avatarLODIncreaseFPS", _avatarLODIncreaseFPS); + settings->setValue("avatarLODDistanceMultiplier", _avatarLODDistanceMultiplier); settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust); settings->beginGroup("View Frustum Offset Camera"); settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffset.yaw); @@ -1165,27 +1176,27 @@ void Menu::autoAdjustLOD(float currentFPS) { quint64 now = usecTimestampNow(); - const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f; const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000; - if (_fastFPSAverage.getAverage() < ADJUST_AVATAR_LOD_DOWN_FPS) { - if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) { - // attempt to lower the detail in proportion to the fps difference - float targetFps = (ADJUST_AVATAR_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f; - float averageFps = _fastFPSAverage.getAverage(); - const float MAXIMUM_MULTIPLIER_SCALE = 2.0f; - const float MAXIMUM_DISTANCE_MULTIPLIER = 15.0f; - _avatarLODDistanceMultiplier = qMin(MAXIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier * - (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps))); - _lastAvatarDetailDrop = now; + if (_automaticAvatarLOD) { + if (_fastFPSAverage.getAverage() < _avatarLODDecreaseFPS) { + if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) { + // attempt to lower the detail in proportion to the fps difference + float targetFps = (_avatarLODDecreaseFPS + _avatarLODIncreaseFPS) * 0.5f; + float averageFps = _fastFPSAverage.getAverage(); + const float MAXIMUM_MULTIPLIER_SCALE = 2.0f; + _avatarLODDistanceMultiplier = qMin(MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier * + (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : + qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps))); + _lastAvatarDetailDrop = now; + } + } else if (_fastFPSAverage.getAverage() > _avatarLODIncreaseFPS) { + // let the detail level creep slowly upwards + const float DISTANCE_DECREASE_RATE = 0.05f; + _avatarLODDistanceMultiplier = qMax(MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, + _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE); } - } else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) { - // let the detail level creep slowly upwards - const float DISTANCE_DECREASE_RATE = 0.05f; - const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f; - _avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER, - _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE); } - + bool changed = false; quint64 elapsed = now - _lastAdjust; diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e827e43014..7151aeeb4c 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -27,6 +27,7 @@ const float ADJUST_LOD_DOWN_FPS = 40.0; const float ADJUST_LOD_UP_FPS = 55.0; +const float DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f; const quint64 ADJUST_LOD_DOWN_DELAY = 1000 * 1000 * 5; const quint64 ADJUST_LOD_UP_DELAY = ADJUST_LOD_DOWN_DELAY * 2; @@ -37,6 +38,9 @@ const float ADJUST_LOD_UP_BY = 1.1f; const float ADJUST_LOD_MIN_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE * 0.25f; const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE; +const float MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 0.1f; +const float MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 15.0f; + enum FrustumDrawMode { FRUSTUM_DRAW_MODE_ALL, FRUSTUM_DRAW_MODE_VECTORS, @@ -95,6 +99,13 @@ public: void resetLODAdjust(); void setVoxelSizeScale(float sizeScale); float getVoxelSizeScale() const { return _voxelSizeScale; } + void setAutomaticAvatarLOD(bool automaticAvatarLOD) { _automaticAvatarLOD = automaticAvatarLOD; } + bool getAutomaticAvatarLOD() const { return _automaticAvatarLOD; } + void setAvatarLODDecreaseFPS(float avatarLODDecreaseFPS) { _avatarLODDecreaseFPS = avatarLODDecreaseFPS; } + float getAvatarLODDecreaseFPS() const { return _avatarLODDecreaseFPS; } + void setAvatarLODIncreaseFPS(float avatarLODIncreaseFPS) { _avatarLODIncreaseFPS = avatarLODIncreaseFPS; } + float getAvatarLODIncreaseFPS() const { return _avatarLODIncreaseFPS; } + void setAvatarLODDistanceMultiplier(float multiplier) { _avatarLODDistanceMultiplier = multiplier; } float getAvatarLODDistanceMultiplier() const { return _avatarLODDistanceMultiplier; } void setBoundaryLevelAdjust(int boundaryLevelAdjust); int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; } @@ -217,6 +228,9 @@ private: LodToolsDialog* _lodToolsDialog; int _maxVoxels; float _voxelSizeScale; + bool _automaticAvatarLOD; + float _avatarLODDecreaseFPS; + float _avatarLODIncreaseFPS; float _avatarLODDistanceMultiplier; int _boundaryLevelAdjust; QAction* _useVoxelShader; diff --git a/interface/src/ui/LodToolsDialog.cpp b/interface/src/ui/LodToolsDialog.cpp index 35d5eada41..92456956e3 100644 --- a/interface/src/ui/LodToolsDialog.cpp +++ b/interface/src/ui/LodToolsDialog.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -75,6 +76,27 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : const int FEEDBACK_WIDTH = 350; _feedback->setFixedWidth(FEEDBACK_WIDTH); form->addRow("You can see... ", _feedback); + + form->addRow("Automatic Avatar LOD Adjustment:", _automaticAvatarLOD = new QCheckBox()); + _automaticAvatarLOD->setChecked(Menu::getInstance()->getAutomaticAvatarLOD()); + connect(_automaticAvatarLOD, SIGNAL(toggled(bool)), SLOT(updateAvatarLODControls())); + + form->addRow("Decrease Avatar LOD Below FPS:", _avatarLODDecreaseFPS = new QDoubleSpinBox()); + _avatarLODDecreaseFPS->setValue(Menu::getInstance()->getAvatarLODDecreaseFPS()); + _avatarLODDecreaseFPS->setDecimals(0); + connect(_avatarLODDecreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues())); + + form->addRow("Increase Avatar LOD Above FPS:", _avatarLODIncreaseFPS = new QDoubleSpinBox()); + _avatarLODIncreaseFPS->setValue(Menu::getInstance()->getAvatarLODIncreaseFPS()); + _avatarLODIncreaseFPS->setDecimals(0); + connect(_avatarLODIncreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues())); + + form->addRow("Avatar LOD:", _avatarLOD = new QDoubleSpinBox()); + _avatarLOD->setDecimals(3); + _avatarLOD->setRange(1.0 / MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, 1.0 / MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER); + _avatarLOD->setSingleStep(0.001); + _avatarLOD->setValue(1.0 / Menu::getInstance()->getAvatarLODDistanceMultiplier()); + connect(_avatarLOD, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues())); // Add a button to reset QPushButton* resetButton = new QPushButton("Reset"); @@ -82,6 +104,8 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : connect(resetButton,SIGNAL(clicked(bool)),this,SLOT(resetClicked(bool))); this->QDialog::setLayout(form); + + updateAvatarLODControls(); } LodToolsDialog::~LodToolsDialog() { @@ -96,6 +120,35 @@ void LodToolsDialog::reloadSliders() { _feedback->setText(Menu::getInstance()->getLODFeedbackText()); } +void LodToolsDialog::updateAvatarLODControls() { + QFormLayout* form = static_cast(layout()); + + Menu::getInstance()->setAutomaticAvatarLOD(_automaticAvatarLOD->isChecked()); + + _avatarLODDecreaseFPS->setVisible(_automaticAvatarLOD->isChecked()); + form->labelForField(_avatarLODDecreaseFPS)->setVisible(_automaticAvatarLOD->isChecked()); + + _avatarLODIncreaseFPS->setVisible(_automaticAvatarLOD->isChecked()); + form->labelForField(_avatarLODIncreaseFPS)->setVisible(_automaticAvatarLOD->isChecked()); + + _avatarLOD->setVisible(!_automaticAvatarLOD->isChecked()); + form->labelForField(_avatarLOD)->setVisible(!_automaticAvatarLOD->isChecked()); + + if (!_automaticAvatarLOD->isChecked()) { + _avatarLOD->setValue(1.0 / Menu::getInstance()->getAvatarLODDistanceMultiplier()); + } +} + +void LodToolsDialog::updateAvatarLODValues() { + if (_automaticAvatarLOD->isChecked()) { + Menu::getInstance()->setAvatarLODDecreaseFPS(_avatarLODDecreaseFPS->value()); + Menu::getInstance()->setAvatarLODIncreaseFPS(_avatarLODIncreaseFPS->value()); + + } else { + Menu::getInstance()->setAvatarLODDistanceMultiplier(1.0 / _avatarLOD->value()); + } +} + void LodToolsDialog::sizeScaleValueChanged(int value) { float realValue = value * TREE_SCALE; Menu::getInstance()->setVoxelSizeScale(realValue); @@ -113,6 +166,9 @@ void LodToolsDialog::resetClicked(bool checked) { //sizeScaleValueChanged(sliderValue); _lodSize->setValue(sliderValue); _boundaryLevelAdjust->setValue(0); + _automaticAvatarLOD->setChecked(true); + _avatarLODDecreaseFPS->setValue(DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS); + _avatarLODIncreaseFPS->setValue(ADJUST_LOD_UP_FPS); } void LodToolsDialog::reject() { diff --git a/interface/src/ui/LodToolsDialog.h b/interface/src/ui/LodToolsDialog.h index a3223806aa..5b34a5efd0 100644 --- a/interface/src/ui/LodToolsDialog.h +++ b/interface/src/ui/LodToolsDialog.h @@ -16,6 +16,9 @@ #include #include +class QCheckBox; +class QDoubleSpinBox; + class LodToolsDialog : public QDialog { Q_OBJECT public: @@ -32,6 +35,8 @@ public slots: void boundaryLevelValueChanged(int value); void resetClicked(bool checked); void reloadSliders(); + void updateAvatarLODControls(); + void updateAvatarLODValues(); protected: @@ -41,6 +46,10 @@ protected: private: QSlider* _lodSize; QSlider* _boundaryLevelAdjust; + QCheckBox* _automaticAvatarLOD; + QDoubleSpinBox* _avatarLODDecreaseFPS; + QDoubleSpinBox* _avatarLODIncreaseFPS; + QDoubleSpinBox* _avatarLOD; QLabel* _feedback; }; From 4265617c3edf787cf97164681310b403d4cc6b30 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 11 Apr 2014 16:02:46 -0700 Subject: [PATCH 02/15] Add missing include. --- interface/src/ui/LodToolsDialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/ui/LodToolsDialog.cpp b/interface/src/ui/LodToolsDialog.cpp index 92456956e3..3612e06e34 100644 --- a/interface/src/ui/LodToolsDialog.cpp +++ b/interface/src/ui/LodToolsDialog.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include From 0ca68e4cb4c2fad9f840d203cae32d61d4c2bf7e Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 11 Apr 2014 17:53:02 -0700 Subject: [PATCH 03/15] Adjust the size when we toggle the avatar LOD options. --- interface/src/ui/LodToolsDialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interface/src/ui/LodToolsDialog.cpp b/interface/src/ui/LodToolsDialog.cpp index 3612e06e34..6df5121104 100644 --- a/interface/src/ui/LodToolsDialog.cpp +++ b/interface/src/ui/LodToolsDialog.cpp @@ -138,6 +138,10 @@ void LodToolsDialog::updateAvatarLODControls() { if (!_automaticAvatarLOD->isChecked()) { _avatarLOD->setValue(1.0 / Menu::getInstance()->getAvatarLODDistanceMultiplier()); } + + if (isVisible()) { + adjustSize(); + } } void LodToolsDialog::updateAvatarLODValues() { From 873620e60174984eb3c64ebe3bbb78923ee1491a Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 14 Apr 2014 12:27:15 -0700 Subject: [PATCH 04/15] Make sure we set the texture data even if the texture URL is invalid. --- interface/src/renderer/TextureCache.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/renderer/TextureCache.cpp b/interface/src/renderer/TextureCache.cpp index 17146dc2bb..3f523cf4bb 100644 --- a/interface/src/renderer/TextureCache.cpp +++ b/interface/src/renderer/TextureCache.cpp @@ -244,7 +244,6 @@ NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) : if (!url.isValid()) { _loaded = true; - return; } // default to white/blue From 1a3e6595c50507551864cc28545a225fffb094f2 Mon Sep 17 00:00:00 2001 From: Stojce Slavkovski Date: Tue, 15 Apr 2014 19:36:02 +0200 Subject: [PATCH 05/15] Allow users to set the destination of Snapshots --- interface/resources/styles/preferences.qss | 3 +- interface/src/Menu.cpp | 7 +- interface/src/Menu.h | 11 ++ interface/src/ui/PreferencesDialog.cpp | 18 +++ interface/src/ui/PreferencesDialog.h | 1 + interface/src/ui/Snapshot.cpp | 9 +- interface/ui/preferencesDialog.ui | 143 ++++++++++++++++++++- libraries/shared/src/FileUtils.cpp | 3 +- 8 files changed, 186 insertions(+), 9 deletions(-) diff --git a/interface/resources/styles/preferences.qss b/interface/resources/styles/preferences.qss index 643fd13a77..e678acd0c9 100644 --- a/interface/resources/styles/preferences.qss +++ b/interface/resources/styles/preferences.qss @@ -11,7 +11,8 @@ QLabel#advancedTuningLabel { } QPushButton#buttonBrowseHead, -QPushButton#buttonBrowseBody { +QPushButton#buttonBrowseBody, +QPushButton#buttonBrowseLocation { background-image: url(styles/search.svg); background-repeat: no-repeat; background-position: center center; diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 272dc39eb3..c9a1087618 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -87,7 +86,8 @@ Menu::Menu() : _fpsAverage(FIVE_SECONDS_OF_FRAMES), _fastFPSAverage(ONE_SECOND_OF_FRAMES), _loginAction(NULL), - _preferencesDialog(NULL) + _preferencesDialog(NULL), + _snapshotsLocation() { Application *appInstance = Application::getInstance(); @@ -416,6 +416,8 @@ void Menu::loadSettings(QSettings* settings) { _maxVoxelPacketsPerSecond = loadSetting(settings, "maxVoxelsPPS", DEFAULT_MAX_VOXEL_PPS); _voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_OCTREE_SIZE_SCALE); _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0); + _snapshotsLocation = settings->value("snapshotsLocation", + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString(); settings->beginGroup("View Frustum Offset Camera"); // in case settings is corrupt or missing loadSetting() will check for NaN @@ -455,6 +457,7 @@ void Menu::saveSettings(QSettings* settings) { settings->setValue("maxVoxelsPPS", _maxVoxelPacketsPerSecond); settings->setValue("voxelSizeScale", _voxelSizeScale); settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust); + settings->setValue("snapshotsLocation", _snapshotsLocation); settings->beginGroup("View Frustum Offset Camera"); settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffset.yaw); settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffset.pitch); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e827e43014..2c39ea3b99 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -12,10 +12,12 @@ #ifndef hifi_Menu_h #define hifi_Menu_h +#include #include #include #include #include +#include #include #include @@ -79,6 +81,14 @@ public: void setFieldOfView(float fieldOfView) { _fieldOfView = fieldOfView; } float getFaceshiftEyeDeflection() const { return _faceshiftEyeDeflection; } void setFaceshiftEyeDeflection(float faceshiftEyeDeflection) { _faceshiftEyeDeflection = faceshiftEyeDeflection; } + QString getSnapshotsLocation() const { + if (_snapshotsLocation.isNull() || _snapshotsLocation.isEmpty() || QDir(_snapshotsLocation).exists() == false) { + return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + } + return _snapshotsLocation; + } + void setSnapshotsLocation(QString snapshotsLocation) { _snapshotsLocation = snapshotsLocation; } + BandwidthDialog* getBandwidthDialog() const { return _bandwidthDialog; } FrustumDrawMode getFrustumDrawMode() const { return _frustumDrawMode; } ViewFrustumOffset getViewFrustumOffset() const { return _viewFrustumOffset; } @@ -229,6 +239,7 @@ private: QAction* _loginAction; QPointer _preferencesDialog; QAction* _chatAction; + QString _snapshotsLocation; }; namespace MenuOption { diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index a14e80e62f..36508e94d1 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -28,6 +28,7 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags flags) : F connect(ui.buttonBrowseHead, &QPushButton::clicked, this, &PreferencesDialog::openHeadModelBrowser); connect(ui.buttonBrowseBody, &QPushButton::clicked, this, &PreferencesDialog::openBodyModelBrowser); + connect(ui.buttonBrowseLocation, &QPushButton::clicked, this, &PreferencesDialog::openSnapshotLocationBrowser); } void PreferencesDialog::accept() { @@ -59,6 +60,17 @@ void PreferencesDialog::openBodyModelBrowser() { modelBrowser.browse(); } +void PreferencesDialog::openSnapshotLocationBrowser() { + setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); + QString dir = QFileDialog::getExistingDirectory(this, tr("Snapshots Location"), + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + if (!dir.isNull() && !dir.isEmpty()) { + ui.snapshotLocationEdit->setText(dir); + } + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); +} + void PreferencesDialog::resizeEvent(QResizeEvent *resizeEvent) { // keep buttons panel at the bottom @@ -94,6 +106,8 @@ void PreferencesDialog::loadPreferences() { _skeletonURLString = myAvatar->getSkeletonModel().getURL().toString(); ui.skeletonURLEdit->setText(_skeletonURLString); + ui.snapshotLocationEdit->setText(menuInstance->getSnapshotsLocation()); + ui.pupilDilationSlider->setValue(myAvatar->getHead()->getPupilDilation() * ui.pupilDilationSlider->maximum()); @@ -143,6 +157,10 @@ void PreferencesDialog::savePreferences() { Application::getInstance()->bumpSettings(); } + if (!ui.snapshotLocationEdit->text().isEmpty() && QDir(ui.snapshotLocationEdit->text()).exists()) { + Menu::getInstance()->setSnapshotsLocation(ui.snapshotLocationEdit->text()); + } + myAvatar->getHead()->setPupilDilation(ui.pupilDilationSlider->value() / (float)ui.pupilDilationSlider->maximum()); myAvatar->setLeanScale(ui.leanScaleSpin->value()); myAvatar->setClampedTargetScale(ui.avatarScaleSpin->value()); diff --git a/interface/src/ui/PreferencesDialog.h b/interface/src/ui/PreferencesDialog.h index c9514e584a..c52986cc5c 100644 --- a/interface/src/ui/PreferencesDialog.h +++ b/interface/src/ui/PreferencesDialog.h @@ -41,6 +41,7 @@ private slots: void accept(); void setHeadUrl(QString modelUrl); void setSkeletonUrl(QString modelUrl); + void openSnapshotLocationBrowser(); }; diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 77b19373f4..29c2d3c90f 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -16,6 +16,7 @@ #include #include "Snapshot.h" +#include "Menu.h" // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg // %1 <= username, %2 <= date and time, %3 <= current location @@ -90,8 +91,12 @@ void Snapshot::saveSnapshot(QGLWidget* widget, Avatar* avatar) { username.replace(QRegExp("[^A-Za-z0-9_]"), "-"); QDateTime now = QDateTime::currentDateTime(); - - QString fileName = FileUtils::standardPath(SNAPSHOTS_DIRECTORY); + QString fileName = Menu::getInstance()->getSnapshotsLocation(); + + if (!fileName.endsWith(QDir::separator())) { + fileName.append(QDir::separator()); + } + fileName.append(QString(FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT), formattedLocation))); shot.save(fileName, 0, 100); } diff --git a/interface/ui/preferencesDialog.ui b/interface/ui/preferencesDialog.ui index a151a499c6..3ad824a35e 100644 --- a/interface/ui/preferencesDialog.ui +++ b/interface/ui/preferencesDialog.ui @@ -156,7 +156,7 @@ color: #0e7077 0 0 615 - 833 + 936 @@ -300,7 +300,7 @@ color: #0e7077 0 - faceURLEdit + snapshotLocationEdit @@ -476,6 +476,145 @@ color: #0e7077 + + + + + 0 + 0 + + + + + 0 + 40 + + + + + Arial + 20 + 50 + false + + + + color: #0e7077 + + + Snapshots + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + Arial + 16 + + + + color: #0e7077 + + + Snapshots location + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + 0 + + + snapshotLocationEdit + + + + + + + + + + 0 + 0 + + + + + Arial + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + + 30 + 30 + + + + + + + + + + + 30 + 30 + + + + + + diff --git a/libraries/shared/src/FileUtils.cpp b/libraries/shared/src/FileUtils.cpp index b890717a66..fe79f6c527 100644 --- a/libraries/shared/src/FileUtils.cpp +++ b/libraries/shared/src/FileUtils.cpp @@ -61,8 +61,7 @@ void FileUtils::locateFile(QString filePath) { QString FileUtils::standardPath(QString subfolder) { // standard path // Mac: ~/Library/Application Support/Interface - QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); - path.append("/Interface"); + QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation); if (!subfolder.startsWith("/")) { subfolder.prepend("/"); From 05023a2585fbcab011065e6db8474d63a6c8d1b0 Mon Sep 17 00:00:00 2001 From: Stojce Slavkovski Date: Tue, 15 Apr 2014 23:29:28 +0200 Subject: [PATCH 06/15] Snapshot preferences title --- interface/ui/preferencesDialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/ui/preferencesDialog.ui b/interface/ui/preferencesDialog.ui index 3ad824a35e..278e3c5dab 100644 --- a/interface/ui/preferencesDialog.ui +++ b/interface/ui/preferencesDialog.ui @@ -533,7 +533,7 @@ color: #0e7077 color: #0e7077 - Snapshots location + Place my Snapshots here: Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft From c67e42be5e0087e9d142b2c19fc5bcdb56bdd403 Mon Sep 17 00:00:00 2001 From: Stojce Slavkovski Date: Wed, 16 Apr 2014 07:46:15 +0200 Subject: [PATCH 07/15] Moved function into .cpp --- interface/src/Menu.cpp | 7 +++++++ interface/src/Menu.h | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index c9a1087618..e4de93c9bf 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1505,3 +1505,10 @@ void Menu::removeMenuItem(const QString& menu, const QString& menuitem) { QMenuBar::repaint(); }; +QString Menu::getSnapshotsLocation() const { + if (_snapshotsLocation.isNull() || _snapshotsLocation.isEmpty() || QDir(_snapshotsLocation).exists() == false) { + return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + } + return _snapshotsLocation; +} + diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 2c39ea3b99..45291802cb 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -81,12 +81,7 @@ public: void setFieldOfView(float fieldOfView) { _fieldOfView = fieldOfView; } float getFaceshiftEyeDeflection() const { return _faceshiftEyeDeflection; } void setFaceshiftEyeDeflection(float faceshiftEyeDeflection) { _faceshiftEyeDeflection = faceshiftEyeDeflection; } - QString getSnapshotsLocation() const { - if (_snapshotsLocation.isNull() || _snapshotsLocation.isEmpty() || QDir(_snapshotsLocation).exists() == false) { - return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - } - return _snapshotsLocation; - } + QString getSnapshotsLocation() const; void setSnapshotsLocation(QString snapshotsLocation) { _snapshotsLocation = snapshotsLocation; } BandwidthDialog* getBandwidthDialog() const { return _bandwidthDialog; } From 97e45e8fe5b675b4425b0b1d0f4ad97e71b7fa7d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 10:56:27 -0700 Subject: [PATCH 08/15] re-instate connect behavior in DS so killed nodes re-connect, amend #2675 --- domain-server/src/DomainServer.cpp | 35 +++++--------------- domain-server/src/DomainServer.h | 5 ++- libraries/networking/src/LimitedNodeList.cpp | 2 +- libraries/networking/src/LimitedNodeList.h | 2 +- libraries/networking/src/Node.cpp | 3 +- libraries/networking/src/Node.h | 2 +- libraries/networking/src/NodeList.cpp | 10 ++++-- libraries/networking/src/PacketHeaders.h | 5 +-- 8 files changed, 25 insertions(+), 39 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 1bda2aa75c..6634dde5b7 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -311,8 +311,7 @@ const NodeSet STATICALLY_ASSIGNED_NODES = NodeSet() << NodeType::AudioMixer << NodeType::MetavoxelServer; -void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr, - const QJsonObject& authJsonObject) { +void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr) { NodeType_t nodeType; HifiSockAddr publicSockAddr, localSockAddr; @@ -336,7 +335,8 @@ void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packe // create a new session UUID for this node QUuid nodeUUID = QUuid::createUuid(); - SharedNodePointer newNode = LimitedNodeList::getInstance()->addOrUpdateNode(nodeUUID, nodeType, publicSockAddr, localSockAddr); + SharedNodePointer newNode = LimitedNodeList::getInstance()->addOrUpdateNode(nodeUUID, nodeType, + publicSockAddr, localSockAddr); // when the newNode is created the linked data is also created // if this was a static assignment set the UUID, set the sendingSockAddr @@ -345,12 +345,6 @@ void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packe nodeData->setStaticAssignmentUUID(assignmentUUID); nodeData->setSendingSockAddr(senderSockAddr); - if (!authJsonObject.isEmpty()) { - // pull the connection secret from the authJsonObject and set it as the connection secret for this node - QUuid connectionSecret(authJsonObject["data"].toObject()["connection_secret"].toString()); - newNode->setConnectionSecret(connectionSecret); - } - // reply back to the user with a PacketTypeDomainList sendDomainListToNode(newNode, senderSockAddr, nodeInterestListFromPacket(packet, numPreInterestBytes)); } @@ -361,18 +355,6 @@ int DomainServer::parseNodeDataFromByteArray(NodeType_t& nodeType, HifiSockAddr& QDataStream packetStream(packet); packetStream.skipRawData(numBytesForPacketHeader(packet)); - if (packetTypeForPacket(packet) == PacketTypeDomainConnectRequest) { - // we need to skip a quint8 that indicates if there is a registration token - // and potentially the registration token itself - quint8 hasRegistrationToken; - packetStream >> hasRegistrationToken; - - if (hasRegistrationToken) { - QByteArray registrationToken; - packetStream >> registrationToken; - } - } - packetStream >> nodeType; packetStream >> publicSockAddr >> localSockAddr; @@ -648,7 +630,11 @@ void DomainServer::processDatagram(const QByteArray& receivedPacket, const HifiS if (nodeList->packetVersionAndHashMatch(receivedPacket)) { PacketType requestType = packetTypeForPacket(receivedPacket); - if (requestType == PacketTypeDomainListRequest) { + if (requestType == PacketTypeDomainConnectRequest) { + // add this node to our NodeList + // and send back session UUID right away + addNodeToNodeListAndConfirmConnection(receivedPacket, senderSockAddr); + } else if (requestType == PacketTypeDomainListRequest) { QUuid nodeUUID = uuidFromPacketHeader(receivedPacket); if (!nodeUUID.isNull() && nodeList->nodeWithUUID(nodeUUID)) { @@ -665,12 +651,7 @@ void DomainServer::processDatagram(const QByteArray& receivedPacket, const HifiS checkInNode->setLastHeardMicrostamp(timeNow); sendDomainListToNode(checkInNode, senderSockAddr, nodeInterestListFromPacket(receivedPacket, numNodeInfoBytes)); - } else { - // new node - add this node to our NodeList - // and send back session UUID right away - addNodeToNodeListAndConfirmConnection(receivedPacket, senderSockAddr); } - } else if (requestType == PacketTypeNodeJsonStats) { SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket); if (matchingNode) { diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 1400fadee3..0153fac49d 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include "DTLSServerSession.h" @@ -57,8 +57,7 @@ private: void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr); - void addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr, - const QJsonObject& authJsonObject = QJsonObject()); + void addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr); int parseNodeDataFromByteArray(NodeType_t& nodeType, HifiSockAddr& publicSockAddr, HifiSockAddr& localSockAddr, const QByteArray& packet, const HifiSockAddr& senderSockAddr); NodeSet nodeInterestListFromPacket(const QByteArray& packet, int numPreceedingBytes); diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index b0b048dde4..60fbe9b3a6 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -331,7 +331,7 @@ void LimitedNodeList::processKillNode(const QByteArray& dataByteArray) { killNodeWithUUID(nodeUUID); } -SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, char nodeType, +SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) { _nodeHashMutex.lock(); diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index f941a8aa5d..ea9cb42436 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -78,7 +78,7 @@ public: SharedNodePointer nodeWithUUID(const QUuid& nodeUUID, bool blockingLock = true); SharedNodePointer sendingNodeForPacket(const QByteArray& packet); - SharedNodePointer addOrUpdateNode(const QUuid& uuid, char nodeType, + SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket); SharedNodePointer updateSocketsForNode(const QUuid& uuid, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket); diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index 9e6ea0dfec..15ee443e1f 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -42,7 +42,7 @@ const QString& NodeType::getNodeTypeName(NodeType_t nodeType) { return matchedTypeName != TypeNameHash.end() ? matchedTypeName.value() : UNKNOWN_NodeType_t_NAME; } -Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) : +Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) : _type(type), _uuid(uuid), _wakeTimestamp(QDateTime::currentMSecsSinceEpoch()), @@ -58,6 +58,7 @@ Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const _clockSkewUsec(0), _mutex() { + } Node::~Node() { diff --git a/libraries/networking/src/Node.h b/libraries/networking/src/Node.h index 3b3237cf6e..0f63d01525 100644 --- a/libraries/networking/src/Node.h +++ b/libraries/networking/src/Node.h @@ -45,7 +45,7 @@ namespace NodeType { class Node : public QObject { Q_OBJECT public: - Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket); + Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket); ~Node(); bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 93377c7763..006d5e0509 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -376,10 +376,14 @@ void NodeList::sendDomainServerCheckIn() { } } - // construct the DS check in packet - QUuid packetUUID = (!_sessionUUID.isNull() ? _sessionUUID : _domainHandler.getAssignmentUUID()); + PacketType domainPacketType = _sessionUUID.isNull() + ? PacketTypeDomainConnectRequest : PacketTypeDomainListRequest; - QByteArray domainServerPacket = byteArrayWithPopulatedHeader(PacketTypeDomainListRequest, packetUUID); + // construct the DS check in packet + QUuid packetUUID = (domainPacketType == PacketTypeDomainListRequest + ? _sessionUUID : _domainHandler.getAssignmentUUID()); + + QByteArray domainServerPacket = byteArrayWithPopulatedHeader(domainPacketType, packetUUID); QDataStream packetStream(&domainServerPacket, QIODevice::Append); // pack our data to send to the domain-server diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/PacketHeaders.h index 3e2ff3d8b0..0f52f90962 100644 --- a/libraries/networking/src/PacketHeaders.h +++ b/libraries/networking/src/PacketHeaders.h @@ -58,7 +58,7 @@ enum PacketType { PacketTypeMetavoxelData, PacketTypeAvatarIdentity, PacketTypeAvatarBillboard, - PacketTypeDomainConnectRequest, // reusable + PacketTypeDomainConnectRequest, PacketTypeDomainServerRequireDTLS, PacketTypeNodeJsonStats, }; @@ -66,7 +66,8 @@ enum PacketType { typedef char PacketVersion; const QSet NON_VERIFIED_PACKETS = QSet() - << PacketTypeDomainServerRequireDTLS << PacketTypeDomainList << PacketTypeDomainListRequest + << PacketTypeDomainServerRequireDTLS << PacketTypeDomainConnectRequest + << PacketTypeDomainList << PacketTypeDomainListRequest << PacketTypeCreateAssignment << PacketTypeRequestAssignment << PacketTypeStunResponse << PacketTypeNodeJsonStats; From 57567becc8776048f0765459c26d55a5aaf6a287 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 11:02:08 -0700 Subject: [PATCH 09/15] fix unexpected null parameter to disconnect, closes, #2663 --- libraries/networking/src/NodeList.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 006d5e0509..fbf2655269 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -209,8 +209,10 @@ void NodeList::reset() { // clear the domain connection information _domainHandler.clearConnectionInfo(); - // also disconnect from the DTLS socket readyRead() so it can handle handshaking - disconnect(_dtlsSocket, 0, this, 0); + // if we setup the DTLS socket, also disconnect from the DTLS socket readyRead() so it can handle handshaking + if (_dtlsSocket) { + disconnect(_dtlsSocket, 0, this, 0); + } } void NodeList::addNodeTypeToInterestSet(NodeType_t nodeTypeToAdd) { From 55d540a0eb6947192f51607fcf313ce4f387091b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 11:24:26 -0700 Subject: [PATCH 10/15] fix a typo in DomainServer.cpp --- domain-server/src/DomainServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 6634dde5b7..1268ae739e 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -71,7 +71,7 @@ DomainServer::DomainServer(int argc, char* argv[]) : int socketHandle = LimitedNodeList::getInstance()->getDTLSSocket().socketDescriptor(); #if defined(IP_DONTFRAG) - int optValue = 1;yea + int optValue = 1; setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, (const void*) optValue, sizeof(optValue)); #elif defined(IP_MTU_DISCOVER) int optValue = 1; From a25ef5824707d9de5707ea11153d19cb36e15006 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 11:25:35 -0700 Subject: [PATCH 11/15] move DTLS socket changes to LimitedNodeList --- domain-server/src/DomainServer.cpp | 12 ------------ libraries/networking/src/LimitedNodeList.cpp | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 1268ae739e..969b83f64f 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -66,18 +66,6 @@ DomainServer::DomainServer(int argc, char* argv[]) : LimitedNodeList* nodeList = LimitedNodeList::getInstance(); -#if defined(IP_DONTFRAG) || defined(IP_MTU_DISCOVER) - qDebug() << "Making required DTLS changes to NodeList DTLS socket."; - - int socketHandle = LimitedNodeList::getInstance()->getDTLSSocket().socketDescriptor(); -#if defined(IP_DONTFRAG) - int optValue = 1; - setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, (const void*) optValue, sizeof(optValue)); -#elif defined(IP_MTU_DISCOVER) - int optValue = 1; - setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, (const void*) optValue, sizeof(optValue)); -#endif -#endif // connect our socket to read datagrams received on the DTLS socket connect(&nodeList->getDTLSSocket(), &QUdpSocket::readyRead, this, &DomainServer::readAvailableDTLSDatagrams); } diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 60fbe9b3a6..d85c01a9eb 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -105,6 +105,20 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() { _dtlsSocket = new QUdpSocket(this); _dtlsSocket->bind(QHostAddress::AnyIPv4, 0, QAbstractSocket::DontShareAddress); + +#if defined(IP_DONTFRAG) || defined(IP_MTU_DISCOVER) + qDebug() << "Making required DTLS changes to LimitedNodeList DTLS socket."; + + int socketHandle = _dtlsSocket->socketDescriptor(); +#if defined(IP_DONTFRAG) + int optValue = 1; + setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, (const void*) optValue, sizeof(optValue)); +#elif defined(IP_MTU_DISCOVER) + int optValue = 1; + setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, (const void*) optValue, sizeof(optValue)); +#endif +#endif + qDebug() << "NodeList DTLS socket is listening on" << _dtlsSocket->localPort(); } From 06a976041b507c8aa1c215e69176029aa89e9532 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 11:27:30 -0700 Subject: [PATCH 12/15] take pointer of optValue and not actual optValue --- libraries/networking/src/LimitedNodeList.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index d85c01a9eb..223ab3c306 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -112,10 +112,10 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() { int socketHandle = _dtlsSocket->socketDescriptor(); #if defined(IP_DONTFRAG) int optValue = 1; - setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, (const void*) optValue, sizeof(optValue)); + setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, reinterpret_cast(&optValue), sizeof(optValue)); #elif defined(IP_MTU_DISCOVER) int optValue = 1; - setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, (const void*) optValue, sizeof(optValue)); + setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, reinterpret_cast(&optValue), sizeof(optValue)); #endif #endif From afcb542bbec5e3a0e879b9bcf167c7625b8ae910 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 11:28:34 -0700 Subject: [PATCH 13/15] fix a debug line in LimitedNodeList --- libraries/networking/src/LimitedNodeList.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 223ab3c306..9b19e9d921 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -112,14 +112,14 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() { int socketHandle = _dtlsSocket->socketDescriptor(); #if defined(IP_DONTFRAG) int optValue = 1; - setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, reinterpret_cast(&optValue), sizeof(optValue)); + setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, reinterpret_cast(&optValue, sizeof(optValue)); #elif defined(IP_MTU_DISCOVER) int optValue = 1; setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, reinterpret_cast(&optValue), sizeof(optValue)); #endif #endif - qDebug() << "NodeList DTLS socket is listening on" << _dtlsSocket->localPort(); + qDebug() << "LimitedNodeList DTLS socket is listening on" << _dtlsSocket->localPort(); } return *_dtlsSocket; From 505145f6934a702ebd5a9289d7f8198b2ae312ba Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 12:02:02 -0700 Subject: [PATCH 14/15] add a missing bracket to IP_DONTFRAG --- libraries/networking/src/LimitedNodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 9b19e9d921..db8a689001 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -112,7 +112,7 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() { int socketHandle = _dtlsSocket->socketDescriptor(); #if defined(IP_DONTFRAG) int optValue = 1; - setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, reinterpret_cast(&optValue, sizeof(optValue)); + setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, reinterpret_cast(&optValue), sizeof(optValue)); #elif defined(IP_MTU_DISCOVER) int optValue = 1; setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, reinterpret_cast(&optValue), sizeof(optValue)); From 49e7842d25ff4e025f8f1d0fa65b4a1608c996f9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 16 Apr 2014 13:37:41 -0700 Subject: [PATCH 15/15] push packet version to force an update --- libraries/networking/src/PacketHeaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index fdbdca3db7..29238220e1 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -55,7 +55,7 @@ PacketVersion versionForPacketType(PacketType type) { return 1; case PacketTypeDomainList: case PacketTypeDomainListRequest: - return 2; + return 3; case PacketTypeCreateAssignment: case PacketTypeRequestAssignment: return 2;