Showing the changes to interface/src/Menu.cpp (1 of 20 files). Show all
Unified · Split
| @@ -25,7 +25,6 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <QMessageBox> |
| 26 | 26 | #include <QShortcut> |
| 27 | 27 | #include <QSlider> |
| 28 | −#include <QStandardPaths> | |
| 29 | 28 | #include <QUuid> |
| 30 | 29 | #include <QHBoxLayout> |
| 31 | 30 | |
| @@ -79,6 +78,9 @@ Menu::Menu() : · 47 unmodified lines | ||
| 79 | 78 | _lodToolsDialog(NULL), |
| 80 | 79 | _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM), |
| 81 | 80 | _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE), |
| 81 | + _automaticAvatarLOD(true), | |
| 82 | + _avatarLODDecreaseFPS(DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS), | |
| 83 | + _avatarLODIncreaseFPS(ADJUST_LOD_UP_FPS), | |
| 82 | 84 | _avatarLODDistanceMultiplier(DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER), |
| 83 | 85 | _boundaryLevelAdjust(0), |
| 84 | 86 | _maxVoxelPacketsPerSecond(DEFAULT_MAX_VOXEL_PPS), |
| @@ -87,7 +89,8 @@ Menu::Menu() : · 2 unmodified lines | ||
| 87 | 89 | _fpsAverage(FIVE_SECONDS_OF_FRAMES), |
| 88 | 90 | _fastFPSAverage(ONE_SECOND_OF_FRAMES), |
| 89 | 91 | _loginAction(NULL), |
| 90 | − _preferencesDialog(NULL) | |
| 92 | + _preferencesDialog(NULL), | |
| 93 | + _snapshotsLocation() | |
| 91 | 94 | { |
| 92 | 95 | Application *appInstance = Application::getInstance(); |
| 93 | 96 | |
| @@ -273,7 +276,7 @@ Menu::Menu() : · 179 unmodified lines | ||
| 273 | 276 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, true); |
| 274 | 277 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, true); |
| 275 | 278 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Particles, 0, true); |
| 276 | − | |
| 279 | + addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); | |
| 277 | 280 | |
| 278 | 281 | QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options"); |
| 279 | 282 | |
| @@ -286,7 +289,6 @@ Menu::Menu() : · 6 unmodified lines | ||
| 286 | 289 | |
| 287 | 290 | addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures); |
| 288 | 291 | addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion); |
| 289 | − addActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); | |
| 290 | 292 | addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontFadeOnVoxelServerChanges); |
| 291 | 293 | addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DisableAutoAdjustLOD); |
| 292 | 294 | |
| @@ -415,7 +417,14 @@ void Menu::loadSettings(QSettings* settings) { · 122 unmodified lines | ||
| 415 | 417 | _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM); |
| 416 | 418 | _maxVoxelPacketsPerSecond = loadSetting(settings, "maxVoxelsPPS", DEFAULT_MAX_VOXEL_PPS); |
| 417 | 419 | _voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_OCTREE_SIZE_SCALE); |
| 420 | + _automaticAvatarLOD = settings->value("automaticAvatarLOD", true).toBool(); | |
| 421 | + _avatarLODDecreaseFPS = loadSetting(settings, "avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS); | |
| 422 | + _avatarLODIncreaseFPS = loadSetting(settings, "avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS); | |
| 423 | + _avatarLODDistanceMultiplier = loadSetting(settings, "avatarLODDistanceMultiplier", | |
| 424 | + DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER); | |
| 418 | 425 | _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0); |
| 426 | + _snapshotsLocation = settings->value("snapshotsLocation", | |
| 427 | + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString(); | |
| 419 | 428 | |
| 420 | 429 | settings->beginGroup("View Frustum Offset Camera"); |
| 421 | 430 | // in case settings is corrupt or missing loadSetting() will check for NaN |
| @@ -454,7 +463,12 @@ void Menu::saveSettings(QSettings* settings) { · 32 unmodified lines | ||
| 454 | 463 | settings->setValue("maxVoxels", _maxVoxels); |
| 455 | 464 | settings->setValue("maxVoxelsPPS", _maxVoxelPacketsPerSecond); |
| 456 | 465 | settings->setValue("voxelSizeScale", _voxelSizeScale); |
| 466 | + settings->setValue("automaticAvatarLOD", _automaticAvatarLOD); | |
| 467 | + settings->setValue("avatarLODDecreaseFPS", _avatarLODDecreaseFPS); | |
| 468 | + settings->setValue("avatarLODIncreaseFPS", _avatarLODIncreaseFPS); | |
| 469 | + settings->setValue("avatarLODDistanceMultiplier", _avatarLODDistanceMultiplier); | |
| 457 | 470 | settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust); |
| 471 | + settings->setValue("snapshotsLocation", _snapshotsLocation); | |
| 458 | 472 | settings->beginGroup("View Frustum Offset Camera"); |
| 459 | 473 | settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffset.yaw); |
| 460 | 474 | settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffset.pitch); |
| @@ -1157,27 +1171,27 @@ void Menu::autoAdjustLOD(float currentFPS) { · 696 unmodified lines | ||
| 1157 | 1171 | |
| 1158 | 1172 | quint64 now = usecTimestampNow(); |
| 1159 | 1173 | |
| 1160 | − const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f; | |
| 1161 | 1174 | const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000; |
| 1162 | − if (_fastFPSAverage.getAverage() < ADJUST_AVATAR_LOD_DOWN_FPS) { | |
| 1163 | − if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) { | |
| 1164 | − // attempt to lower the detail in proportion to the fps difference | |
| 1165 | − float targetFps = (ADJUST_AVATAR_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f; | |
| 1166 | − float averageFps = _fastFPSAverage.getAverage(); | |
| 1167 | − const float MAXIMUM_MULTIPLIER_SCALE = 2.0f; | |
| 1168 | − const float MAXIMUM_DISTANCE_MULTIPLIER = 15.0f; | |
| 1169 | − _avatarLODDistanceMultiplier = qMin(MAXIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier * | |
| 1170 | − (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps))); | |
| 1171 | − _lastAvatarDetailDrop = now; | |
| 1175 | + if (_automaticAvatarLOD) { | |
| 1176 | + if (_fastFPSAverage.getAverage() < _avatarLODDecreaseFPS) { | |
| 1177 | + if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) { | |
| 1178 | + // attempt to lower the detail in proportion to the fps difference | |
| 1179 | + float targetFps = (_avatarLODDecreaseFPS + _avatarLODIncreaseFPS) * 0.5f; | |
| 1180 | + float averageFps = _fastFPSAverage.getAverage(); | |
| 1181 | + const float MAXIMUM_MULTIPLIER_SCALE = 2.0f; | |
| 1182 | + _avatarLODDistanceMultiplier = qMin(MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier * | |
| 1183 | + (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : | |
| 1184 | + qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps))); | |
| 1185 | + _lastAvatarDetailDrop = now; | |
| 1186 | + } | |
| 1187 | + } else if (_fastFPSAverage.getAverage() > _avatarLODIncreaseFPS) { | |
| 1188 | + // let the detail level creep slowly upwards | |
| 1189 | + const float DISTANCE_DECREASE_RATE = 0.05f; | |
| 1190 | + _avatarLODDistanceMultiplier = qMax(MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, | |
| 1191 | + _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE); | |
| 1172 | 1192 | } |
| 1173 | − } else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) { | |
| 1174 | − // let the detail level creep slowly upwards | |
| 1175 | − const float DISTANCE_DECREASE_RATE = 0.05f; | |
| 1176 | − const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f; | |
| 1177 | − _avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER, | |
| 1178 | − _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE); | |
| 1179 | 1193 | } |
| 1180 | − | |
| 1194 | + | |
| 1181 | 1195 | bool changed = false; |
| 1182 | 1196 | quint64 elapsed = now - _lastAdjust; |
| 1183 | 1197 | |
| @@ -1501,3 +1515,10 @@ void Menu::removeMenuItem(const QString& menu, const QString& menuitem) { · 317 unmodified lines | ||
| 1501 | 1515 | QMenuBar::repaint(); |
| 1502 | 1516 | }; |
| 1503 | 1517 | |
| 1518 | +QString Menu::getSnapshotsLocation() const { | |
| 1519 | + if (_snapshotsLocation.isNull() || _snapshotsLocation.isEmpty() || QDir(_snapshotsLocation).exists() == false) { | |
| 1520 | + return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); | |
| 1521 | + } | |
| 1522 | + return _snapshotsLocation; | |
| 1523 | +} | |
| 1524 | + | |