From 0d5260bccc38a8c2682ebd0ac54b290ac8da471e Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Tue, 6 Aug 2019 16:35:41 -0700 Subject: [PATCH] More LOD renaming with focus on angles --- interface/src/Application.cpp | 2 +- interface/src/LODManager.cpp | 6 +++--- interface/src/LODManager.h | 2 +- libraries/octree/src/OctreeUtils.cpp | 12 ++++++------ libraries/octree/src/OctreeUtils.h | 6 +++--- libraries/render/src/render/DrawSceneOctree.cpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5f4850485f..90ca03d6c6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6818,7 +6818,7 @@ void Application::updateRenderArgs(float deltaTime) { _viewFrustum.calculate(); } appRenderArgs._renderArgs = RenderArgs(_graphicsEngine.getGPUContext(), lodManager->getVisibilityDistance(), - lodManager->getBoundaryLevelAdjust(), lodManager->getLODAngleHalfTan(), RenderArgs::DEFAULT_RENDER_MODE, + lodManager->getBoundaryLevelAdjust(), lodManager->getLODHalfAngleTan(), RenderArgs::DEFAULT_RENDER_MODE, RenderArgs::MONO, RenderArgs::DEFERRED, RenderArgs::RENDER_DEBUG_NONE); appRenderArgs._renderArgs._scene = getMain3DScene(); diff --git a/interface/src/LODManager.cpp b/interface/src/LODManager.cpp index 2b303aed74..1de003adcd 100644 --- a/interface/src/LODManager.cpp +++ b/interface/src/LODManager.cpp @@ -173,12 +173,12 @@ void LODManager::autoAdjustLOD(float realTimeDelta) { } } -float LODManager::getLODAngleHalfTan() const { - return getPerspectiveAccuracyAngleTan(_visibilityDistance, _boundaryLevelAdjust); +float LODManager::getLODHalfAngleTan() const { + return getPerspectiveAccuracyHalfAngleTan(_visibilityDistance, _boundaryLevelAdjust); } float LODManager::getLODAngle() const { - return 2.0f * atanf(getLODAngleHalfTan()); + return 2.0f * atanf(getLODHalfAngleTan()); } float LODManager::getLODAngleDeg() const { return glm::degrees(getLODAngle()); diff --git a/interface/src/LODManager.h b/interface/src/LODManager.h index facda81724..46dde807db 100644 --- a/interface/src/LODManager.h +++ b/interface/src/LODManager.h @@ -201,7 +201,7 @@ public: float getLODAngleDeg() const; void setLODAngleDeg(float lodAngle); - float getLODAngleHalfTan() const; + float getLODHalfAngleTan() const; float getLODAngle() const; float getVisibilityDistance() const; void setVisibilityDistance(float distance); diff --git a/libraries/octree/src/OctreeUtils.cpp b/libraries/octree/src/OctreeUtils.cpp index 2a1f520819..34a92c694b 100644 --- a/libraries/octree/src/OctreeUtils.cpp +++ b/libraries/octree/src/OctreeUtils.cpp @@ -18,17 +18,17 @@ #include #include -float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale) { - return voxelSizeScale / powf(2.0f, renderLevel); +float boundaryDistanceForRenderLevel(unsigned int renderLevel, float visibilityDistance) { + return visibilityDistance / powf(2.0f, renderLevel); } -float getPerspectiveAccuracyAngleTan(float visibilityDistance, int boundaryLevelAdjust) { +float getPerspectiveAccuracyHalfAngleTan(float visibilityDistance, int boundaryLevelAdjust) { float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, visibilityDistance); - return UNIT_ELEMENT_MAX_EXTENT / visibleDistanceAtMaxScale; // TODO: consider renaming this function to half tangent because we're taking into account a factor of 1/2 + return UNIT_ELEMENT_MAX_EXTENT / visibleDistanceAtMaxScale; } -float getPerspectiveAccuracyAngle(float visibilityDistance, int boundaryLevelAdjust) { - return atan(getPerspectiveAccuracyAngleTan(visibilityDistance, boundaryLevelAdjust)); +float getPerspectiveAccuracyHalfAngle(float visibilityDistance, int boundaryLevelAdjust) { + return atan(getPerspectiveAccuracyHalfAngleTan(visibilityDistance, boundaryLevelAdjust)); } float getOrthographicAccuracySize(float visibilityDistance, int boundaryLevelAdjust) { diff --git a/libraries/octree/src/OctreeUtils.h b/libraries/octree/src/OctreeUtils.h index 4ac3937cd0..8bf8bea587 100644 --- a/libraries/octree/src/OctreeUtils.h +++ b/libraries/octree/src/OctreeUtils.h @@ -20,10 +20,10 @@ class AABox; class AACube; class QJsonDocument; -float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale); +float boundaryDistanceForRenderLevel(unsigned int renderLevel, float visibilityDistance); -float getPerspectiveAccuracyAngleTan(float visibilityDistance, int boundaryLevelAdjust); -float getPerspectiveAccuracyAngle(float visibilityDistance, int boundaryLevelAdjust); +float getPerspectiveAccuracyHalfAngleTan(float visibilityDistance, int boundaryLevelAdjust); +float getPerspectiveAccuracyHalfAngle(float visibilityDistance, int boundaryLevelAdjust); 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 diff --git a/libraries/render/src/render/DrawSceneOctree.cpp b/libraries/render/src/render/DrawSceneOctree.cpp index b10c3fef8d..493ed01c3f 100644 --- a/libraries/render/src/render/DrawSceneOctree.cpp +++ b/libraries/render/src/render/DrawSceneOctree.cpp @@ -120,7 +120,7 @@ void DrawSceneOctree::run(const RenderContextPointer& renderContext, const ItemS // Draw the LOD Reticle { - float angle = glm::degrees(getPerspectiveAccuracyAngle(args->_sizeScale, args->_boundaryLevelAdjust)); + float angle = glm::degrees(getPerspectiveAccuracyHalfAngle(args->_sizeScale, args->_boundaryLevelAdjust)); Transform crosshairModel; crosshairModel.setTranslation(glm::vec3(0.0, 0.0, -1000.0)); crosshairModel.setScale(1000.0f * tanf(glm::radians(angle))); // Scaling at the actual tan of the lod angle => Multiplied by TWO