diff --git a/interface/src/LODManager.cpp b/interface/src/LODManager.cpp index 5c55952e3a..6d08b8e242 100644 --- a/interface/src/LODManager.cpp +++ b/interface/src/LODManager.cpp @@ -20,13 +20,14 @@ Setting::Handle desktopLODDecreaseFPS("desktopLODDecreaseFPS", DEFAULT_DESKTOP_LOD_DOWN_FPS); Setting::Handle hmdLODDecreaseFPS("hmdLODDecreaseFPS", DEFAULT_HMD_LOD_DOWN_FPS); - -Setting::Handle avatarLODDistanceMultiplier("avatarLODDistanceMultiplier", - DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER); Setting::Handle boundaryLevelAdjust("boundaryLevelAdjust", 0); Setting::Handle octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE); +LODManager::LODManager() { + calculateAvatarLODDistanceMultiplier(); +} + float LODManager::getLODDecreaseFPS() { if (Application::getInstance()->isHMDMode()) { return getHMDLODDecreaseFPS(); @@ -64,21 +65,6 @@ void LODManager::autoAdjustLOD(float currentFPS) { // LOD Downward adjustment if (elapsed > ADJUST_LOD_DOWN_DELAY && _fpsAverage.getAverage() < getLODDecreaseFPS()) { - // Avatars... attempt to lower the detail in proportion to the fps difference - float targetFps = (getLODDecreaseFPS() + getLODIncreaseFPS()) * 0.5f; - float averageFps = _fastFPSAverage.getAverage(); - const float MAXIMUM_MULTIPLIER_SCALE = 2.0f; - float oldAvatarLODDistanceMultiplier = _avatarLODDistanceMultiplier; - _avatarLODDistanceMultiplier = qMin(MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier * - (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : - qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps))); - - if (oldAvatarLODDistanceMultiplier != _avatarLODDistanceMultiplier) { - qDebug() << "adjusting LOD down... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage() - << "_avatarLODDistanceMultiplier=" << _avatarLODDistanceMultiplier; - changed = true; - } - // Octree items... stepwise adjustment if (_octreeSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) { _octreeSizeScale *= ADJUST_LOD_DOWN_BY; @@ -100,20 +86,6 @@ void LODManager::autoAdjustLOD(float currentFPS) { // LOD Upward adjustment if (elapsed > ADJUST_LOD_UP_DELAY && _fpsAverage.getAverage() > getLODIncreaseFPS()) { - // Avatars... let the detail level creep slowly upwards - if (_avatarLODDistanceMultiplier < MAXIMUM_AUTO_ADJUST_AVATAR_LOD_DISTANCE_MULTIPLIER) { - const float DISTANCE_DECREASE_RATE = 0.05f; - float oldAvatarLODDistanceMultiplier = _avatarLODDistanceMultiplier; - _avatarLODDistanceMultiplier = qMax(MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, - _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE); - - if (oldAvatarLODDistanceMultiplier != _avatarLODDistanceMultiplier) { - qDebug() << "adjusting LOD up... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage() - << "_avatarLODDistanceMultiplier=" << _avatarLODDistanceMultiplier; - changed = true; - } - } - // Octee items... stepwise adjustment if (_octreeSizeScale < ADJUST_LOD_MAX_SIZE_SCALE) { if (_octreeSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) { @@ -137,6 +109,7 @@ void LODManager::autoAdjustLOD(float currentFPS) { } if (changed) { + calculateAvatarLODDistanceMultiplier(); _shouldRenderTableNeedsRebuilding = true; auto lodToolsDialog = DependencyManager::get()->getLodToolsDialog(); if (lodToolsDialog) { @@ -231,9 +204,14 @@ bool LODManager::shouldRenderMesh(float largestDimension, float distanceToCamera void LODManager::setOctreeSizeScale(float sizeScale) { _octreeSizeScale = sizeScale; + calculateAvatarLODDistanceMultiplier(); _shouldRenderTableNeedsRebuilding = true; } +void LODManager::calculateAvatarLODDistanceMultiplier() { + _avatarLODDistanceMultiplier = AVATAR_TO_ENTITY_RATIO / (_octreeSizeScale / DEFAULT_OCTREE_SIZE_SCALE); +} + void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; _shouldRenderTableNeedsRebuilding = true; @@ -243,8 +221,6 @@ void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) { void LODManager::loadSettings() { setDesktopLODDecreaseFPS(desktopLODDecreaseFPS.get()); setHMDLODDecreaseFPS(hmdLODDecreaseFPS.get()); - - setAvatarLODDistanceMultiplier(avatarLODDistanceMultiplier.get()); setBoundaryLevelAdjust(boundaryLevelAdjust.get()); setOctreeSizeScale(octreeSizeScale.get()); } @@ -252,8 +228,6 @@ void LODManager::loadSettings() { void LODManager::saveSettings() { desktopLODDecreaseFPS.set(getDesktopLODDecreaseFPS()); hmdLODDecreaseFPS.set(getHMDLODDecreaseFPS()); - - avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier()); boundaryLevelAdjust.set(getBoundaryLevelAdjust()); octreeSizeScale.set(getOctreeSizeScale()); } diff --git a/interface/src/LODManager.h b/interface/src/LODManager.h index 7d63fbd172..c14f17ca61 100644 --- a/interface/src/LODManager.h +++ b/interface/src/LODManager.h @@ -33,10 +33,9 @@ const float ADJUST_LOD_UP_BY = 1.1f; const float ADJUST_LOD_MIN_SIZE_SCALE = 1.0f; const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE; -const float MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 0.1f; -const float MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 15.0f; -const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f; -const float MAXIMUM_AUTO_ADJUST_AVATAR_LOD_DISTANCE_MULTIPLIER = DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER; +// The ratio of "visibility" of avatars to other content. A value larger than 1 will mean Avatars "cull" later than entities +// do. But both are still culled using the same angular size logic. +const float AVATAR_TO_ENTITY_RATIO = 2.0f; const int ONE_SECOND_OF_FRAMES = 60; const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES; @@ -58,7 +57,6 @@ public: Q_INVOKABLE float getHMDLODDecreaseFPS() const { return _hmdLODDecreaseFPS; } Q_INVOKABLE float getHMDLODIncreaseFPS() const { return _hmdLODDecreaseFPS + INCREASE_LOD_GAP; } - Q_INVOKABLE void setAvatarLODDistanceMultiplier(float multiplier) { _avatarLODDistanceMultiplier = multiplier; } Q_INVOKABLE float getAvatarLODDistanceMultiplier() const { return _avatarLODDistanceMultiplier; } // User Tweakable LOD Items @@ -87,14 +85,14 @@ signals: void LODDecreased(); private: - LODManager() {} + LODManager(); + void calculateAvatarLODDistanceMultiplier(); bool _automaticLODAdjust = true; float _desktopLODDecreaseFPS = DEFAULT_DESKTOP_LOD_DOWN_FPS; float _hmdLODDecreaseFPS = DEFAULT_HMD_LOD_DOWN_FPS; - float _avatarLODDistanceMultiplier = DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER; - + float _avatarLODDistanceMultiplier; float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE; int _boundaryLevelAdjust = 0; diff --git a/interface/src/ui/LodToolsDialog.cpp b/interface/src/ui/LodToolsDialog.cpp index 7635012bc2..97991c62a4 100644 --- a/interface/src/ui/LodToolsDialog.cpp +++ b/interface/src/ui/LodToolsDialog.cpp @@ -50,13 +50,6 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : _automaticLODAdjust->setChecked(lodManager->getAutomaticLODAdjust()); connect(_automaticLODAdjust, SIGNAL(toggled(bool)), SLOT(updateAutomaticLODAdjust())); - form->addRow("Avatar LOD:", _avatarLOD = new QDoubleSpinBox(this)); - _avatarLOD->setDecimals(3); - _avatarLOD->setRange(1.0 / MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, 1.0 / MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER); - _avatarLOD->setSingleStep(0.001); - _avatarLOD->setValue(1.0 / lodManager->getAvatarLODDistanceMultiplier()); - connect(_avatarLOD, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues())); - _lodSize = new QSlider(Qt::Horizontal, this); const int MAX_LOD_SIZE = MAX_LOD_SIZE_MULTIPLIER; const int MIN_LOD_SIZE = ADJUST_LOD_MIN_SIZE_SCALE; @@ -89,9 +82,6 @@ void LodToolsDialog::reloadSliders() { auto lodManager = DependencyManager::get(); _lodSize->setValue(lodManager->getOctreeSizeScale() / TREE_SCALE); _feedback->setText(lodManager->getLODFeedbackText()); - - _avatarLOD->setValue(1.0 / lodManager->getAvatarLODDistanceMultiplier()); - } void LodToolsDialog::updateAutomaticLODAdjust() { @@ -101,9 +91,7 @@ void LodToolsDialog::updateAutomaticLODAdjust() { void LodToolsDialog::updateLODValues() { auto lodManager = DependencyManager::get(); - lodManager->setAutomaticLODAdjust(_automaticLODAdjust->isChecked()); - lodManager->setAvatarLODDistanceMultiplier(1.0 / _avatarLOD->value()); } void LodToolsDialog::sizeScaleValueChanged(int value) { @@ -119,7 +107,6 @@ void LodToolsDialog::resetClicked(bool checked) { int sliderValue = DEFAULT_OCTREE_SIZE_SCALE / TREE_SCALE; _lodSize->setValue(sliderValue); _automaticLODAdjust->setChecked(true); - _avatarLOD->setValue(1.0 / DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER); updateLODValues(); // tell our LOD manager about the reset } diff --git a/interface/src/ui/LodToolsDialog.h b/interface/src/ui/LodToolsDialog.h index 709357fddd..91be04e0ed 100644 --- a/interface/src/ui/LodToolsDialog.h +++ b/interface/src/ui/LodToolsDialog.h @@ -50,8 +50,6 @@ private: QDoubleSpinBox* _hmdLODDecreaseFPS; - - QDoubleSpinBox* _avatarLOD; QLabel* _feedback; };