Skip to content

Commit 22fb030

Browse files
committed
Rename astro namespace to celestia::astro
- Tidy up includes in astro.h/astro.cpp - Replace snprintf with fmt in astro.cpp - Replace Date::toCStr() with Date::toString() returning std::string
1 parent fabefe9 commit 22fb030

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+771
-614
lines changed

src/celengine/astro.cpp

Lines changed: 331 additions & 263 deletions
Large diffs are not rendered by default.

src/celengine/astro.h

Lines changed: 282 additions & 262 deletions
Large diffs are not rendered by default.

src/celengine/body.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ using namespace Eigen;
3030
using namespace std;
3131
using namespace celmath;
3232

33+
namespace astro = celestia::astro;
3334

3435
Body::Body(PlanetarySystem* _system, const std::string& _name) :
3536
system(_system),

src/celengine/boundaries.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "astro.h"
1818

19+
namespace astro = celestia::astro;
1920

2021
namespace
2122
{

src/celengine/dateformatter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <celutil/gettext.h>
1515
#endif
1616

17+
namespace astro = celestia::astro;
18+
1719
namespace celestia::engine
1820
{
1921

@@ -69,7 +71,7 @@ std::string DateFormatter::formatDate(double tdb, bool local, astro::Date::Forma
6971
return utf8FormattedDate;
7072
#else
7173
astro::Date d = local ? astro::TDBtoLocal(tdb) : astro::TDBtoUTC(tdb);
72-
return d.toCStr(format);
74+
return d.toString(format);
7375
#endif
7476
}
7577

src/celengine/deepskyobj.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "astro.h"
1818
#include "hash.h"
1919

20+
namespace astro = celestia::astro;
21+
2022
Eigen::Vector3d DeepSkyObject::getPosition() const
2123
{
2224
return position;
@@ -86,14 +88,14 @@ bool DeepSkyObject::pick(const Eigen::ParametrizedLine<double, 3>& ray,
8688
bool DeepSkyObject::load(const AssociativeArray* params, const fs::path& resPath)
8789
{
8890
// Get position
89-
if (auto position = params->getLengthVector<double>("Position", KM_PER_LY<double>); position.has_value())
91+
if (auto pos = params->getLengthVector<double>("Position", astro::KM_PER_LY<double>); pos.has_value())
9092
{
91-
setPosition(*position);
93+
setPosition(*pos);
9294
}
9395
else
9496
{
95-
auto distance = params->getLength<double>("Distance", KM_PER_LY<double>).value_or(1.0);
96-
auto RA = params->getAngle<double>("RA", DEG_PER_HRA).value_or(0.0);
97+
auto distance = params->getLength<double>("Distance", astro::KM_PER_LY<double>).value_or(1.0);
98+
auto RA = params->getAngle<double>("RA", astro::DEG_PER_HRA).value_or(0.0);
9799
auto dec = params->getAngle<double>("Dec").value_or(0.0);
98100

99101
Eigen::Vector3d p = astro::equatorialToCelestialCart(RA, dec, distance);
@@ -107,7 +109,7 @@ bool DeepSkyObject::load(const AssociativeArray* params, const fs::path& resPath
107109
setOrientation(Eigen::Quaternionf(Eigen::AngleAxisf(static_cast<float>(celmath::degToRad(angle)),
108110
axis.cast<float>().normalized())));
109111

110-
setRadius(params->getLength<float>("Radius", KM_PER_LY<double>).value_or(1.0f));
112+
setRadius(params->getLength<float>("Radius", astro::KM_PER_LY<double>).value_or(1.0f));
111113

112114
if (auto absMagValue = params->getNumber<float>("AbsMag"); absMagValue.has_value())
113115
setAbsoluteMagnitude(*absMagValue);

src/celengine/dsodb.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <cmath>
1515
#include <utility>
1616

17+
#include <celcompat/numbers.h>
1718
#include <celutil/gettext.h>
1819
#include <celutil/logger.h>
1920
#include <celutil/tokenizer.h>
@@ -29,6 +30,8 @@
2930

3031
using celestia::util::GetLogger;
3132

33+
namespace astro = celestia::astro;
34+
3235
constexpr const float DSO_OCTREE_MAGNITUDE = 8.0f;
3336
//constexpr const float DSO_EXTRA_ROOM = 0.01f; // Reserve 1% capacity for extra DSOs
3437
// (useful as a complement of binary loaded DSOs)
@@ -336,7 +339,7 @@ void DSODatabase::finish()
336339
void DSODatabase::buildOctree()
337340
{
338341
GetLogger()->debug("Sorting DSOs into octree . . .\n");
339-
float absMag = astro::appToAbsMag(DSO_OCTREE_MAGNITUDE, DSO_OCTREE_ROOT_SIZE * (float) sqrt(3.0));
342+
float absMag = astro::appToAbsMag(DSO_OCTREE_MAGNITUDE, DSO_OCTREE_ROOT_SIZE * celestia::numbers::sqrt3_v<float>);
340343

341344
// TODO: investigate using a different center--it's possible that more
342345
// objects end up straddling the base level nodes when the center of the

src/celengine/dsooctree.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using namespace Eigen;
1616

17+
namespace astro = celestia::astro;
1718

1819
// The octree node into which a dso is placed is dependent on two properties:
1920
// its obsPosition and its luminosity--the fainter the dso, the deeper the node
@@ -100,7 +101,7 @@ void DSOOctree::processVisibleObjects(DSOHandler& processor,
100101
double minDistance = (obsPosition - cellCenterPos).norm() - scale * DSOOctree::SQRT3;
101102

102103
// Process the objects in this node
103-
double dimmest = minDistance > 0.0 ? astro::appToAbsMag((double) limitingFactor, minDistance) : 1000.0;
104+
double dimmest = minDistance > 0.0 ? astro::appToAbsMag((double) limitingFactor, minDistance) : 1000.0;
104105

105106
for (unsigned int i=0; i<nObjects; ++i)
106107
{
@@ -115,7 +116,7 @@ void DSOOctree::processVisibleObjects(DSOHandler& processor,
115116
double distance = (obsPosition - _obj->getPosition()).norm() - _obj->getBoundingSphereRadius();
116117
float appMag = (float) ((distance >= 32.6167) ? astro::absToAppMag((double) absMag, distance) : absMag);
117118

118-
if ( appMag < limitingFactor)
119+
if (appMag < limitingFactor)
119120
processor.process(_obj, distance, absMag);
120121
}
121122
}

src/celengine/dsorenderer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "render.h"
1818
#include "dsorenderer.h"
1919

20+
namespace astro = celestia::astro;
2021

2122
namespace
2223
{

src/celengine/frame.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using namespace Eigen;
2121
using namespace std;
2222

23+
namespace astro = celestia::astro;
2324

2425
// Velocity for two-vector frames is computed by differentiation; units
2526
// are Julian days.

0 commit comments

Comments
 (0)