mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:38:29 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into webwindow-open-url
This commit is contained in:
commit
bb4417acc6
15 changed files with 2513 additions and 2289 deletions
|
@ -18,4 +18,3 @@ Script.load("lobby.js");
|
||||||
Script.load("notifications.js");
|
Script.load("notifications.js");
|
||||||
Script.load("look.js");
|
Script.load("look.js");
|
||||||
Script.load("users.js");
|
Script.load("users.js");
|
||||||
Script.load("utilities/LODWarning.js");
|
|
||||||
|
|
157
examples/example/entities/makeHouses.js
Normal file
157
examples/example/entities/makeHouses.js
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
//
|
||||||
|
// makeHouses.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Stojce Slavkovski on March 14, 2015
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample script that creates house entities based on parameters.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
|
||||||
|
/** options **/
|
||||||
|
var numHouses = 100;
|
||||||
|
var xRange = 300;
|
||||||
|
var yRange = 300;
|
||||||
|
|
||||||
|
var sizeOfTheHouse = {
|
||||||
|
x: 10,
|
||||||
|
y: 15,
|
||||||
|
z: 10
|
||||||
|
};
|
||||||
|
|
||||||
|
var randomizeModels = false;
|
||||||
|
/**/
|
||||||
|
|
||||||
|
var modelUrlPrefix = "http://public.highfidelity.io/load_testing/3-Buildings-2-SanFranciscoHouse-";
|
||||||
|
var modelurlExt = ".fbx";
|
||||||
|
var modelVariations = 100;
|
||||||
|
|
||||||
|
var houses = [];
|
||||||
|
|
||||||
|
function addHouseAt(position, rotation) {
|
||||||
|
// get house model
|
||||||
|
var modelNumber = randomizeModels ?
|
||||||
|
1 + Math.floor(Math.random() * (modelVariations - 1)) :
|
||||||
|
(houses.length + 1) % modelVariations;
|
||||||
|
|
||||||
|
if (modelNumber == 0) {
|
||||||
|
modelNumber = modelVariations;
|
||||||
|
}
|
||||||
|
|
||||||
|
var modelUrl = modelUrlPrefix + (modelNumber + "") + modelurlExt;
|
||||||
|
print("Model ID:" + modelNumber);
|
||||||
|
print("Model URL:" + modelUrl);
|
||||||
|
|
||||||
|
var properties = {
|
||||||
|
type: "Model",
|
||||||
|
position: position,
|
||||||
|
rotation: rotation,
|
||||||
|
dimensions: sizeOfTheHouse,
|
||||||
|
modelURL: modelUrl
|
||||||
|
};
|
||||||
|
|
||||||
|
return Entities.addEntity(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate initial position
|
||||||
|
var posX = MyAvatar.position.x - (xRange / 2);
|
||||||
|
var measures = calculateParcels(numHouses, xRange, yRange);
|
||||||
|
var dd = 0;
|
||||||
|
|
||||||
|
// avatar facing rotation
|
||||||
|
var rotEven = Quat.fromPitchYawRollDegrees(0, 270.0 + MyAvatar.bodyYaw, 0.0);
|
||||||
|
|
||||||
|
// avatar opposite rotation
|
||||||
|
var rotOdd = Quat.fromPitchYawRollDegrees(0, 90.0 + MyAvatar.bodyYaw, 0.0);
|
||||||
|
var housePos = Vec3.sum(MyAvatar.position, Quat.getFront(Camera.getOrientation()));
|
||||||
|
|
||||||
|
for (var j = 0; j < measures.rows; j++) {
|
||||||
|
|
||||||
|
var posX1 = 0 - (xRange / 2);
|
||||||
|
dd += measures.parcelLength;
|
||||||
|
|
||||||
|
for (var i = 0; i < measures.cols; i++) {
|
||||||
|
|
||||||
|
// skip reminder of houses
|
||||||
|
if (houses.length > numHouses) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var posShift = {
|
||||||
|
x: posX1,
|
||||||
|
y: 0,
|
||||||
|
z: dd
|
||||||
|
};
|
||||||
|
|
||||||
|
print("House nr.:" + (houses.length + 1));
|
||||||
|
houses.push(
|
||||||
|
addHouseAt(Vec3.sum(housePos, posShift), (j % 2 == 0) ? rotEven : rotOdd)
|
||||||
|
);
|
||||||
|
posX1 += measures.parcelWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate rows and columns in area, and dimension of single parcel
|
||||||
|
function calculateParcels(items, areaWidth, areaLength) {
|
||||||
|
|
||||||
|
var idealSize = Math.min(Math.sqrt(areaWidth * areaLength / items), areaWidth, areaLength);
|
||||||
|
|
||||||
|
var baseWidth = Math.min(Math.floor(areaWidth / idealSize), items);
|
||||||
|
var baseLength = Math.min(Math.floor(areaLength / idealSize), items);
|
||||||
|
|
||||||
|
var sirRows = baseWidth;
|
||||||
|
var sirCols = Math.ceil(items / sirRows);
|
||||||
|
var sirW = areaWidth / sirRows;
|
||||||
|
var sirL = areaLength / sirCols;
|
||||||
|
|
||||||
|
var visCols = baseLength;
|
||||||
|
var visRows = Math.ceil(items / visCols);
|
||||||
|
var visW = areaWidth / visRows;
|
||||||
|
var visL = areaLength / visCols;
|
||||||
|
|
||||||
|
var rows = 0;
|
||||||
|
var cols = 0;
|
||||||
|
var parcelWidth = 0;
|
||||||
|
var parcelLength = 0;
|
||||||
|
|
||||||
|
if (Math.min(sirW, sirL) > Math.min(visW, visL)) {
|
||||||
|
rows = sirRows;
|
||||||
|
cols = sirCols;
|
||||||
|
parcelWidth = sirW;
|
||||||
|
parcelLength = sirL;
|
||||||
|
} else {
|
||||||
|
rows = visRows;
|
||||||
|
cols = visCols;
|
||||||
|
parcelWidth = visW;
|
||||||
|
parcelLength = visL;
|
||||||
|
}
|
||||||
|
|
||||||
|
print("rows:" + rows);
|
||||||
|
print("cols:" + cols);
|
||||||
|
print("parcelWidth:" + parcelWidth);
|
||||||
|
print("parcelLength:" + parcelLength);
|
||||||
|
|
||||||
|
return {
|
||||||
|
rows: rows,
|
||||||
|
cols: cols,
|
||||||
|
parcelWidth: parcelWidth,
|
||||||
|
parcelLength: parcelLength
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
while (houses.length > 0) {
|
||||||
|
if (!houses[0].isKnownID) {
|
||||||
|
houses[0] = Entities.identifyEntity(houses[0]);
|
||||||
|
}
|
||||||
|
Entities.deleteEntity(houses.shift());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
})();
|
|
@ -13,5 +13,4 @@ Script.load("progress.js");
|
||||||
Script.load("lobby.js");
|
Script.load("lobby.js");
|
||||||
Script.load("notifications.js");
|
Script.load("notifications.js");
|
||||||
Script.load("controllers/oculus/goTo.js");
|
Script.load("controllers/oculus/goTo.js");
|
||||||
Script.load("utilities/LODWarning.js");
|
|
||||||
//Script.load("scripts.js"); // Not created yet
|
//Script.load("scripts.js"); // Not created yet
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
// after that we will send it to createNotification(text).
|
// after that we will send it to createNotification(text).
|
||||||
// If the message is 42 chars or less you should bypass wordWrap() and call createNotification() directly.
|
// If the message is 42 chars or less you should bypass wordWrap() and call createNotification() directly.
|
||||||
|
|
||||||
|
|
||||||
// To add a keypress driven notification:
|
// To add a keypress driven notification:
|
||||||
//
|
//
|
||||||
// 1. Add a key to the keyPressEvent(key).
|
// 1. Add a key to the keyPressEvent(key).
|
||||||
|
@ -85,16 +84,19 @@ var PLAY_NOTIFICATION_SOUNDS_MENU_ITEM = "Play Notification Sounds";
|
||||||
var NOTIFICATION_MENU_ITEM_POST = " Notifications";
|
var NOTIFICATION_MENU_ITEM_POST = " Notifications";
|
||||||
var PLAY_NOTIFICATION_SOUNDS_SETTING = "play_notification_sounds";
|
var PLAY_NOTIFICATION_SOUNDS_SETTING = "play_notification_sounds";
|
||||||
var PLAY_NOTIFICATION_SOUNDS_TYPE_SETTING_PRE = "play_notification_sounds_type_";
|
var PLAY_NOTIFICATION_SOUNDS_TYPE_SETTING_PRE = "play_notification_sounds_type_";
|
||||||
|
var lodTextID = false;
|
||||||
|
|
||||||
var NotificationType = {
|
var NotificationType = {
|
||||||
UNKNOWN: 0,
|
UNKNOWN: 0,
|
||||||
MUTE_TOGGLE: 1,
|
MUTE_TOGGLE: 1,
|
||||||
SNAPSHOT: 2,
|
SNAPSHOT: 2,
|
||||||
WINDOW_RESIZE: 3,
|
WINDOW_RESIZE: 3,
|
||||||
|
LOD_WARNING: 4,
|
||||||
properties: [
|
properties: [
|
||||||
{ text: "Mute Toggle" },
|
{ text: "Mute Toggle" },
|
||||||
{ text: "Snapshot" },
|
{ text: "Snapshot" },
|
||||||
{ text: "Window Resize" }
|
{ text: "Window Resize" },
|
||||||
|
{ text: "Level of Detail" }
|
||||||
],
|
],
|
||||||
getTypeFromMenuItem: function(menuItemName) {
|
getTypeFromMenuItem: function(menuItemName) {
|
||||||
if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) {
|
if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) {
|
||||||
|
@ -143,6 +145,10 @@ function createArrays(notice, button, createTime, height, myAlpha) {
|
||||||
|
|
||||||
// This handles the final dismissal of a notification after fading
|
// This handles the final dismissal of a notification after fading
|
||||||
function dismiss(firstNoteOut, firstButOut, firstOut) {
|
function dismiss(firstNoteOut, firstButOut, firstOut) {
|
||||||
|
if (firstNoteOut == lodTextID) {
|
||||||
|
lodTextID = false;
|
||||||
|
}
|
||||||
|
|
||||||
Overlays.deleteOverlay(firstNoteOut);
|
Overlays.deleteOverlay(firstNoteOut);
|
||||||
Overlays.deleteOverlay(firstButOut);
|
Overlays.deleteOverlay(firstButOut);
|
||||||
notifications.splice(firstOut, 1);
|
notifications.splice(firstOut, 1);
|
||||||
|
@ -261,7 +267,8 @@ function notify(notice, button, height) {
|
||||||
height: noticeHeight
|
height: noticeHeight
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
notifications.push((Overlays.addOverlay("text", notice)));
|
var notificationText = Overlays.addOverlay("text", notice);
|
||||||
|
notifications.push((notificationText));
|
||||||
buttons.push((Overlays.addOverlay("image", button)));
|
buttons.push((Overlays.addOverlay("image", button)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,6 +279,7 @@ function notify(notice, button, height) {
|
||||||
last = notifications.length - 1;
|
last = notifications.length - 1;
|
||||||
createArrays(notifications[last], buttons[last], times[last], heights[last], myAlpha[last]);
|
createArrays(notifications[last], buttons[last], times[last], heights[last], myAlpha[last]);
|
||||||
fadeIn(notifications[last], buttons[last]);
|
fadeIn(notifications[last], buttons[last]);
|
||||||
|
return notificationText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function creates and sizes the overlays
|
// This function creates and sizes the overlays
|
||||||
|
@ -331,11 +339,15 @@ function createNotification(text, notificationType) {
|
||||||
randomSounds.playRandom();
|
randomSounds.playRandom();
|
||||||
}
|
}
|
||||||
|
|
||||||
notify(noticeProperties, buttonProperties, height);
|
return notify(noticeProperties, buttonProperties, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteNotification(index) {
|
function deleteNotification(index) {
|
||||||
Overlays.deleteOverlay(notifications[index]);
|
var notificationTextID = notifications[index];
|
||||||
|
if (notificationTextID == lodTextID) {
|
||||||
|
lodTextID = false;
|
||||||
|
}
|
||||||
|
Overlays.deleteOverlay(notificationTextID);
|
||||||
Overlays.deleteOverlay(buttons[index]);
|
Overlays.deleteOverlay(buttons[index]);
|
||||||
notifications.splice(index, 1);
|
notifications.splice(index, 1);
|
||||||
buttons.splice(index, 1);
|
buttons.splice(index, 1);
|
||||||
|
@ -575,6 +587,20 @@ function menuItemEvent(menuItem) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LODManager.LODDecreased.connect(function() {
|
||||||
|
var warningText = "\n"
|
||||||
|
+ "Due to the complexity of the content, the \n"
|
||||||
|
+ "level of detail has been decreased."
|
||||||
|
+ "You can now see: \n"
|
||||||
|
+ LODManager.getLODFeedbackText();
|
||||||
|
|
||||||
|
if (lodTextID == false) {
|
||||||
|
lodTextID = createNotification(warningText, NotificationType.LOD_WARNING);
|
||||||
|
} else {
|
||||||
|
Overlays.editOverlay(lodTextID, { text: warningText });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
AudioDevice.muteToggled.connect(onMuteStateChanged);
|
AudioDevice.muteToggled.connect(onMuteStateChanged);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
Controller.mousePressEvent.connect(mousePressEvent);
|
Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
// LODWarning.js
|
|
||||||
// examples
|
|
||||||
//
|
|
||||||
// Created by Brad Hefta-Gaub on 3/17/15.
|
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// This script will display a warning when the LOD is adjusted to do scene complexity.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
var DISPLAY_WARNING_FOR = 3; // in seconds
|
|
||||||
var DISTANCE_FROM_CAMERA = 2;
|
|
||||||
var SHOW_LOD_UP_MESSAGE = false; // By default we only display the LOD message when reducing LOD
|
|
||||||
|
|
||||||
|
|
||||||
var warningIsVisible = false; // initially the warning is hidden
|
|
||||||
var warningShownAt = 0;
|
|
||||||
var billboardPosition = Vec3.sum(Camera.getPosition(),
|
|
||||||
Vec3.multiply(DISTANCE_FROM_CAMERA, Quat.getFront(Camera.getOrientation())));
|
|
||||||
|
|
||||||
var warningOverlay = Overlays.addOverlay("text3d", {
|
|
||||||
position: billboardPosition,
|
|
||||||
dimensions: { x: 2, y: 1.25 },
|
|
||||||
width: 2,
|
|
||||||
height: 1.25,
|
|
||||||
backgroundColor: { red: 0, green: 0, blue: 0 },
|
|
||||||
color: { red: 255, green: 255, blue: 255},
|
|
||||||
topMargin: 0.1,
|
|
||||||
leftMargin: 0.1,
|
|
||||||
lineHeight: 0.07,
|
|
||||||
text: "",
|
|
||||||
alpha: 0.5,
|
|
||||||
backgroundAlpha: 0.7,
|
|
||||||
isFacingAvatar: true,
|
|
||||||
visible: warningIsVisible,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle moving the billboard to remain in front of the camera
|
|
||||||
var billboardNeedsMoving = false;
|
|
||||||
Script.update.connect(function() {
|
|
||||||
|
|
||||||
if (warningIsVisible) {
|
|
||||||
var bestBillboardPosition = Vec3.sum(Camera.getPosition(),
|
|
||||||
Vec3.multiply(DISTANCE_FROM_CAMERA, Quat.getFront(Camera.getOrientation())));
|
|
||||||
|
|
||||||
var MAX_DISTANCE = 0.5;
|
|
||||||
var CLOSE_ENOUGH = 0.01;
|
|
||||||
if (!billboardNeedsMoving && Vec3.distance(bestBillboardPosition, billboardPosition) > MAX_DISTANCE) {
|
|
||||||
billboardNeedsMoving = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (billboardNeedsMoving && Vec3.distance(bestBillboardPosition, billboardPosition) <= CLOSE_ENOUGH) {
|
|
||||||
billboardNeedsMoving = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (billboardNeedsMoving) {
|
|
||||||
// slurp the billboard to the best location
|
|
||||||
moveVector = Vec3.multiply(0.05, Vec3.subtract(bestBillboardPosition, billboardPosition));
|
|
||||||
billboardPosition = Vec3.sum(billboardPosition, moveVector);
|
|
||||||
Overlays.editOverlay(warningOverlay, { position: billboardPosition });
|
|
||||||
}
|
|
||||||
|
|
||||||
var now = new Date();
|
|
||||||
var sinceWarningShown = now - warningShownAt;
|
|
||||||
if (sinceWarningShown > 1000 * DISPLAY_WARNING_FOR) {
|
|
||||||
warningIsVisible = false;
|
|
||||||
Overlays.editOverlay(warningOverlay, { visible: warningIsVisible });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LODManager.LODIncreased.connect(function() {
|
|
||||||
if (SHOW_LOD_UP_MESSAGE) {
|
|
||||||
// if the warning wasn't visible, then move it before showing it.
|
|
||||||
if (!warningIsVisible) {
|
|
||||||
billboardPosition = Vec3.sum(Camera.getPosition(),
|
|
||||||
Vec3.multiply(DISTANCE_FROM_CAMERA, Quat.getFront(Camera.getOrientation())));
|
|
||||||
Overlays.editOverlay(warningOverlay, { position: billboardPosition });
|
|
||||||
}
|
|
||||||
|
|
||||||
warningShownAt = new Date();
|
|
||||||
warningIsVisible = true;
|
|
||||||
warningText = "Level of detail has been increased. \n"
|
|
||||||
+ "You can now see: \n"
|
|
||||||
+ LODManager.getLODFeedbackText();
|
|
||||||
|
|
||||||
Overlays.editOverlay(warningOverlay, { visible: warningIsVisible, text: warningText });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LODManager.LODDecreased.connect(function() {
|
|
||||||
// if the warning wasn't visible, then move it before showing it.
|
|
||||||
if (!warningIsVisible) {
|
|
||||||
billboardPosition = Vec3.sum(Camera.getPosition(),
|
|
||||||
Vec3.multiply(DISTANCE_FROM_CAMERA, Quat.getFront(Camera.getOrientation())));
|
|
||||||
Overlays.editOverlay(warningOverlay, { position: billboardPosition });
|
|
||||||
}
|
|
||||||
|
|
||||||
warningShownAt = new Date();
|
|
||||||
warningIsVisible = true;
|
|
||||||
warningText = "\n"
|
|
||||||
+ "Due to the complexity of the content, the \n"
|
|
||||||
+ "level of detail has been decreased. \n"
|
|
||||||
+ "You can now see: \n"
|
|
||||||
+ LODManager.getLODFeedbackText();
|
|
||||||
|
|
||||||
Overlays.editOverlay(warningOverlay, { visible: warningIsVisible, text: warningText });
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Script.scriptEnding.connect(function() {
|
|
||||||
Overlays.deleteOverlay(warningOverlay);
|
|
||||||
});
|
|
2058
interface/resources/html/edit-commands.html
Normal file
2058
interface/resources/html/edit-commands.html
Normal file
File diff suppressed because it is too large
Load diff
After Width: | Height: | Size: 197 KiB |
File diff suppressed because it is too large
Load diff
Before Width: | Height: | Size: 193 KiB |
|
@ -1790,6 +1790,7 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
|
||||||
void Application::loadSettings() {
|
void Application::loadSettings() {
|
||||||
|
|
||||||
DependencyManager::get<AudioClient>()->loadSettings();
|
DependencyManager::get<AudioClient>()->loadSettings();
|
||||||
|
DependencyManager::get<LODManager>()->loadSettings();
|
||||||
|
|
||||||
Menu::getInstance()->loadSettings();
|
Menu::getInstance()->loadSettings();
|
||||||
_myAvatar->loadData();
|
_myAvatar->loadData();
|
||||||
|
@ -1797,6 +1798,7 @@ void Application::loadSettings() {
|
||||||
|
|
||||||
void Application::saveSettings() {
|
void Application::saveSettings() {
|
||||||
DependencyManager::get<AudioClient>()->saveSettings();
|
DependencyManager::get<AudioClient>()->saveSettings();
|
||||||
|
DependencyManager::get<LODManager>()->saveSettings();
|
||||||
|
|
||||||
Menu::getInstance()->saveSettings();
|
Menu::getInstance()->saveSettings();
|
||||||
_myAvatar->saveData();
|
_myAvatar->saveData();
|
||||||
|
|
|
@ -113,7 +113,7 @@ static const float MIRROR_FIELD_OF_VIEW = 30.0f;
|
||||||
static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND;
|
static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND;
|
||||||
|
|
||||||
static const QString INFO_HELP_PATH = "html/interface-welcome.html";
|
static const QString INFO_HELP_PATH = "html/interface-welcome.html";
|
||||||
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
|
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html";
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static const UINT UWM_IDENTIFY_INSTANCES =
|
static const UINT UWM_IDENTIFY_INSTANCES =
|
||||||
|
|
|
@ -17,18 +17,12 @@
|
||||||
|
|
||||||
#include "LODManager.h"
|
#include "LODManager.h"
|
||||||
|
|
||||||
Setting::Handle<bool> automaticLODAdjust("automaticLODAdjust", true);
|
|
||||||
Setting::Handle<float> desktopLODDecreaseFPS("desktopLODDecreaseFPS", DEFAULT_DESKTOP_LOD_DOWN_FPS);
|
Setting::Handle<float> desktopLODDecreaseFPS("desktopLODDecreaseFPS", DEFAULT_DESKTOP_LOD_DOWN_FPS);
|
||||||
Setting::Handle<float> desktopLODIncreaseFPS("desktopLODIncreaseFPS", DEFAULT_DESKTOP_LOD_UP_FPS);
|
|
||||||
Setting::Handle<float> hmdLODDecreaseFPS("hmdLODDecreaseFPS", DEFAULT_HMD_LOD_DOWN_FPS);
|
Setting::Handle<float> hmdLODDecreaseFPS("hmdLODDecreaseFPS", DEFAULT_HMD_LOD_DOWN_FPS);
|
||||||
Setting::Handle<float> hmdLODIncreaseFPS("hmdLODIncreaseFPS", DEFAULT_HMD_LOD_UP_FPS);
|
|
||||||
|
|
||||||
|
|
||||||
Setting::Handle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
|
||||||
DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER);
|
|
||||||
Setting::Handle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
|
||||||
Setting::Handle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
|
||||||
|
|
||||||
|
LODManager::LODManager() {
|
||||||
|
calculateAvatarLODDistanceMultiplier();
|
||||||
|
}
|
||||||
|
|
||||||
float LODManager::getLODDecreaseFPS() {
|
float LODManager::getLODDecreaseFPS() {
|
||||||
if (Application::getInstance()->isHMDMode()) {
|
if (Application::getInstance()->isHMDMode()) {
|
||||||
|
@ -67,21 +61,6 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
// LOD Downward adjustment
|
// LOD Downward adjustment
|
||||||
if (elapsed > ADJUST_LOD_DOWN_DELAY && _fpsAverage.getAverage() < getLODDecreaseFPS()) {
|
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
|
// Octree items... stepwise adjustment
|
||||||
if (_octreeSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) {
|
if (_octreeSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) {
|
||||||
_octreeSizeScale *= ADJUST_LOD_DOWN_BY;
|
_octreeSizeScale *= ADJUST_LOD_DOWN_BY;
|
||||||
|
@ -103,20 +82,6 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
// LOD Upward adjustment
|
// LOD Upward adjustment
|
||||||
if (elapsed > ADJUST_LOD_UP_DELAY && _fpsAverage.getAverage() > getLODIncreaseFPS()) {
|
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
|
// Octee items... stepwise adjustment
|
||||||
if (_octreeSizeScale < ADJUST_LOD_MAX_SIZE_SCALE) {
|
if (_octreeSizeScale < ADJUST_LOD_MAX_SIZE_SCALE) {
|
||||||
if (_octreeSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) {
|
if (_octreeSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) {
|
||||||
|
@ -140,6 +105,7 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
calculateAvatarLODDistanceMultiplier();
|
||||||
_shouldRenderTableNeedsRebuilding = true;
|
_shouldRenderTableNeedsRebuilding = true;
|
||||||
auto lodToolsDialog = DependencyManager::get<DialogsManager>()->getLodToolsDialog();
|
auto lodToolsDialog = DependencyManager::get<DialogsManager>()->getLodToolsDialog();
|
||||||
if (lodToolsDialog) {
|
if (lodToolsDialog) {
|
||||||
|
@ -234,9 +200,14 @@ bool LODManager::shouldRenderMesh(float largestDimension, float distanceToCamera
|
||||||
|
|
||||||
void LODManager::setOctreeSizeScale(float sizeScale) {
|
void LODManager::setOctreeSizeScale(float sizeScale) {
|
||||||
_octreeSizeScale = sizeScale;
|
_octreeSizeScale = sizeScale;
|
||||||
|
calculateAvatarLODDistanceMultiplier();
|
||||||
_shouldRenderTableNeedsRebuilding = true;
|
_shouldRenderTableNeedsRebuilding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LODManager::calculateAvatarLODDistanceMultiplier() {
|
||||||
|
_avatarLODDistanceMultiplier = AVATAR_TO_ENTITY_RATIO / (_octreeSizeScale / DEFAULT_OCTREE_SIZE_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
||||||
_boundaryLevelAdjust = boundaryLevelAdjust;
|
_boundaryLevelAdjust = boundaryLevelAdjust;
|
||||||
_shouldRenderTableNeedsRebuilding = true;
|
_shouldRenderTableNeedsRebuilding = true;
|
||||||
|
@ -244,27 +215,13 @@ void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
||||||
|
|
||||||
|
|
||||||
void LODManager::loadSettings() {
|
void LODManager::loadSettings() {
|
||||||
setAutomaticLODAdjust(automaticLODAdjust.get());
|
|
||||||
setDesktopLODDecreaseFPS(desktopLODDecreaseFPS.get());
|
setDesktopLODDecreaseFPS(desktopLODDecreaseFPS.get());
|
||||||
setDesktopLODIncreaseFPS(desktopLODIncreaseFPS.get());
|
|
||||||
setHMDLODDecreaseFPS(hmdLODDecreaseFPS.get());
|
setHMDLODDecreaseFPS(hmdLODDecreaseFPS.get());
|
||||||
setHMDLODIncreaseFPS(hmdLODIncreaseFPS.get());
|
|
||||||
|
|
||||||
setAvatarLODDistanceMultiplier(avatarLODDistanceMultiplier.get());
|
|
||||||
setBoundaryLevelAdjust(boundaryLevelAdjust.get());
|
|
||||||
setOctreeSizeScale(octreeSizeScale.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LODManager::saveSettings() {
|
void LODManager::saveSettings() {
|
||||||
automaticLODAdjust.set(getAutomaticLODAdjust());
|
|
||||||
desktopLODDecreaseFPS.set(getDesktopLODDecreaseFPS());
|
desktopLODDecreaseFPS.set(getDesktopLODDecreaseFPS());
|
||||||
desktopLODIncreaseFPS.set(getDesktopLODIncreaseFPS());
|
|
||||||
hmdLODDecreaseFPS.set(getHMDLODDecreaseFPS());
|
hmdLODDecreaseFPS.set(getHMDLODDecreaseFPS());
|
||||||
hmdLODIncreaseFPS.set(getHMDLODIncreaseFPS());
|
|
||||||
|
|
||||||
avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
|
||||||
boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
|
||||||
octreeSizeScale.set(getOctreeSizeScale());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,8 @@
|
||||||
#include <SimpleMovingAverage.h>
|
#include <SimpleMovingAverage.h>
|
||||||
|
|
||||||
const float DEFAULT_DESKTOP_LOD_DOWN_FPS = 30.0;
|
const float DEFAULT_DESKTOP_LOD_DOWN_FPS = 30.0;
|
||||||
const float DEFAULT_DESKTOP_LOD_UP_FPS = 50.0;
|
|
||||||
const float DEFAULT_HMD_LOD_DOWN_FPS = 60.0;
|
const float DEFAULT_HMD_LOD_DOWN_FPS = 60.0;
|
||||||
const float DEFAULT_HMD_LOD_UP_FPS = 65.0;
|
const float INCREASE_LOD_GAP = 5.0f;
|
||||||
|
|
||||||
const quint64 ADJUST_LOD_DOWN_DELAY = 1000 * 1000 * 0.5; // Consider adjusting LOD down after half a second
|
const quint64 ADJUST_LOD_DOWN_DELAY = 1000 * 1000 * 0.5; // Consider adjusting LOD down after half a second
|
||||||
const quint64 ADJUST_LOD_UP_DELAY = ADJUST_LOD_DOWN_DELAY * 2;
|
const quint64 ADJUST_LOD_UP_DELAY = ADJUST_LOD_DOWN_DELAY * 2;
|
||||||
|
@ -34,10 +33,9 @@ const float ADJUST_LOD_UP_BY = 1.1f;
|
||||||
const float ADJUST_LOD_MIN_SIZE_SCALE = 1.0f;
|
const float ADJUST_LOD_MIN_SIZE_SCALE = 1.0f;
|
||||||
const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE;
|
const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE;
|
||||||
|
|
||||||
const float MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 0.1f;
|
// The ratio of "visibility" of avatars to other content. A value larger than 1 will mean Avatars "cull" later than entities
|
||||||
const float MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 15.0f;
|
// do. But both are still culled using the same angular size logic.
|
||||||
const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f;
|
const float AVATAR_TO_ENTITY_RATIO = 2.0f;
|
||||||
const float MAXIMUM_AUTO_ADJUST_AVATAR_LOD_DISTANCE_MULTIPLIER = DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER;
|
|
||||||
|
|
||||||
const int ONE_SECOND_OF_FRAMES = 60;
|
const int ONE_SECOND_OF_FRAMES = 60;
|
||||||
const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES;
|
const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES;
|
||||||
|
@ -53,15 +51,12 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void setDesktopLODDecreaseFPS(float value) { _desktopLODDecreaseFPS = value; }
|
Q_INVOKABLE void setDesktopLODDecreaseFPS(float value) { _desktopLODDecreaseFPS = value; }
|
||||||
Q_INVOKABLE float getDesktopLODDecreaseFPS() const { return _desktopLODDecreaseFPS; }
|
Q_INVOKABLE float getDesktopLODDecreaseFPS() const { return _desktopLODDecreaseFPS; }
|
||||||
Q_INVOKABLE void setDesktopLODIncreaseFPS(float value) { _desktopLODIncreaseFPS = value; }
|
Q_INVOKABLE float getDesktopLODIncreaseFPS() const { return _desktopLODDecreaseFPS + INCREASE_LOD_GAP; }
|
||||||
Q_INVOKABLE float getDesktopLODIncreaseFPS() const { return _desktopLODIncreaseFPS; }
|
|
||||||
|
|
||||||
Q_INVOKABLE void setHMDLODDecreaseFPS(float value) { _hmdLODDecreaseFPS = value; }
|
Q_INVOKABLE void setHMDLODDecreaseFPS(float value) { _hmdLODDecreaseFPS = value; }
|
||||||
Q_INVOKABLE float getHMDLODDecreaseFPS() const { return _hmdLODDecreaseFPS; }
|
Q_INVOKABLE float getHMDLODDecreaseFPS() const { return _hmdLODDecreaseFPS; }
|
||||||
Q_INVOKABLE void setHMDLODIncreaseFPS(float value) { _hmdLODIncreaseFPS = value; }
|
Q_INVOKABLE float getHMDLODIncreaseFPS() const { return _hmdLODDecreaseFPS + INCREASE_LOD_GAP; }
|
||||||
Q_INVOKABLE float getHMDLODIncreaseFPS() const { return _hmdLODIncreaseFPS; }
|
|
||||||
|
|
||||||
Q_INVOKABLE void setAvatarLODDistanceMultiplier(float multiplier) { _avatarLODDistanceMultiplier = multiplier; }
|
|
||||||
Q_INVOKABLE float getAvatarLODDistanceMultiplier() const { return _avatarLODDistanceMultiplier; }
|
Q_INVOKABLE float getAvatarLODDistanceMultiplier() const { return _avatarLODDistanceMultiplier; }
|
||||||
|
|
||||||
// User Tweakable LOD Items
|
// User Tweakable LOD Items
|
||||||
|
@ -90,16 +85,14 @@ signals:
|
||||||
void LODDecreased();
|
void LODDecreased();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LODManager() {}
|
LODManager();
|
||||||
|
void calculateAvatarLODDistanceMultiplier();
|
||||||
|
|
||||||
bool _automaticLODAdjust = true;
|
bool _automaticLODAdjust = true;
|
||||||
float _desktopLODDecreaseFPS = DEFAULT_DESKTOP_LOD_DOWN_FPS;
|
float _desktopLODDecreaseFPS = DEFAULT_DESKTOP_LOD_DOWN_FPS;
|
||||||
float _desktopLODIncreaseFPS = DEFAULT_DESKTOP_LOD_UP_FPS;
|
|
||||||
float _hmdLODDecreaseFPS = DEFAULT_HMD_LOD_DOWN_FPS;
|
float _hmdLODDecreaseFPS = DEFAULT_HMD_LOD_DOWN_FPS;
|
||||||
float _hmdLODIncreaseFPS = DEFAULT_HMD_LOD_UP_FPS;
|
|
||||||
|
|
||||||
float _avatarLODDistanceMultiplier = DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER;
|
float _avatarLODDistanceMultiplier;
|
||||||
|
|
||||||
float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE;
|
float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE;
|
||||||
int _boundaryLevelAdjust = 0;
|
int _boundaryLevelAdjust = 0;
|
||||||
|
|
||||||
|
|
|
@ -46,37 +46,10 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
||||||
_feedback->setFixedWidth(FEEDBACK_WIDTH);
|
_feedback->setFixedWidth(FEEDBACK_WIDTH);
|
||||||
form->addRow("You can see... ", _feedback);
|
form->addRow("You can see... ", _feedback);
|
||||||
|
|
||||||
form->addRow("Automatic LOD Adjustment:", _automaticLODAdjust = new QCheckBox(this));
|
form->addRow("Manually Adjust Level of Detail:", _manualLODAdjust = new QCheckBox(this));
|
||||||
_automaticLODAdjust->setChecked(lodManager->getAutomaticLODAdjust());
|
_manualLODAdjust->setChecked(!lodManager->getAutomaticLODAdjust());
|
||||||
connect(_automaticLODAdjust, SIGNAL(toggled(bool)), SLOT(updateAutomaticLODAdjust()));
|
connect(_manualLODAdjust, SIGNAL(toggled(bool)), SLOT(updateAutomaticLODAdjust()));
|
||||||
|
|
||||||
form->addRow("Desktop Decrease LOD Below FPS:", _desktopLODDecreaseFPS = new QDoubleSpinBox(this));
|
|
||||||
_desktopLODDecreaseFPS->setValue(lodManager->getDesktopLODDecreaseFPS());
|
|
||||||
_desktopLODDecreaseFPS->setDecimals(0);
|
|
||||||
connect(_desktopLODDecreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateLODValues()));
|
|
||||||
|
|
||||||
form->addRow("Desktop Increase LOD Above FPS:", _desktopLODIncreaseFPS = new QDoubleSpinBox(this));
|
|
||||||
_desktopLODIncreaseFPS->setValue(lodManager->getDesktopLODIncreaseFPS());
|
|
||||||
_desktopLODIncreaseFPS->setDecimals(0);
|
|
||||||
connect(_desktopLODIncreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateLODValues()));
|
|
||||||
|
|
||||||
form->addRow("HMD Decrease LOD Below FPS:", _hmdLODDecreaseFPS = new QDoubleSpinBox(this));
|
|
||||||
_hmdLODDecreaseFPS->setValue(lodManager->getHMDLODDecreaseFPS());
|
|
||||||
_hmdLODDecreaseFPS->setDecimals(0);
|
|
||||||
connect(_hmdLODDecreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateLODValues()));
|
|
||||||
|
|
||||||
form->addRow("HMD Increase LOD Above FPS:", _hmdLODIncreaseFPS = new QDoubleSpinBox(this));
|
|
||||||
_hmdLODIncreaseFPS->setValue(lodManager->getHMDLODIncreaseFPS());
|
|
||||||
_hmdLODIncreaseFPS->setDecimals(0);
|
|
||||||
connect(_hmdLODIncreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateLODValues()));
|
|
||||||
|
|
||||||
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);
|
_lodSize = new QSlider(Qt::Horizontal, this);
|
||||||
const int MAX_LOD_SIZE = MAX_LOD_SIZE_MULTIPLIER;
|
const int MAX_LOD_SIZE = MAX_LOD_SIZE_MULTIPLIER;
|
||||||
const int MIN_LOD_SIZE = ADJUST_LOD_MIN_SIZE_SCALE;
|
const int MIN_LOD_SIZE = ADJUST_LOD_MIN_SIZE_SCALE;
|
||||||
|
@ -92,7 +65,7 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
||||||
_lodSize->setPageStep(PAGE_STEP_LOD_SIZE);
|
_lodSize->setPageStep(PAGE_STEP_LOD_SIZE);
|
||||||
int sliderValue = lodManager->getOctreeSizeScale() / TREE_SCALE;
|
int sliderValue = lodManager->getOctreeSizeScale() / TREE_SCALE;
|
||||||
_lodSize->setValue(sliderValue);
|
_lodSize->setValue(sliderValue);
|
||||||
form->addRow("Non-Avatar Content LOD:", _lodSize);
|
form->addRow("Level of Detail:", _lodSize);
|
||||||
connect(_lodSize,SIGNAL(valueChanged(int)),this,SLOT(sizeScaleValueChanged(int)));
|
connect(_lodSize,SIGNAL(valueChanged(int)),this,SLOT(sizeScaleValueChanged(int)));
|
||||||
|
|
||||||
// Add a button to reset
|
// Add a button to reset
|
||||||
|
@ -109,27 +82,12 @@ void LodToolsDialog::reloadSliders() {
|
||||||
auto lodManager = DependencyManager::get<LODManager>();
|
auto lodManager = DependencyManager::get<LODManager>();
|
||||||
_lodSize->setValue(lodManager->getOctreeSizeScale() / TREE_SCALE);
|
_lodSize->setValue(lodManager->getOctreeSizeScale() / TREE_SCALE);
|
||||||
_feedback->setText(lodManager->getLODFeedbackText());
|
_feedback->setText(lodManager->getLODFeedbackText());
|
||||||
|
|
||||||
_avatarLOD->setValue(1.0 / lodManager->getAvatarLODDistanceMultiplier());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LodToolsDialog::updateAutomaticLODAdjust() {
|
void LodToolsDialog::updateAutomaticLODAdjust() {
|
||||||
auto lodManager = DependencyManager::get<LODManager>();
|
auto lodManager = DependencyManager::get<LODManager>();
|
||||||
lodManager->setAutomaticLODAdjust(_automaticLODAdjust->isChecked());
|
lodManager->setAutomaticLODAdjust(!_manualLODAdjust->isChecked());
|
||||||
}
|
_lodSize->setEnabled(_manualLODAdjust->isChecked());
|
||||||
|
|
||||||
void LodToolsDialog::updateLODValues() {
|
|
||||||
auto lodManager = DependencyManager::get<LODManager>();
|
|
||||||
|
|
||||||
lodManager->setAutomaticLODAdjust(_automaticLODAdjust->isChecked());
|
|
||||||
|
|
||||||
lodManager->setDesktopLODDecreaseFPS(_desktopLODDecreaseFPS->value());
|
|
||||||
lodManager->setDesktopLODIncreaseFPS(_desktopLODIncreaseFPS->value());
|
|
||||||
lodManager->setHMDLODDecreaseFPS(_hmdLODDecreaseFPS->value());
|
|
||||||
lodManager->setHMDLODIncreaseFPS(_hmdLODIncreaseFPS->value());
|
|
||||||
|
|
||||||
lodManager->setAvatarLODDistanceMultiplier(1.0 / _avatarLOD->value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LodToolsDialog::sizeScaleValueChanged(int value) {
|
void LodToolsDialog::sizeScaleValueChanged(int value) {
|
||||||
|
@ -144,15 +102,9 @@ void LodToolsDialog::resetClicked(bool checked) {
|
||||||
|
|
||||||
int sliderValue = DEFAULT_OCTREE_SIZE_SCALE / TREE_SCALE;
|
int sliderValue = DEFAULT_OCTREE_SIZE_SCALE / TREE_SCALE;
|
||||||
_lodSize->setValue(sliderValue);
|
_lodSize->setValue(sliderValue);
|
||||||
_automaticLODAdjust->setChecked(true);
|
_manualLODAdjust->setChecked(false);
|
||||||
_desktopLODDecreaseFPS->setValue(DEFAULT_DESKTOP_LOD_DOWN_FPS);
|
|
||||||
_desktopLODIncreaseFPS->setValue(DEFAULT_DESKTOP_LOD_UP_FPS);
|
|
||||||
_hmdLODDecreaseFPS->setValue(DEFAULT_HMD_LOD_DOWN_FPS);
|
|
||||||
_hmdLODIncreaseFPS->setValue(DEFAULT_HMD_LOD_UP_FPS);
|
|
||||||
|
|
||||||
_avatarLOD->setValue(1.0 / DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER);
|
|
||||||
|
|
||||||
updateLODValues(); // tell our LOD manager about the reset
|
updateAutomaticLODAdjust(); // tell our LOD manager about the reset
|
||||||
}
|
}
|
||||||
|
|
||||||
void LodToolsDialog::reject() {
|
void LodToolsDialog::reject() {
|
||||||
|
@ -163,6 +115,15 @@ void LodToolsDialog::reject() {
|
||||||
void LodToolsDialog::closeEvent(QCloseEvent* event) {
|
void LodToolsDialog::closeEvent(QCloseEvent* event) {
|
||||||
this->QDialog::closeEvent(event);
|
this->QDialog::closeEvent(event);
|
||||||
emit closed();
|
emit closed();
|
||||||
|
auto lodManager = DependencyManager::get<LODManager>();
|
||||||
|
|
||||||
|
// always revert back to automatic LOD adjustment when closed
|
||||||
|
lodManager->setAutomaticLODAdjust(true);
|
||||||
|
|
||||||
|
// if the user adjusted the LOD above "normal" then always revert back to default
|
||||||
|
if (lodManager->getOctreeSizeScale() > DEFAULT_OCTREE_SIZE_SCALE) {
|
||||||
|
lodManager->setOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ public slots:
|
||||||
void resetClicked(bool checked);
|
void resetClicked(bool checked);
|
||||||
void reloadSliders();
|
void reloadSliders();
|
||||||
void updateAutomaticLODAdjust();
|
void updateAutomaticLODAdjust();
|
||||||
void updateLODValues();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -44,16 +43,12 @@ protected:
|
||||||
private:
|
private:
|
||||||
QSlider* _lodSize;
|
QSlider* _lodSize;
|
||||||
|
|
||||||
QCheckBox* _automaticLODAdjust;
|
QCheckBox* _manualLODAdjust;
|
||||||
|
|
||||||
QDoubleSpinBox* _desktopLODDecreaseFPS;
|
QDoubleSpinBox* _desktopLODDecreaseFPS;
|
||||||
QDoubleSpinBox* _desktopLODIncreaseFPS;
|
|
||||||
|
|
||||||
QDoubleSpinBox* _hmdLODDecreaseFPS;
|
QDoubleSpinBox* _hmdLODDecreaseFPS;
|
||||||
QDoubleSpinBox* _hmdLODIncreaseFPS;
|
|
||||||
|
|
||||||
|
|
||||||
QDoubleSpinBox* _avatarLOD;
|
|
||||||
QLabel* _feedback;
|
QLabel* _feedback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include "LODManager.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "ModelsBrowser.h"
|
#include "ModelsBrowser.h"
|
||||||
#include "PreferencesDialog.h"
|
#include "PreferencesDialog.h"
|
||||||
|
@ -174,6 +175,10 @@ void PreferencesDialog::loadPreferences() {
|
||||||
ui.sixenseReticleMoveSpeedSpin->setValue(sixense.getReticleMoveSpeed());
|
ui.sixenseReticleMoveSpeedSpin->setValue(sixense.getReticleMoveSpeed());
|
||||||
ui.invertSixenseButtonsCheckBox->setChecked(sixense.getInvertButtons());
|
ui.invertSixenseButtonsCheckBox->setChecked(sixense.getInvertButtons());
|
||||||
|
|
||||||
|
// LOD items
|
||||||
|
auto lodManager = DependencyManager::get<LODManager>();
|
||||||
|
ui.desktopMinimumFPSSpin->setValue(lodManager->getDesktopLODDecreaseFPS());
|
||||||
|
ui.hmdMinimumFPSSpin->setValue(lodManager->getHMDLODDecreaseFPS());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::savePreferences() {
|
void PreferencesDialog::savePreferences() {
|
||||||
|
@ -275,4 +280,9 @@ void PreferencesDialog::savePreferences() {
|
||||||
audio->setOutputStarveDetectionPeriod(ui.outputStarveDetectionPeriodSpinner->value());
|
audio->setOutputStarveDetectionPeriod(ui.outputStarveDetectionPeriodSpinner->value());
|
||||||
|
|
||||||
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||||
|
|
||||||
|
// LOD items
|
||||||
|
auto lodManager = DependencyManager::get<LODManager>();
|
||||||
|
lodManager->setDesktopLODDecreaseFPS(ui.desktopMinimumFPSSpin->value());
|
||||||
|
lodManager->setHMDLODDecreaseFPS(ui.hmdMinimumFPSSpin->value());
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,6 +701,219 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_10">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="levelOfDetailTitleLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
<pointsize>18</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">color:#29967e</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Level of Detail Tuning</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_111x">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_9x">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Minimum Desktop FPS</string>
|
||||||
|
</property>
|
||||||
|
<property name="indent">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<!--
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>fieldOfViewSpin</cstring>
|
||||||
|
</property>
|
||||||
|
-->
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_111x">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="desktopMinimumFPSSpin">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>95</width>
|
||||||
|
<height>36</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>120</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_111y">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_9y">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Minimum HMD FPS</string>
|
||||||
|
</property>
|
||||||
|
<property name="indent">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<!--
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>fieldOfViewSpin</cstring>
|
||||||
|
</property>
|
||||||
|
-->
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_111y">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="hmdMinimumFPSSpin">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>95</width>
|
||||||
|
<height>36</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>120</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_8">
|
<spacer name="verticalSpacer_8">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -717,6 +930,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="avatarTitleLabel">
|
<widget class="QLabel" name="avatarTitleLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
@ -738,6 +952,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_111">
|
<layout class="QHBoxLayout" name="horizontalLayout_111">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
@ -820,6 +1035,9 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
|
Loading…
Reference in a new issue