Code Cleanup (#2191)

* constexpr const -> constexpr
* const char* -> std::string_view
This commit is contained in:
Alexander Bock
2022-07-25 15:57:45 +02:00
committed by GitHub
parent ea1f4bbf40
commit 9cc4c595a8
267 changed files with 1425 additions and 1565 deletions
@@ -34,7 +34,6 @@
#include <openspace/util/updatestructures.h>
#include <openspace/query/query.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/logging/consolelog.h>
#include <ghoul/logging/visualstudiooutputlog.h>
@@ -47,9 +46,9 @@
#include <thread>
namespace {
constexpr const char* _loggerCat = "RenderableFluxNodes";
constexpr std::string_view _loggerCat = "RenderableFluxNodes";
constexpr const std::array<const char*, 29> UniformNames = {
constexpr std::array<const char*, 29> UniformNames = {
"streamColor", "nodeSize", "proximityNodesSize",
"thresholdFlux", "colorMode", "filterLower", "filterUpper", "scalingMode",
"colorTableRange", "domainLimZ", "nodeSkip", "nodeSkipDefault", "nodeSkipEarth",
@@ -40,7 +40,7 @@
#include <optional>
namespace {
constexpr const std::array<const char*, 6> UniformNames = {
constexpr std::array<const char*, 6> UniformNames = {
"modelViewProjectionTransform", "opacity", "width", "transferFunctionTexture",
"conservativeBounds", "showOptimistic"
};
@@ -189,7 +189,7 @@ void RenderableHabitableZone::updateUniformLocations() {
void RenderableHabitableZone::computeZone() {
glm::dvec4 distancesInAu = computeKopparapuZoneBoundaries(_teff, _luminosity);
constexpr const double AU = distanceconstants::AstronomicalUnit;
constexpr double AU = distanceconstants::AstronomicalUnit;
const double inner = distancesInAu[0] * AU;
const double innerConservative = distancesInAu[1] * AU;
const double outerConservative = distancesInAu[2] * AU;
@@ -235,15 +235,15 @@ glm::dvec4 RenderableHabitableZone::computeKopparapuZoneBoundaries(float teff,
// Coefficients for planets of 1 Earth mass. Received from:
// https://depts.washington.edu/naivpl/sites/default/files/HZ_coefficients.dat
constexpr const Coefficients coefficients[] = {
constexpr Coefficients coefficients[] = {
// Optimistic Inner boundary - Recent Venus
{1.77600E+00, 2.13600E-04, 2.53300E-08, -1.33200E-11, -3.09700E-15},
{ 1.77600E+00, 2.13600E-04, 2.53300E-08, -1.33200E-11, -3.09700E-15 },
// Conservative Inner boundary - Runaway greenhouse
{1.10700E+00, 1.33200E-04, 1.58000E-08, -8.30800E-12, -1.93100E-15},
{ 1.10700E+00, 1.33200E-04, 1.58000E-08, -8.30800E-12, -1.93100E-15 },
// Conservative Outer boundary - Maximum greenhouse
{3.56000E-01, 6.17100E-05, 1.69800E-09, -3.19800E-12, -5.57500E-16},
{ 3.56000E-01, 6.17100E-05, 1.69800E-09, -3.19800E-12, -5.57500E-16 },
// Optimistic Outer boundary - Early Mars
{3.20000E-01, 5.54700E-05, 1.52600E-09, -2.87400E-12, -5.01100E-16}
{ 3.20000E-01, 5.54700E-05, 1.52600E-09, -2.87400E-12, -5.01100E-16 }
};
const double tstar = static_cast<double>(teff - 5780.f);
@@ -45,14 +45,12 @@
#include <vector>
namespace {
constexpr const char* ProgramName = "OrbitalKepler";
constexpr const std::array<int, 36> LeapYears = {
constexpr std::array<int, 36> LeapYears = {
1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996,
2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040,
2044, 2048, 2052, 2056
};
constexpr const std::array<int, 12> DaysOfMonths = {
constexpr std::array<int, 12> DaysOfMonths = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
@@ -66,10 +64,10 @@ namespace {
}
};
constexpr const LeapSecond LeapEpoch = { 2000, 1 };
constexpr LeapSecond LeapEpoch = { 2000, 1 };
// List taken from: https://www.ietf.org/timezones/data/leap-seconds.list
constexpr const std::array<LeapSecond, 28> LeapSeconds = {
constexpr std::array<LeapSecond, 28> LeapSeconds = {
LeapSecond{ 1972, 1 },
LeapSecond{ 1972, 183 },
LeapSecond{ 1973, 1 },
@@ -106,9 +104,9 @@ namespace {
// Find the position of the current year in the vector, the difference
// between its position and the position of 2000 (for J2000) gives the
// number of leap years
constexpr const int Epoch = 2000;
constexpr const int DaysRegularYear = 365;
constexpr const int DaysLeapYear = 366;
constexpr int Epoch = 2000;
constexpr int DaysRegularYear = 365;
constexpr int DaysLeapYear = 366;
if (year == Epoch) {
return 0;
@@ -242,9 +240,9 @@ documentation::Documentation RenderableOrbitalKepler::Documentation() {
}
double RenderableOrbitalKepler::calculateSemiMajorAxis(double meanMotion) const {
constexpr const double GravitationalConstant = 6.6740831e-11;
constexpr const double MassEarth = 5.9721986e24;
constexpr const double muEarth = GravitationalConstant * MassEarth;
constexpr double GravitationalConstant = 6.6740831e-11;
constexpr double MassEarth = 5.9721986e24;
constexpr double muEarth = GravitationalConstant * MassEarth;
// Use Kepler's 3rd law to calculate semimajor axis
// a^3 / P^2 = mu / (2pi)^2
@@ -255,7 +253,7 @@ double RenderableOrbitalKepler::calculateSemiMajorAxis(double meanMotion) const
const double period =
std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion;
constexpr const double pisq = glm::pi<double>() * glm::pi<double>();
constexpr double pisq = glm::pi<double>() * glm::pi<double>();
const double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0);
// We need the semi major axis in km instead of m
@@ -398,10 +396,10 @@ void RenderableOrbitalKepler::initializeGL() {
glGenBuffers(1, &_vertexBuffer);
_programObject = SpaceModule::ProgramObjectManager.request(
ProgramName,
"OrbitalKepler",
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
return global::renderEngine->buildRenderProgram(
ProgramName,
"OrbitalKepler",
absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl")
);
@@ -431,7 +429,7 @@ void RenderableOrbitalKepler::deinitializeGL() {
glDeleteVertexArrays(1, &_vertexArray);
SpaceModule::ProgramObjectManager.release(
ProgramName,
"OrbitalKepler",
[](ghoul::opengl::ProgramObject* p) {
global::renderEngine->removeRenderProgram(p);
}
+1 -1
View File
@@ -39,7 +39,7 @@
#include <optional>
namespace {
constexpr const std::array<const char*, 6> UniformNames = {
constexpr std::array<const char*, 6> UniformNames = {
"modelViewProjectionTransform", "textureOffset", "colorFilterValue",
"_nightFactor", "sunPosition", "texture1"
};
@@ -46,7 +46,7 @@
#include <vector>
namespace {
constexpr const char* _loggerCat = "Satellites";
constexpr std::string_view _loggerCat = "Satellites";
static const openspace::properties::Property::PropertyInfo SegmentsInfo = {
"Segments",
@@ -47,7 +47,7 @@
#include <vector>
namespace {
constexpr const char* _loggerCat = "SmallSolarSystemBody";
constexpr std::string_view _loggerCat = "SmallSolarSystemBody";
static const openspace::properties::Property::PropertyInfo ContiguousModeInfo = {
"ContiguousMode",
+8 -9
View File
@@ -31,7 +31,6 @@
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/templatefactory.h>
@@ -49,9 +48,9 @@
#include <type_traits>
namespace {
constexpr const char* _loggerCat = "RenderableStars";
constexpr std::string_view _loggerCat = "RenderableStars";
constexpr const std::array<const char*, 17> UniformNames = {
constexpr std::array<const char*, 17> UniformNames = {
"modelMatrix", "cameraUp", "cameraViewProjectionMatrix", "colorOption",
"magnitudeExponent", "eyePosition", "psfParamConf", "lumCent", "radiusCent",
"brightnessCent", "colorTexture", "alphaValue", "psfTexture", "otherDataTexture",
@@ -72,11 +71,11 @@ namespace {
DistanceModulus
};
constexpr const int PsfMethodSpencer = 0;
constexpr const int PsfMethodMoffat = 1;
constexpr int PsfMethodSpencer = 0;
constexpr int PsfMethodMoffat = 1;
constexpr const int PsfTextureSize = 64;
constexpr const int ConvolvedfTextureSize = 257;
constexpr int PsfTextureSize = 64;
constexpr int ConvolvedfTextureSize = 257;
constexpr double PARSEC = 0.308567756E17;
@@ -781,7 +780,7 @@ void RenderableStars::initializeGL() {
glBindVertexArray(_psfVao);
glBindBuffer(GL_ARRAY_BUFFER, _psfVbo);
constexpr const std::array<GLfloat, 24> VertexData = {
constexpr std::array<GLfloat, 24> VertexData = {
//x y s t
-1.f, -1.f, 0.f, 0.f,
1.f, 1.f, 1.f, 1.f,
@@ -909,7 +908,7 @@ void RenderableStars::renderPSFToTexture() {
);
program->activate();
constexpr const std::array<float, 4> Black = { 0.f, 0.f, 0.f, 0.f };
constexpr std::array<float, 4> Black = { 0.f, 0.f, 0.f, 0.f };
glClearBufferfv(GL_COLOR, 0, Black.data());
program->setUniform("psfMethod", _psfMethodOption.value());
@@ -37,7 +37,7 @@
#include <optional>
namespace {
constexpr const std::array<const char*, 2> UniformNames = {"lineColor", "opacity"};
constexpr std::array<const char*, 2> UniformNames = {"lineColor", "opacity"};
constexpr openspace::properties::Property::PropertyInfo SpeedInfo = {
"TravelSpeed",