History

Merge branch 'master' of https://github.com/worklist/hifi

Philip Rosedale committed 12 years ago

Commit 7a2279b2 parents d5e106b bde71525 files · +58 −17Browse files

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

Unified · Split

interface/src/Menu.cpp+28−5
@@ -56,6 +56,7 @@ Menu* Menu::getInstance() { · 55 unmodified lines
56 56
57const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f};57const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f};
58const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f;58const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f;
59const int FIVE_SECONDS_OF_FRAMES = 5 * 60;
59 60
60Menu::Menu() :61Menu::Menu() :
61 _actionHash(),62 _actionHash(),
@@ -72,6 +73,7 @@ Menu::Menu() : · 10 unmodified lines
72 _boundaryLevelAdjust(0),73 _boundaryLevelAdjust(0),
73 _maxVoxelPacketsPerSecond(DEFAULT_MAX_VOXEL_PPS),74 _maxVoxelPacketsPerSecond(DEFAULT_MAX_VOXEL_PPS),
74 _lastAdjust(usecTimestampNow()),75 _lastAdjust(usecTimestampNow()),
76 _fpsAverage(FIVE_SECONDS_OF_FRAMES),
75 _loginAction(NULL)77 _loginAction(NULL)
76{78{
77 Application *appInstance = Application::getInstance();79 Application *appInstance = Application::getInstance();
@@ -1104,22 +1106,43 @@ void Menu::voxelStatsDetailsClosed() { · 1026 unmodified lines
1104}1106}
1105 1107
1106void Menu::autoAdjustLOD(float currentFPS) {1108void Menu::autoAdjustLOD(float currentFPS) {
1109 // NOTE: our first ~100 samples at app startup are completely all over the place, and we don't
1110 // really want to count them in our average, so we will ignore the real frame rates and stuff
1111 // our moving average with simulated good data
1112 const int IGNORE_THESE_SAMPLES = 100;
1113 const float ASSUMED_FPS = 60.0f;
1114 if (_fpsAverage.getSampleCount() < IGNORE_THESE_SAMPLES) {
1115 currentFPS = ASSUMED_FPS;
1116 }
1117 _fpsAverage.updateAverage(currentFPS);
1118
1107 bool changed = false;1119 bool changed = false;
1108 quint64 now = usecTimestampNow();1120 quint64 now = usecTimestampNow();
1109 quint64 elapsed = now - _lastAdjust;1121 quint64 elapsed = now - _lastAdjust;
1110 1122
1111 if (elapsed > ADJUST_LOD_DOWN_DELAY && currentFPS < ADJUST_LOD_DOWN_FPS && _voxelSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) {1123 if (elapsed > ADJUST_LOD_DOWN_DELAY && _fpsAverage.getAverage() < ADJUST_LOD_DOWN_FPS
1124 && _voxelSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) {
1125
1112 _voxelSizeScale *= ADJUST_LOD_DOWN_BY;1126 _voxelSizeScale *= ADJUST_LOD_DOWN_BY;
1127 if (_voxelSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) {
1128 _voxelSizeScale = ADJUST_LOD_MIN_SIZE_SCALE;
1129 }
1113 changed = true;1130 changed = true;
1114 _lastAdjust = now;1131 _lastAdjust = now;
1115 qDebug() << "adjusting LOD down... currentFPS=" << currentFPS << "_voxelSizeScale=" << _voxelSizeScale;1132 qDebug() << "adjusting LOD down... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage()
1133 << "_voxelSizeScale=" << _voxelSizeScale;
1116 }1134 }
1117 1135
1118 if (elapsed > ADJUST_LOD_UP_DELAY && currentFPS > ADJUST_LOD_UP_FPS && _voxelSizeScale < ADJUST_LOD_MAX_SIZE_SCALE) {1136 if (elapsed > ADJUST_LOD_UP_DELAY && _fpsAverage.getAverage() > ADJUST_LOD_UP_FPS
1137 && _voxelSizeScale < ADJUST_LOD_MAX_SIZE_SCALE) {
1119 _voxelSizeScale *= ADJUST_LOD_UP_BY;1138 _voxelSizeScale *= ADJUST_LOD_UP_BY;
1139 if (_voxelSizeScale > ADJUST_LOD_MAX_SIZE_SCALE) {
1140 _voxelSizeScale = ADJUST_LOD_MAX_SIZE_SCALE;
1141 }
1120 changed = true;1142 changed = true;
1121 _lastAdjust = now;1143 _lastAdjust = now;
1122 qDebug() << "adjusting LOD up... currentFPS=" << currentFPS << "_voxelSizeScale=" << _voxelSizeScale;1144 qDebug() << "adjusting LOD up... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage()
1145 << "_voxelSizeScale=" << _voxelSizeScale;
1123 }1146 }
1124 1147
1125 if (changed) {1148 if (changed) {