mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-08 07:02:25 +02:00
working on the LOD behavior
This commit is contained in:
parent
b725ed440b
commit
cee9b90930
7 changed files with 213 additions and 15 deletions
|
@ -136,6 +136,11 @@ void LODManager::resetLODAdjust() {
|
|||
_decreaseFPSExpiry = _increaseFPSExpiry = usecTimestampNow() + LOD_AUTO_ADJUST_PERIOD;
|
||||
}
|
||||
|
||||
void LODManager::setAutomaticLODAdjust(bool value) {
|
||||
_automaticLODAdjust = value;
|
||||
emit autoLODChanged();
|
||||
}
|
||||
|
||||
float LODManager::getLODLevel() const {
|
||||
// simpleLOD is a linearized and normalized number that represents how much LOD is being applied.
|
||||
// It ranges from:
|
||||
|
@ -149,7 +154,14 @@ float LODManager::getLODLevel() const {
|
|||
}
|
||||
|
||||
void LODManager::setLODLevel(float level) {
|
||||
float simpleLOD = level;
|
||||
if (!_automaticLODAdjust) {
|
||||
const float LOG_MIN_LOD_RATIO = logf(ADJUST_LOD_MIN_SIZE_SCALE / ADJUST_LOD_MAX_SIZE_SCALE);
|
||||
|
||||
float power = LOG_MIN_LOD_RATIO - (simpleLOD * LOG_MIN_LOD_RATIO);
|
||||
float sizeScale = expf(power) * ADJUST_LOD_MAX_SIZE_SCALE;
|
||||
setOctreeSizeScale(sizeScale);
|
||||
}
|
||||
}
|
||||
|
||||
const float MIN_DECREASE_FPS = 0.5f;
|
||||
|
@ -247,3 +259,63 @@ void LODManager::saveSettings() {
|
|||
hmdLODDecreaseFPS.set(getHMDLODDecreaseFPS());
|
||||
}
|
||||
|
||||
void LODManager::setWorldDetailQuality(float quality) {
|
||||
|
||||
static const float MAX_DESKTOP_FPS = 60;
|
||||
static const float MAX_HMD_FPS = 90;
|
||||
static const float MIN_FPS = 10;
|
||||
static const float LOW = 0.25f;
|
||||
static const float MEDIUM = 0.5f;
|
||||
static const float HIGH = 0.75f;
|
||||
static const float THRASHING_DIFFERENCE = 10;
|
||||
|
||||
bool isLowestValue = quality == LOW;
|
||||
bool isHMDMode = qApp->isHMDMode();
|
||||
|
||||
float maxFPS = isHMDMode ? MAX_HMD_FPS : MAX_DESKTOP_FPS;
|
||||
float desiredFPS = maxFPS - THRASHING_DIFFERENCE;
|
||||
|
||||
if (!isLowestValue) {
|
||||
float calculatedFPS = (maxFPS - (maxFPS * quality)) - THRASHING_DIFFERENCE;
|
||||
desiredFPS = calculatedFPS < MIN_FPS ? MIN_FPS : calculatedFPS;
|
||||
}
|
||||
|
||||
if (isHMDMode) {
|
||||
setHMDLODDecreaseFPS(desiredFPS);
|
||||
}
|
||||
else {
|
||||
setDesktopLODDecreaseFPS(desiredFPS);
|
||||
}
|
||||
|
||||
emit worldDetailQualityChanged();
|
||||
}
|
||||
|
||||
float LODManager::getWorldDetailQuality() const {
|
||||
|
||||
|
||||
static const float MAX_DESKTOP_FPS = 60;
|
||||
static const float MAX_HMD_FPS = 90;
|
||||
static const float MIN_FPS = 10;
|
||||
static const float LOW = 0.25f;
|
||||
static const float MEDIUM = 0.5f;
|
||||
static const float HIGH = 0.75f;
|
||||
|
||||
bool inHMD = qApp->isHMDMode();
|
||||
|
||||
float increaseFPS = 0;
|
||||
if (inHMD) {
|
||||
increaseFPS = getHMDLODDecreaseFPS();
|
||||
} else {
|
||||
increaseFPS = getDesktopLODDecreaseFPS();
|
||||
}
|
||||
float maxFPS = inHMD ? MAX_HMD_FPS : MAX_DESKTOP_FPS;
|
||||
float percentage = increaseFPS / maxFPS;
|
||||
|
||||
if (percentage >= HIGH) {
|
||||
return LOW;
|
||||
}
|
||||
else if (percentage >= LOW) {
|
||||
return MEDIUM;
|
||||
}
|
||||
return HIGH;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,9 @@ class LODManager : public QObject, public Dependency {
|
|||
Q_PROPERTY(float lodLevel READ getLODLevel WRITE setLODLevel NOTIFY LODChanged)
|
||||
Q_PROPERTY(float lodDecreaseFPS READ getLODDecreaseFPS)
|
||||
Q_PROPERTY(float lodIncreaseFPS READ getLODIncreaseFPS)
|
||||
Q_PROPERTY(bool automaticLODAdjust READ getAutomaticLODAdjust WRITE setAutomaticLODAdjust)
|
||||
Q_PROPERTY(bool automaticLODAdjust READ getAutomaticLODAdjust WRITE setAutomaticLODAdjust NOTIFY autoLODChanged)
|
||||
|
||||
Q_PROPERTY(float worldDetailQuality READ getWorldDetailQuality WRITE setWorldDetailQuality NOTIFY worldDetailQualityChanged)
|
||||
|
||||
public:
|
||||
|
||||
|
@ -73,7 +75,7 @@ public:
|
|||
* @function LODManager.setAutomaticLODAdjust
|
||||
* @param {boolean} value
|
||||
*/
|
||||
Q_INVOKABLE void setAutomaticLODAdjust(bool value) { _automaticLODAdjust = value; }
|
||||
Q_INVOKABLE void setAutomaticLODAdjust(bool value);
|
||||
|
||||
/**jsdoc
|
||||
* @function LODManager.getAutomaticLODAdjust
|
||||
|
@ -179,6 +181,9 @@ public:
|
|||
float getLODLevel() const;
|
||||
void setLODLevel(float level);
|
||||
|
||||
void setWorldDetailQuality(float quality);
|
||||
float getWorldDetailQuality() const;
|
||||
|
||||
signals:
|
||||
|
||||
/**jsdoc
|
||||
|
@ -194,6 +199,8 @@ signals:
|
|||
void LODDecreased();
|
||||
|
||||
void LODChanged();
|
||||
void autoLODChanged();
|
||||
void worldDetailQualityChanged();
|
||||
|
||||
private:
|
||||
LODManager();
|
||||
|
|
|
@ -55,7 +55,7 @@ void setupPreferences() {
|
|||
// Graphics quality
|
||||
static const QString GRAPHICS_QUALITY { "Graphics Quality" };
|
||||
{
|
||||
static const float MAX_DESKTOP_FPS = 60;
|
||||
/* static const float MAX_DESKTOP_FPS = 60;
|
||||
static const float MAX_HMD_FPS = 90;
|
||||
static const float MIN_FPS = 10;
|
||||
static const float LOW = 0.25f;
|
||||
|
@ -102,6 +102,13 @@ void setupPreferences() {
|
|||
} else {
|
||||
lodManager->setDesktopLODDecreaseFPS(desiredFPS);
|
||||
}
|
||||
};*/
|
||||
auto getter = []()->float {
|
||||
return DependencyManager::get<LODManager>()->getWorldDetailQuality();
|
||||
};
|
||||
|
||||
auto setter = [](float value) {
|
||||
DependencyManager::get<LODManager>()->setWorldDetailQuality(value);
|
||||
};
|
||||
|
||||
auto wodSlider = new SliderPreference(GRAPHICS_QUALITY, "World Detail", getter, setter);
|
||||
|
|
|
@ -56,13 +56,13 @@ Item {
|
|||
anchors.verticalCenter: root.verticalCenter
|
||||
}
|
||||
|
||||
/* Binding {
|
||||
Binding {
|
||||
id: bindingControl
|
||||
target: root.config
|
||||
property: root.property
|
||||
value: sliderControl.value
|
||||
when: false
|
||||
}*/
|
||||
}
|
||||
|
||||
HifiControls.Slider {
|
||||
id: sliderControl
|
||||
|
@ -73,7 +73,7 @@ Item {
|
|||
anchors.top: root.top
|
||||
anchors.topMargin: 0
|
||||
|
||||
// onValueChanged: { root.valueChanged(value) }
|
||||
onValueChanged: { root.valueChanged(value) }
|
||||
}
|
||||
|
||||
HifiControls.Label {
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
//
|
||||
// RichSlider.qml
|
||||
//
|
||||
// Created by Zach Pomerantz on 2/8/2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4 as Original
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import "qrc:///qml/styles-uit"
|
||||
import "qrc:///qml/controls-uit" as HifiControls
|
||||
|
||||
|
||||
Item {
|
||||
HifiConstants { id: hifi }
|
||||
id: root
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 24
|
||||
|
||||
function defaultGet() { return 0 }
|
||||
function defaultSet(value) { }
|
||||
|
||||
property var labelAreaWidthScale: 0.5
|
||||
|
||||
property bool integral: false
|
||||
property var valueVarGetter: defaultGet
|
||||
property var valueVarSetter: defaultSet
|
||||
// property string property
|
||||
property alias valueVar : sliderControl.value
|
||||
// property alias valueSetter : sliderControl.value
|
||||
property alias min: sliderControl.minimumValue
|
||||
property alias max: sliderControl.maximumValue
|
||||
|
||||
property alias label: labelControl.text
|
||||
property bool showLabel: true
|
||||
|
||||
property bool showValue: true
|
||||
|
||||
|
||||
|
||||
signal valueChanged(real value)
|
||||
|
||||
Component.onCompleted: {
|
||||
}
|
||||
|
||||
HifiControls.Label {
|
||||
id: labelControl
|
||||
text: root.label
|
||||
enabled: root.showLabel
|
||||
anchors.left: root.left
|
||||
width: root.width * root.labelAreaWidthScale
|
||||
anchors.verticalCenter: root.verticalCenter
|
||||
}
|
||||
|
||||
HifiControls.Slider {
|
||||
id: sliderControl
|
||||
stepSize: root.integral ? 1.0 : 0.0
|
||||
anchors.left: labelControl.right
|
||||
anchors.right: root.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.top: root.top
|
||||
anchors.topMargin: 0
|
||||
onValueChanged: { root.valueVarSetter(value) }
|
||||
}
|
||||
|
||||
HifiControls.Label {
|
||||
id: labelValue
|
||||
enabled: root.showValue
|
||||
text: sliderControl.value.toFixed(root.integral ? 0 : 2)
|
||||
anchors.right: labelControl.right
|
||||
anchors.rightMargin: 5
|
||||
anchors.verticalCenter: root.verticalCenter
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
ConfigSlider 1.0 ConfigSlider.qml
|
||||
ConfigSlider 1.0 ConfigSlider.qml
|
||||
RichSlider 1.0 RichSlider.qml
|
|
@ -44,21 +44,50 @@ Item {
|
|||
}
|
||||
HifiControls.CheckBox {
|
||||
boxSize: 20
|
||||
text: "Manual LOD"
|
||||
checked: LODManager.getAutomaticLODAdjust()
|
||||
onCheckedChanged: { LODManager.setAutomaticLODAdjust(checked) }
|
||||
text: "Auto LOD"
|
||||
checked: LODManager.automaticLODAdjust
|
||||
onCheckedChanged: { LODManager.automaticLODAdjust = (checked) }
|
||||
}
|
||||
ConfigSlider {
|
||||
property var lodObject: LODManager
|
||||
|
||||
RichSlider {
|
||||
showLabel: true
|
||||
config: LODManager
|
||||
property: "lodLevel"
|
||||
max: 13
|
||||
min: 0
|
||||
label: "lodLevel"
|
||||
valueVar: LODManager["lodLevel"]
|
||||
valueVarSetter: (function (v) { LODManager["lodLevel"] = v })
|
||||
max: 1.0
|
||||
min: 0.0
|
||||
integral: false
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
RichSlider {
|
||||
showLabel: true
|
||||
// config: lodObject
|
||||
// property: "worldDetailQuality"
|
||||
// valueVar: LODManager["worldDetailQuality"]
|
||||
label: "World Quality"
|
||||
valueVar: LODManager["worldDetailQuality"]
|
||||
// valueVarGetter: { return LODManager["worldDetailQuality"] }
|
||||
valueVarSetter: (function (v) { LODManager["worldDetailQuality"] = v })
|
||||
max: 0.75
|
||||
min: 0.25
|
||||
integral: false
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
/* HifiControls.Slider {
|
||||
id: sliderControl
|
||||
stepSize: 0.0
|
||||
minimumValue: 0.0
|
||||
maximumValue: 1.2
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
value: LODManager["lodLevel"]
|
||||
onValueChanged: { LODManager["lodLevel"] = value }
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue