Make the LOD half angle the definitive LOD variable

This commit is contained in:
sabrina-shanman 2019-08-07 17:23:04 -07:00
parent 0d5260bccc
commit 9c16fcfdef
4 changed files with 22 additions and 7 deletions

View file

@ -12,7 +12,6 @@
#include "LODManager.h"
#include <SettingHandle.h>
#include <OctreeUtils.h>
#include <Util.h>
#include <shared/GlobalAppProperties.h>
@ -165,7 +164,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
// And now add the output of the controller to the LODAngle where we will guarantee it is in the proper range
setLODAngleDeg(oldLODAngle + output);
if (oldVisibilityDistance != _visibilityDistance) {
if (oldLODAngle != getLODAngleDeg()) {
auto lodToolsDialog = DependencyManager::get<DialogsManager>()->getLodToolsDialog();
if (lodToolsDialog) {
lodToolsDialog->reloadSliders();
@ -174,22 +173,26 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
}
float LODManager::getLODHalfAngleTan() const {
return getPerspectiveAccuracyHalfAngleTan(_visibilityDistance, _boundaryLevelAdjust);
return tan(_lodHalfAngle);
}
float LODManager::getLODAngle() const {
return 2.0f * atanf(getLODHalfAngleTan());
return 2.0f * _lodHalfAngle;
}
float LODManager::getLODAngleDeg() const {
return glm::degrees(getLODAngle());
}
float LODManager::getVisibilityDistance() const {
return _visibilityDistance;
float systemDistance = getVisibilityDistanceFromHalfAngle(_lodHalfAngle);
// Maintain behavior with deprecated _boundaryLevelAdjust property
return systemDistance * powf(2.0f, _boundaryLevelAdjust);
}
void LODManager::setVisibilityDistance(float distance) {
_visibilityDistance = distance;
// Maintain behavior with deprecated _boundaryLevelAdjust property
float userDistance = distance / powf(2.0f, _boundaryLevelAdjust);
_lodHalfAngle = getHalfAngleFromVisibilityDistance(userDistance);
}
void LODManager::setLODAngleDeg(float lodAngle) {

View file

@ -17,6 +17,7 @@
#include <DependencyManager.h>
#include <NumericalConstants.h>
#include <OctreeConstants.h>
#include <OctreeUtils.h>
#include <PIDController.h>
#include <SimpleMovingAverage.h>
#include <render/Args.h>
@ -261,7 +262,7 @@ private:
float _desktopTargetFPS { LOD_OFFSET_FPS + LOD_DEFAULT_QUALITY_LEVEL * LOD_MAX_LIKELY_DESKTOP_FPS };
float _hmdTargetFPS { LOD_OFFSET_FPS + LOD_DEFAULT_QUALITY_LEVEL * LOD_MAX_LIKELY_HMD_FPS };
float _visibilityDistance = DEFAULT_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT;
float _lodHalfAngle = getHalfAngleFromVisibilityDistance(DEFAULT_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT);
int _boundaryLevelAdjust = 0;
glm::vec4 _pidCoefs{ 1.0f, 0.0f, 0.0f, 1.0f }; // Kp, Ki, Kd, Kv

View file

@ -31,6 +31,15 @@ float getPerspectiveAccuracyHalfAngle(float visibilityDistance, int boundaryLeve
return atan(getPerspectiveAccuracyHalfAngleTan(visibilityDistance, boundaryLevelAdjust));
}
float getVisibilityDistanceFromHalfAngle(float halfAngle) {
float halfAngleTan = tan(halfAngle);
return UNIT_ELEMENT_MAX_EXTENT / halfAngleTan;
}
float getHalfAngleFromVisibilityDistance(float visibilityDistance) {
return UNIT_ELEMENT_MAX_EXTENT / visibilityDistance;
}
float getOrthographicAccuracySize(float visibilityDistance, int boundaryLevelAdjust) {
// Smallest visible element is 1cm
const float smallestSize = 0.01f;

View file

@ -24,6 +24,8 @@ float boundaryDistanceForRenderLevel(unsigned int renderLevel, float visibilityD
float getPerspectiveAccuracyHalfAngleTan(float visibilityDistance, int boundaryLevelAdjust);
float getPerspectiveAccuracyHalfAngle(float visibilityDistance, int boundaryLevelAdjust);
float getVisibilityDistanceFromHalfAngle(float halfAngle);
float getHalfAngleFromVisibilityDistance(float visibilityDistance);
float getOrthographicAccuracySize(float visibilityDistance, int boundaryLevelAdjust);
// MIN_ELEMENT_ANGULAR_DIAMETER = angular diameter of 1x1x1m cube at 400m = sqrt(3) / 400 = 0.0043301 radians ~= 0.25 degrees