mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:28:02 +02:00
Leave LOD settings as globals
This commit is contained in:
parent
875507aaaa
commit
578ab1a9f2
3 changed files with 71 additions and 53 deletions
|
@ -9,6 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <SettingHandle.h>
|
||||||
#include <Util.h>
|
#include <Util.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
@ -16,16 +17,14 @@
|
||||||
|
|
||||||
#include "LODManager.h"
|
#include "LODManager.h"
|
||||||
|
|
||||||
LODManager::LODManager() :
|
Setting::Handle<bool> automaticAvatarLOD("automaticAvatarLOD", true);
|
||||||
_automaticAvatarLOD("automaticAvatarLOD", true),
|
Setting::Handle<float> avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS);
|
||||||
_avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS),
|
Setting::Handle<float> avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS);
|
||||||
_avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS),
|
Setting::Handle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
||||||
_avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER);
|
||||||
DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER),
|
Setting::Handle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
||||||
_boundaryLevelAdjust("boundaryLevelAdjust", 0),
|
Setting::Handle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
||||||
_octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LODManager::autoAdjustLOD(float currentFPS) {
|
void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
// NOTE: our first ~100 samples at app startup are completely all over the place, and we don't
|
// NOTE: our first ~100 samples at app startup are completely all over the place, and we don't
|
||||||
|
@ -42,25 +41,23 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
|
||||||
const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;
|
const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;
|
||||||
if (_automaticAvatarLOD.get()) {
|
if (_automaticAvatarLOD) {
|
||||||
if (_fastFPSAverage.getAverage() < _avatarLODDecreaseFPS.get()) {
|
if (_fastFPSAverage.getAverage() < _avatarLODDecreaseFPS) {
|
||||||
if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) {
|
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 = (_avatarLODDecreaseFPS.get() + _avatarLODIncreaseFPS.get()) * 0.5f;
|
float targetFps = (_avatarLODDecreaseFPS + _avatarLODIncreaseFPS) * 0.5f;
|
||||||
float averageFps = _fastFPSAverage.getAverage();
|
float averageFps = _fastFPSAverage.getAverage();
|
||||||
const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;
|
const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;
|
||||||
_avatarLODDistanceMultiplier.set(qMin(MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER,
|
_avatarLODDistanceMultiplier = qMin(MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier *
|
||||||
_avatarLODDistanceMultiplier.get() *
|
(averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE :
|
||||||
(averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE :
|
qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps)));
|
||||||
qMin(MAXIMUM_MULTIPLIER_SCALE,
|
|
||||||
targetFps / averageFps))));
|
|
||||||
_lastAvatarDetailDrop = now;
|
_lastAvatarDetailDrop = now;
|
||||||
}
|
}
|
||||||
} else if (_fastFPSAverage.getAverage() > _avatarLODIncreaseFPS.get()) {
|
} else if (_fastFPSAverage.getAverage() > _avatarLODIncreaseFPS) {
|
||||||
// let the detail level creep slowly upwards
|
// let the detail level creep slowly upwards
|
||||||
const float DISTANCE_DECREASE_RATE = 0.05f;
|
const float DISTANCE_DECREASE_RATE = 0.05f;
|
||||||
_avatarLODDistanceMultiplier.set(qMax(MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER,
|
_avatarLODDistanceMultiplier = qMax(MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER,
|
||||||
_avatarLODDistanceMultiplier.get() - DISTANCE_DECREASE_RATE));
|
_avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,29 +65,29 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
quint64 elapsed = now - _lastAdjust;
|
quint64 elapsed = now - _lastAdjust;
|
||||||
|
|
||||||
if (elapsed > ADJUST_LOD_DOWN_DELAY && _fpsAverage.getAverage() < ADJUST_LOD_DOWN_FPS
|
if (elapsed > ADJUST_LOD_DOWN_DELAY && _fpsAverage.getAverage() < ADJUST_LOD_DOWN_FPS
|
||||||
&& _octreeSizeScale.get() > ADJUST_LOD_MIN_SIZE_SCALE) {
|
&& _octreeSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) {
|
||||||
|
|
||||||
_octreeSizeScale.set(_octreeSizeScale.get() * ADJUST_LOD_DOWN_BY);
|
_octreeSizeScale *= ADJUST_LOD_DOWN_BY;
|
||||||
|
|
||||||
if (_octreeSizeScale.get() < ADJUST_LOD_MIN_SIZE_SCALE) {
|
if (_octreeSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) {
|
||||||
_octreeSizeScale.set(ADJUST_LOD_MIN_SIZE_SCALE);
|
_octreeSizeScale = ADJUST_LOD_MIN_SIZE_SCALE;
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
_lastAdjust = now;
|
_lastAdjust = now;
|
||||||
qDebug() << "adjusting LOD down... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage()
|
qDebug() << "adjusting LOD down... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage()
|
||||||
<< "_octreeSizeScale=" << _octreeSizeScale.get();
|
<< "_octreeSizeScale=" << _octreeSizeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elapsed > ADJUST_LOD_UP_DELAY && _fpsAverage.getAverage() > ADJUST_LOD_UP_FPS
|
if (elapsed > ADJUST_LOD_UP_DELAY && _fpsAverage.getAverage() > ADJUST_LOD_UP_FPS
|
||||||
&& _octreeSizeScale.get() < ADJUST_LOD_MAX_SIZE_SCALE) {
|
&& _octreeSizeScale < ADJUST_LOD_MAX_SIZE_SCALE) {
|
||||||
_octreeSizeScale.set(_octreeSizeScale.get() * ADJUST_LOD_UP_BY);
|
_octreeSizeScale *= ADJUST_LOD_UP_BY;
|
||||||
if (_octreeSizeScale.get() > ADJUST_LOD_MAX_SIZE_SCALE) {
|
if (_octreeSizeScale > ADJUST_LOD_MAX_SIZE_SCALE) {
|
||||||
_octreeSizeScale.set(ADJUST_LOD_MAX_SIZE_SCALE);
|
_octreeSizeScale = ADJUST_LOD_MAX_SIZE_SCALE;
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
_lastAdjust = now;
|
_lastAdjust = now;
|
||||||
qDebug() << "adjusting LOD up... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage()
|
qDebug() << "adjusting LOD up... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage()
|
||||||
<< "_octreeSizeScale=" << _octreeSizeScale.get();
|
<< "_octreeSizeScale=" << _octreeSizeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
@ -182,13 +179,32 @@ bool LODManager::shouldRenderMesh(float largestDimension, float distanceToCamera
|
||||||
}
|
}
|
||||||
|
|
||||||
void LODManager::setOctreeSizeScale(float sizeScale) {
|
void LODManager::setOctreeSizeScale(float sizeScale) {
|
||||||
_octreeSizeScale.set(sizeScale);
|
_octreeSizeScale = sizeScale;
|
||||||
_shouldRenderTableNeedsRebuilding = true;
|
_shouldRenderTableNeedsRebuilding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
||||||
_boundaryLevelAdjust.set(boundaryLevelAdjust);
|
_boundaryLevelAdjust = boundaryLevelAdjust;
|
||||||
_shouldRenderTableNeedsRebuilding = true;
|
_shouldRenderTableNeedsRebuilding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LODManager::loadSettings() {
|
||||||
|
setAutomaticAvatarLOD(automaticAvatarLOD.get());
|
||||||
|
setAvatarLODDecreaseFPS(avatarLODDecreaseFPS.get());
|
||||||
|
setAvatarLODIncreaseFPS(avatarLODIncreaseFPS.get());
|
||||||
|
setAvatarLODDistanceMultiplier(avatarLODDistanceMultiplier.get());
|
||||||
|
setBoundaryLevelAdjust(boundaryLevelAdjust.get());
|
||||||
|
setOctreeSizeScale(octreeSizeScale.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LODManager::saveSettings() {
|
||||||
|
automaticAvatarLOD.set(getAutomaticAvatarLOD());
|
||||||
|
avatarLODDecreaseFPS.set(getAvatarLODDecreaseFPS());
|
||||||
|
avatarLODIncreaseFPS.set(getAvatarLODIncreaseFPS());
|
||||||
|
avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
||||||
|
boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
||||||
|
octreeSizeScale.set(getOctreeSizeScale());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <OctreeConstants.h>
|
#include <OctreeConstants.h>
|
||||||
#include <SettingHandle.h>
|
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <SimpleMovingAverage.h>
|
#include <SimpleMovingAverage.h>
|
||||||
|
|
||||||
|
@ -43,38 +42,41 @@ class LODManager : public Dependency {
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setAutomaticAvatarLOD(bool automaticAvatarLOD) { _automaticAvatarLOD.set(automaticAvatarLOD); }
|
void setAutomaticAvatarLOD(bool automaticAvatarLOD) { _automaticAvatarLOD = automaticAvatarLOD; }
|
||||||
bool getAutomaticAvatarLOD() { return _automaticAvatarLOD.get(); }
|
bool getAutomaticAvatarLOD() const { return _automaticAvatarLOD; }
|
||||||
void setAvatarLODDecreaseFPS(float avatarLODDecreaseFPS) { _avatarLODDecreaseFPS.set(avatarLODDecreaseFPS); }
|
void setAvatarLODDecreaseFPS(float avatarLODDecreaseFPS) { _avatarLODDecreaseFPS = avatarLODDecreaseFPS; }
|
||||||
float getAvatarLODDecreaseFPS() { return _avatarLODDecreaseFPS.get(); }
|
float getAvatarLODDecreaseFPS() const { return _avatarLODDecreaseFPS; }
|
||||||
void setAvatarLODIncreaseFPS(float avatarLODIncreaseFPS) { _avatarLODIncreaseFPS.set(avatarLODIncreaseFPS); }
|
void setAvatarLODIncreaseFPS(float avatarLODIncreaseFPS) { _avatarLODIncreaseFPS = avatarLODIncreaseFPS; }
|
||||||
float getAvatarLODIncreaseFPS() { return _avatarLODIncreaseFPS.get(); }
|
float getAvatarLODIncreaseFPS() const { return _avatarLODIncreaseFPS; }
|
||||||
void setAvatarLODDistanceMultiplier(float multiplier) { _avatarLODDistanceMultiplier.set(multiplier); }
|
void setAvatarLODDistanceMultiplier(float multiplier) { _avatarLODDistanceMultiplier = multiplier; }
|
||||||
float getAvatarLODDistanceMultiplier() { return _avatarLODDistanceMultiplier.get(); }
|
float getAvatarLODDistanceMultiplier() const { return _avatarLODDistanceMultiplier; }
|
||||||
|
|
||||||
// User Tweakable LOD Items
|
// User Tweakable LOD Items
|
||||||
QString getLODFeedbackText();
|
QString getLODFeedbackText();
|
||||||
void setOctreeSizeScale(float sizeScale);
|
void setOctreeSizeScale(float sizeScale);
|
||||||
float getOctreeSizeScale() { return _octreeSizeScale.get(); }
|
float getOctreeSizeScale() const { return _octreeSizeScale; }
|
||||||
|
|
||||||
void setBoundaryLevelAdjust(int boundaryLevelAdjust);
|
void setBoundaryLevelAdjust(int boundaryLevelAdjust);
|
||||||
int getBoundaryLevelAdjust() { return _boundaryLevelAdjust.get(); }
|
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
||||||
|
|
||||||
void autoAdjustLOD(float currentFPS);
|
void autoAdjustLOD(float currentFPS);
|
||||||
void resetLODAdjust();
|
void resetLODAdjust();
|
||||||
|
|
||||||
bool shouldRenderMesh(float largestDimension, float distanceToCamera);
|
bool shouldRenderMesh(float largestDimension, float distanceToCamera);
|
||||||
|
|
||||||
|
void loadSettings();
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LODManager();
|
LODManager() {}
|
||||||
|
|
||||||
Setting::Handle<bool> _automaticAvatarLOD;
|
bool _automaticAvatarLOD = true;
|
||||||
Setting::Handle<float> _avatarLODDecreaseFPS;
|
float _avatarLODDecreaseFPS = DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS;
|
||||||
Setting::Handle<float> _avatarLODIncreaseFPS;
|
float _avatarLODIncreaseFPS = ADJUST_LOD_UP_FPS;
|
||||||
Setting::Handle<float> _avatarLODDistanceMultiplier;
|
float _avatarLODDistanceMultiplier = DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER;
|
||||||
|
|
||||||
Setting::Handle<int> _boundaryLevelAdjust;
|
float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE;
|
||||||
Setting::Handle<float> _octreeSizeScale;
|
int _boundaryLevelAdjust = 0;
|
||||||
|
|
||||||
quint64 _lastAdjust = 0;
|
quint64 _lastAdjust = 0;
|
||||||
quint64 _lastAvatarDetailDrop = 0;
|
quint64 _lastAvatarDetailDrop = 0;
|
||||||
|
|
|
@ -378,9 +378,9 @@ void ChatWindow::messageReceived(const QXmppMessage& message) {
|
||||||
if (message.body().contains(usernameMention)) {
|
if (message.body().contains(usernameMention)) {
|
||||||
|
|
||||||
// Don't show messages already seen in icon tray at start-up.
|
// Don't show messages already seen in icon tray at start-up.
|
||||||
bool showMessage = usernameMentionTimestamp.get() < _lastMessageStamp;
|
bool showMessage = _usernameMentionTimestamp.get() < _lastMessageStamp;
|
||||||
if (showMessage) {
|
if (showMessage) {
|
||||||
usernameMentionTimestamp.set(_lastMessageStamp);
|
_usernameMentionTimestamp.set(_lastMessageStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHidden() && showMessage) {
|
if (isHidden() && showMessage) {
|
||||||
|
|
Loading…
Reference in a new issue