Fix LOD math

This commit is contained in:
sabrina-shanman 2019-08-08 11:12:07 -07:00
parent 9c16fcfdef
commit 1571c2be27
2 changed files with 6 additions and 8 deletions

View file

@ -92,8 +92,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
return;
}
// Previous values for output
float oldVisibilityDistance = getVisibilityDistance();
// Previous value for output
float oldLODAngle = getLODAngleDeg();
// Target fps is slightly overshooted by 5hz
@ -174,7 +173,6 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
float LODManager::getLODHalfAngleTan() const {
return tan(_lodHalfAngle);
}
float LODManager::getLODAngle() const {
return 2.0f * _lodHalfAngle;
@ -196,10 +194,9 @@ void LODManager::setVisibilityDistance(float distance) {
}
void LODManager::setLODAngleDeg(float lodAngle) {
auto newSolidAngle = std::max(0.001f, std::min(lodAngle, 90.f));
auto halfTan = glm::tan(glm::radians(newSolidAngle * 0.5f));
auto visibilityDistance = UNIT_ELEMENT_MAX_EXTENT / halfTan;
setVisibilityDistance(visibilityDistance);
auto newLODAngleDeg = std::max(0.001f, std::min(lodAngle, 90.f));
auto newLODHalfAngle = glm::radians(newLODAngleDeg * 0.5);
_lodHalfAngle = newLODHalfAngle;
}
void LODManager::setSmoothScale(float t) {

View file

@ -37,7 +37,8 @@ float getVisibilityDistanceFromHalfAngle(float halfAngle) {
}
float getHalfAngleFromVisibilityDistance(float visibilityDistance) {
return UNIT_ELEMENT_MAX_EXTENT / visibilityDistance;
float halfAngleTan = UNIT_ELEMENT_MAX_EXTENT / visibilityDistance;
return atan(halfAngleTan);
}
float getOrthographicAccuracySize(float visibilityDistance, int boundaryLevelAdjust) {