History

Merge remote-tracking branch 'upstream/master' into 19554-2

Ryan Huffman committed 12 years ago

Commit 2de98482 parents 23d68d5 bd37a7520 files · +347 −84Browse files

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

Unified · Split

interface/src/Menu.cpp+43−22
@@ -25,7 +25,6 @@ · 24 unmodified lines
2525 #include <QMessageBox>
2626 #include <QShortcut>
2727 #include <QSlider>
28−#include <QStandardPaths>
2928 #include <QUuid>
3029 #include <QHBoxLayout>
3130
@@ -79,6 +78,9 @@ Menu::Menu() : · 47 unmodified lines
7978 _lodToolsDialog(NULL),
8079 _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM),
8180 _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE),
81+ _automaticAvatarLOD(true),
82+ _avatarLODDecreaseFPS(DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS),
83+ _avatarLODIncreaseFPS(ADJUST_LOD_UP_FPS),
8284 _avatarLODDistanceMultiplier(DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER),
8385 _boundaryLevelAdjust(0),
8486 _maxVoxelPacketsPerSecond(DEFAULT_MAX_VOXEL_PPS),
@@ -87,7 +89,8 @@ Menu::Menu() : · 2 unmodified lines
8789 _fpsAverage(FIVE_SECONDS_OF_FRAMES),
8890 _fastFPSAverage(ONE_SECOND_OF_FRAMES),
8991 _loginAction(NULL),
90− _preferencesDialog(NULL)
92+ _preferencesDialog(NULL),
93+ _snapshotsLocation()
9194 {
9295 Application *appInstance = Application::getInstance();
9396
@@ -273,7 +276,7 @@ Menu::Menu() : · 179 unmodified lines
273276 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, true);
274277 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, true);
275278 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Particles, 0, true);
276−
279+ addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
277280
278281 QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options");
279282
@@ -286,7 +289,6 @@ Menu::Menu() : · 6 unmodified lines
286289
287290 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);
288291 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);
289− addActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
290292 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontFadeOnVoxelServerChanges);
291293 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DisableAutoAdjustLOD);
292294
@@ -415,7 +417,14 @@ void Menu::loadSettings(QSettings* settings) { · 122 unmodified lines
415417 _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM);
416418 _maxVoxelPacketsPerSecond = loadSetting(settings, "maxVoxelsPPS", DEFAULT_MAX_VOXEL_PPS);
417419 _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);
418425 _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0);
426+ _snapshotsLocation = settings->value("snapshotsLocation",
427+ QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString();
419428
420429 settings->beginGroup("View Frustum Offset Camera");
421430 // in case settings is corrupt or missing loadSetting() will check for NaN
@@ -454,7 +463,12 @@ void Menu::saveSettings(QSettings* settings) { · 32 unmodified lines
454463 settings->setValue("maxVoxels", _maxVoxels);
455464 settings->setValue("maxVoxelsPPS", _maxVoxelPacketsPerSecond);
456465 settings->setValue("voxelSizeScale", _voxelSizeScale);
466+ settings->setValue("automaticAvatarLOD", _automaticAvatarLOD);
467+ settings->setValue("avatarLODDecreaseFPS", _avatarLODDecreaseFPS);
468+ settings->setValue("avatarLODIncreaseFPS", _avatarLODIncreaseFPS);
469+ settings->setValue("avatarLODDistanceMultiplier", _avatarLODDistanceMultiplier);
457470 settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust);
471+ settings->setValue("snapshotsLocation", _snapshotsLocation);
458472 settings->beginGroup("View Frustum Offset Camera");
459473 settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffset.yaw);
460474 settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffset.pitch);
@@ -1157,27 +1171,27 @@ void Menu::autoAdjustLOD(float currentFPS) { · 696 unmodified lines
11571171
11581172 quint64 now = usecTimestampNow();
11591173
1160− const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f;
11611174 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);
11721192 }
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);
11791193 }
1180−
1194+
11811195 bool changed = false;
11821196 quint64 elapsed = now - _lastAdjust;
11831197
@@ -1501,3 +1515,10 @@ void Menu::removeMenuItem(const QString& menu, const QString& menuitem) { · 317 unmodified lines
15011515 QMenuBar::repaint();
15021516 };
15031517
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+