Adjust avatar LOD faster. Closes #2496.

This commit is contained in:
Andrzej Kapolka 2014-03-26 16:01:07 -07:00
parent 52c8a865f1
commit 1cae0dc94c
3 changed files with 14 additions and 9 deletions

View file

@ -113,18 +113,18 @@
<context> <context>
<name>Menu</name> <name>Menu</name>
<message> <message>
<location filename="src/Menu.cpp" line="457"/> <location filename="src/Menu.cpp" line="459"/>
<source>Open .ini config file</source> <source>Open .ini config file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Menu.cpp" line="459"/> <location filename="src/Menu.cpp" line="461"/>
<location filename="src/Menu.cpp" line="471"/> <location filename="src/Menu.cpp" line="473"/>
<source>Text files (*.ini)</source> <source>Text files (*.ini)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Menu.cpp" line="469"/> <location filename="src/Menu.cpp" line="471"/>
<source>Save .ini config file</source> <source>Save .ini config file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -62,7 +62,8 @@ Menu* Menu::getInstance() {
const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f}; const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f};
const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f;
const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f; const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f;
const int FIVE_SECONDS_OF_FRAMES = 5 * 60; const int ONE_SECOND_OF_FRAMES = 60;
const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES;
Menu::Menu() : Menu::Menu() :
_actionHash(), _actionHash(),
@ -82,6 +83,7 @@ Menu::Menu() :
_lastAdjust(usecTimestampNow()), _lastAdjust(usecTimestampNow()),
_lastAvatarDetailDrop(usecTimestampNow()), _lastAvatarDetailDrop(usecTimestampNow()),
_fpsAverage(FIVE_SECONDS_OF_FRAMES), _fpsAverage(FIVE_SECONDS_OF_FRAMES),
_fastFPSAverage(ONE_SECOND_OF_FRAMES),
_loginAction(NULL) _loginAction(NULL)
{ {
Application *appInstance = Application::getInstance(); Application *appInstance = Application::getInstance();
@ -1192,17 +1194,19 @@ void Menu::autoAdjustLOD(float currentFPS) {
currentFPS = ASSUMED_FPS; currentFPS = ASSUMED_FPS;
} }
_fpsAverage.updateAverage(currentFPS); _fpsAverage.updateAverage(currentFPS);
_fastFPSAverage.updateAverage(currentFPS);
quint64 now = usecTimestampNow(); quint64 now = usecTimestampNow();
if (_fpsAverage.getAverage() < ADJUST_LOD_DOWN_FPS) { const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;
if (now - _lastAvatarDetailDrop > ADJUST_LOD_DOWN_DELAY) { if (_fastFPSAverage.getAverage() < ADJUST_LOD_DOWN_FPS) {
if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) {
// attempt to lower the detail in proportion to the fps difference // attempt to lower the detail in proportion to the fps difference
float targetFps = (ADJUST_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f; float targetFps = (ADJUST_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f;
_avatarLODDistanceMultiplier *= (targetFps / _fpsAverage.getAverage()); _avatarLODDistanceMultiplier *= (targetFps / _fastFPSAverage.getAverage());
_lastAvatarDetailDrop = now; _lastAvatarDetailDrop = now;
} }
} else if (_fpsAverage.getAverage() > ADJUST_LOD_UP_FPS) { } else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) {
// let the detail level creep slowly upwards // let the detail level creep slowly upwards
const float DISTANCE_DECREASE_RATE = 0.01f; const float DISTANCE_DECREASE_RATE = 0.01f;
const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f; const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f;

View file

@ -211,6 +211,7 @@ private:
quint64 _lastAdjust; quint64 _lastAdjust;
quint64 _lastAvatarDetailDrop; quint64 _lastAvatarDetailDrop;
SimpleMovingAverage _fpsAverage; SimpleMovingAverage _fpsAverage;
SimpleMovingAverage _fastFPSAverage;
QAction* _loginAction; QAction* _loginAction;
QAction* _chatAction; QAction* _chatAction;
}; };