Merge pull request #465 from overte-org/feature/fov_setting

Added FOV setting to graphics menu
This commit is contained in:
ksuprynowicz 2023-06-25 10:12:54 +02:00 committed by GitHub
commit da03262084
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 6 deletions

View file

@ -18,9 +18,20 @@ import controlsUit 1.0 as HifiControlsUit
import "qrc:////qml//controls" as HifiControls
import PerformanceEnums 1.0
Item {
Flickable {
HifiStylesUit.HifiConstants { id: hifi; }
contentHeight: graphicsSettingsColumnLayout.height;
ScrollBar.vertical : ScrollBar {
policy: ScrollBar.AlwaysOn
visible: true
width: 20
background: Rectangle {
color: hifi.colors.tableScrollBackgroundDark
}
}
id: root;
anchors.fill: parent
@ -418,6 +429,53 @@ Item {
}
}
}
Item {
Layout.preferredWidth: parent.width
Layout.preferredHeight: 35
Layout.topMargin: 16
HifiStylesUit.RalewayRegular {
id: fieldOfViewHeader
text: "Vertical FOV (" + Number(Math.round(Render.verticalFieldOfView)) + ")"
anchors.left: parent.left
anchors.top: parent.top
width: 130
height: parent.height
size: 16
color: "#FFFFFF"
}
HifiControlsUit.Slider {
id: fieldOfViewSlider
enabled: true
anchors.left: fieldOfViewHeader.right
anchors.leftMargin: 57
anchors.top: parent.top
width: 150
height: parent.height
colorScheme: hifi.colorSchemes.dark
minimumValue: 20
maximumValue: 130
stepSize: 0.05
value: Render.verticalFieldOfView
live: true
function updateFieldOfView(sliderValue) {
if (Render.verticalFieldOfView !== sliderValue) {
Render.verticalFieldOfView = sliderValue;
}
}
onValueChanged: {
updateFieldOfView(value);
}
onPressedChanged: {
if (!pressed) {
updateFieldOfView(value);
}
}
}
}
}
ColumnLayout {

View file

@ -223,6 +223,13 @@ void RenderScriptingInterface::setViewportResolutionScale(float scale) {
}
}
void RenderScriptingInterface::setVerticalFieldOfView(float fieldOfView) {
if (getViewportResolutionScale() != fieldOfView) {
qApp->setFieldOfView(fieldOfView);
emit settingsChanged();
}
}
QStringList RenderScriptingInterface::getScreens() const {
QStringList screens;

View file

@ -41,6 +41,7 @@ class RenderScriptingInterface : public QObject {
Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged)
Q_PROPERTY(AntialiasingConfig::Mode antialiasingMode READ getAntialiasingMode WRITE setAntialiasingMode NOTIFY settingsChanged)
Q_PROPERTY(float viewportResolutionScale READ getViewportResolutionScale WRITE setViewportResolutionScale NOTIFY settingsChanged)
Q_PROPERTY(float verticalFieldOfView READ getVerticalFieldOfView WRITE setVerticalFieldOfView NOTIFY settingsChanged)
public:
RenderScriptingInterface();
@ -178,27 +179,41 @@ public slots:
/*@jsdoc
* Returns the list of screens
* @function Render.getScreens
* @returns {string[]} The names of the available screens
* @returns {string[]} The names of the available screens.
*/
QStringList getScreens() const;
/*@jsdoc
* Gets the screen used when switching to full screen mode
* Gets the screen used when switching to full screen mode.
* @function Render.getFullScreenScreen
* @returns {string} The name of the screen used for full screen mode
* @returns {string} The name of the screen used for full screen mode.
*/
QString getFullScreenScreen() const;
/*@jsdoc
* Sets the screen used when switching to full screen mode
* Sets the screen used when switching to full screen mode.
* This function will only succeed if the name passed is one of the entries from Render.getScreens.
* Otherwise, it will return False and have no effect.
*
* @function Render.setFullScreenScreen
* @returns {bool} True if the setting was successful
* @returns {bool} True if the setting was successful.
*/
bool setFullScreenScreen(QString name);
/*@jsdoc
* Gets the vertical field of view in degrees.
* @function Render.getVerticalFieldOfView
* @returns {number} The vertical field of view in degrees.
*/
float getVerticalFieldOfView() { return qApp->getFieldOfView(); }
/*@jsdoc
* Sets the vertical field of view in degrees.
* @function Render.setVerticalFieldOfView
* @param {number} fieldOfView - The vertical field of view in degrees to set.
*/
void setVerticalFieldOfView( float fieldOfView );
signals:
/*@jsdoc