History

Merge pull request #2657 from ey6es/master

Added tools to adjust avatar LOD to LOD tools dialog. Closes #2624.

AndrewMeadows committed 12 years ago

Commit 7dc8f2a2 parents fbafbf4 873620e5 files · +115 −21Browse files

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

Unified · Split

interface/src/Menu.cpp+31−20
@@ -78,6 +78,9 @@ Menu::Menu() : · 77 unmodified lines
78 _lodToolsDialog(NULL),78 _lodToolsDialog(NULL),
79 _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM),79 _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM),
80 _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE),80 _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE),
81 _automaticAvatarLOD(true),
82 _avatarLODDecreaseFPS(DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS),
83 _avatarLODIncreaseFPS(ADJUST_LOD_UP_FPS),
81 _avatarLODDistanceMultiplier(DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER),84 _avatarLODDistanceMultiplier(DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER),
82 _boundaryLevelAdjust(0),85 _boundaryLevelAdjust(0),
83 _maxVoxelPacketsPerSecond(DEFAULT_MAX_VOXEL_PPS),86 _maxVoxelPacketsPerSecond(DEFAULT_MAX_VOXEL_PPS),
@@ -273,7 +276,7 @@ Menu::Menu() : · 189 unmodified lines
273 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, true);276 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, true);
274 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, true);277 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, true);
275 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Particles, 0, true);278 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Particles, 0, true);
276 279 addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
277 280
278 QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options");281 QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options");
279 282
@@ -286,7 +289,6 @@ Menu::Menu() : · 6 unmodified lines
286 289
287 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);290 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);
288 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);291 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);
289 addActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
290 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontFadeOnVoxelServerChanges);292 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontFadeOnVoxelServerChanges);
291 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DisableAutoAdjustLOD);293 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DisableAutoAdjustLOD);
292 294
@@ -415,6 +417,11 @@ void Menu::loadSettings(QSettings* settings) { · 122 unmodified lines
415 _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM);417 _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM);
416 _maxVoxelPacketsPerSecond = loadSetting(settings, "maxVoxelsPPS", DEFAULT_MAX_VOXEL_PPS);418 _maxVoxelPacketsPerSecond = loadSetting(settings, "maxVoxelsPPS", DEFAULT_MAX_VOXEL_PPS);
417 _voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_OCTREE_SIZE_SCALE);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 _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0);425 _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0);
419 _snapshotsLocation = settings->value("snapshotsLocation",426 _snapshotsLocation = settings->value("snapshotsLocation",
420 QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString();427 QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString();
@@ -456,6 +463,10 @@ void Menu::saveSettings(QSettings* settings) { · 35 unmodified lines
456 settings->setValue("maxVoxels", _maxVoxels);463 settings->setValue("maxVoxels", _maxVoxels);
457 settings->setValue("maxVoxelsPPS", _maxVoxelPacketsPerSecond);464 settings->setValue("maxVoxelsPPS", _maxVoxelPacketsPerSecond);
458 settings->setValue("voxelSizeScale", _voxelSizeScale);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);
459 settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust);470 settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust);
460 settings->setValue("snapshotsLocation", _snapshotsLocation);471 settings->setValue("snapshotsLocation", _snapshotsLocation);
461 settings->beginGroup("View Frustum Offset Camera");472 settings->beginGroup("View Frustum Offset Camera");
@@ -1161,27 +1172,27 @@ void Menu::autoAdjustLOD(float currentFPS) { · 699 unmodified lines
1161 1172
1162 quint64 now = usecTimestampNow();1173 quint64 now = usecTimestampNow();
1163 1174
1164 const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f;
1165 const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;1175 const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;
1166 if (_fastFPSAverage.getAverage() < ADJUST_AVATAR_LOD_DOWN_FPS) {1176 if (_automaticAvatarLOD) {
1167 if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) {1177 if (_fastFPSAverage.getAverage() < _avatarLODDecreaseFPS) {
1168 // attempt to lower the detail in proportion to the fps difference1178 if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) {
1169 float targetFps = (ADJUST_AVATAR_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f;1179 // attempt to lower the detail in proportion to the fps difference
1170 float averageFps = _fastFPSAverage.getAverage();1180 float targetFps = (_avatarLODDecreaseFPS + _avatarLODIncreaseFPS) * 0.5f;
1171 const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;1181 float averageFps = _fastFPSAverage.getAverage();
1172 const float MAXIMUM_DISTANCE_MULTIPLIER = 15.0f;1182 const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;
1173 _avatarLODDistanceMultiplier = qMin(MAXIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier *1183 _avatarLODDistanceMultiplier = qMin(MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier *
1174 (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps)));1184 (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE :
1175 _lastAvatarDetailDrop = now;1185 qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps)));
1186 _lastAvatarDetailDrop = now;
1187 }
1188 } else if (_fastFPSAverage.getAverage() > _avatarLODIncreaseFPS) {
1189 // let the detail level creep slowly upwards
1190 const float DISTANCE_DECREASE_RATE = 0.05f;
1191 _avatarLODDistanceMultiplier = qMax(MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER,
1192 _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
1176 }1193 }
1177 } else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) {
1178 // let the detail level creep slowly upwards
1179 const float DISTANCE_DECREASE_RATE = 0.05f;
1180 const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f;
1181 _avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER,
1182 _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
1183 }1194 }
1184 1195
1185 bool changed = false;1196 bool changed = false;
1186 quint64 elapsed = now - _lastAdjust;1197 quint64 elapsed = now - _lastAdjust;
1187 1198

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