Use inline constexpr for constants in header files

pull/1273/head
Andrew Tribick 2021-12-15 15:07:12 +01:00 committed by ajtribick
parent 1dc01e221e
commit 9651e9e265
6 changed files with 19 additions and 19 deletions

View File

@ -223,21 +223,21 @@ namespace astro
double meanEclipticObliquity(double jd);
// epoch J2000: 12 UT on 1 Jan 2000
constexpr const double J2000 = 2451545.0;
constexpr const double speedOfLight = 299792.458; // km/s
constexpr const double G = 6.672e-11; // N m^2 / kg^2; gravitational constant
constexpr const double SolarMass = 1.989e30;
constexpr const double EarthMass = 5.972e24;
constexpr const double LunarMass = 7.346e22;
constexpr const double JupiterMass = 1.898e27;
constexpr inline double J2000 = 2451545.0;
constexpr inline double speedOfLight = 299792.458; // km/s
constexpr inline double G = 6.672e-11; // N m^2 / kg^2; gravitational constant
constexpr inline double SolarMass = 1.989e30;
constexpr inline double EarthMass = 5.972e24;
constexpr inline double LunarMass = 7.346e22;
constexpr inline double JupiterMass = 1.898e27;
// Angle between J2000 mean equator and the ecliptic plane.
// 23 deg 26' 21".448 (Seidelmann, _Explanatory Supplement to the
// Astronomical Almanac_ (1992), eqn 3.222-1.
constexpr const double J2000Obliquity = 23.4392911_deg;
constexpr inline double J2000Obliquity = 23.4392911_deg;
constexpr const double SOLAR_IRRADIANCE = 1367.6; // Watts / m^2
constexpr const double SOLAR_POWER = 3.8462e26; // in Watts
constexpr inline double SOLAR_IRRADIANCE = 1367.6; // Watts / m^2
constexpr inline double SOLAR_POWER = 3.8462e26; // in Watts
namespace literals

View File

@ -67,7 +67,7 @@ class Atmosphere
// to render. The radius of the sphere is the height at which the
// density of the atmosphere falls to the extinction threshold, i.e.
// -H * ln(extinctionThreshold)
constexpr const float AtmosphereExtinctionThreshold = 0.05f;
constexpr inline float AtmosphereExtinctionThreshold = 0.05f;
#endif // _CELENGINE_ATMOSPHERE_H_

View File

@ -26,7 +26,7 @@ class Selection;
class Renderer;
struct Matrices;
constexpr const float DSO_DEFAULT_ABS_MAGNITUDE = -1000.0f;
constexpr inline float DSO_DEFAULT_ABS_MAGNITUDE = -1000.0f;
class Nebula;
class Galaxy;

View File

@ -21,10 +21,10 @@
#include <celengine/parser.h>
constexpr const unsigned int MAX_DSO_NAMES = 10;
constexpr inline unsigned int MAX_DSO_NAMES = 10;
// 100 Gly - on the order of the current size of the universe
constexpr const float DSO_OCTREE_ROOT_SIZE = 1.0e11f;
constexpr inline float DSO_OCTREE_ROOT_SIZE = 1.0e11f;
//NOTE: this one and starDatabase should be derived from a common base class since they share lots of code and functionality.
class DSODatabase

View File

@ -22,11 +22,11 @@ class StarDatabase;
// TODO: move these variables to PointStarRenderer class
// without adding a variable. Requires C++17
constexpr const float StarDistanceLimit = 1.0e6f;
constexpr inline float StarDistanceLimit = 1.0e6f;
// Star disc size in pixels
constexpr const float BaseStarDiscSize = 5.0f;
constexpr const float MaxScaledDiscStarSize = 8.0f;
constexpr const float GlareOpacity = 0.65f;
constexpr inline float BaseStarDiscSize = 5.0f;
constexpr inline float MaxScaledDiscStarSize = 8.0f;
constexpr inline float GlareOpacity = 0.65f;
class PointStarRenderer : public ObjectRenderer<Star, float>
{

View File

@ -13,7 +13,7 @@
namespace celestia::gl
{
constexpr const int GL_2_1 = 21;
constexpr inline int GL_2_1 = 21;
extern bool ARB_shader_objects;
extern bool ARB_shading_language_100;