Skip to content

Commit

Permalink
Remove unused Simulation::findObject, make Universe::find private
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtribick committed Dec 18, 2024
1 parent 7e3a200 commit e13024d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
22 changes: 0 additions & 22 deletions src/celengine/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,28 +417,6 @@ void Simulation::selectPlanet(int index)
}
}


// Select an object by name, with the following priority:
// 1. Try to look up the name in the star database
// 2. Search the deep sky catalog for a matching name.
// 3. Search the planets and moons in the planetary system of the currently selected
// star
// 4. Search the planets and moons in any 'nearby' (< 0.1 ly) planetary systems
Selection Simulation::findObject(std::string_view s, bool i18n) const
{
Selection path[2];
std::size_t nPathEntries = 0;

if (!selection.empty())
path[nPathEntries++] = selection;

if (auto nearestSolarSystem = getNearestSolarSystem(); nearestSolarSystem != nullptr)
path[nPathEntries++] = Selection(nearestSolarSystem->getStar());

return universe->find(s, {path, nPathEntries}, i18n);
}


// Find an object from a path, for example Sol/Earth/Moon or Upsilon And/b
// Currently, 'absolute' paths starting with a / are not supported nor are
// paths that contain galaxies.
Expand Down
8 changes: 3 additions & 5 deletions src/celengine/simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
#include <celengine/frame.h>
#include <celengine/observer.h>


class Renderer;

class Simulation
{
public:
Simulation(Universe*);
public:
explicit Simulation(Universe*);
~Simulation();

double getTime() const; // Julian date
Expand Down Expand Up @@ -65,7 +64,6 @@ class Simulation
void setTrackedObject(const Selection&);

void selectPlanet(int);
Selection findObject(std::string_view s, bool i18n = false) const;
Selection findObjectFromPath(std::string_view s, bool i18n = false) const;
void getObjectCompletion(std::vector<celestia::engine::Completion>& completion,
std::string_view s,
Expand Down Expand Up @@ -127,7 +125,7 @@ class Simulation
void setFrame(ObserverFrame::CoordinateSystem, const Selection& refObject);
const ObserverFrame::SharedConstPtr& getFrame() const;

private:
private:
double realTime{ 0.0 };
double timeScale{ 1.0 };
double storedTimeScale{ 1.0 };
Expand Down
12 changes: 5 additions & 7 deletions src/celengine/universe.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
#include <celengine/asterism.h>
#include <celutil/array_view.h>


class Universe
{
public:
public:
Universe() = default;
~Universe();

Expand All @@ -58,9 +57,6 @@ class Universe
float tolerance = 0.0f);


Selection find(std::string_view s,
celestia::util::array_view<const Selection> contexts,
bool i18n = false) const;
Selection findPath(std::string_view s,
celestia::util::array_view<const Selection> contexts,
bool i18n = false) const;
Expand Down Expand Up @@ -90,12 +86,15 @@ class Universe
bool isMarked(const Selection&, int priority) const;
const celestia::MarkerList& getMarkers() const;

private:
private:
void getCompletion(std::vector<celestia::engine::Completion>& completion,
std::string_view s,
celestia::util::array_view<const Selection> contexts,
bool withLocations = false) const;

Selection find(std::string_view s,
celestia::util::array_view<const Selection> contexts,
bool i18n = false) const;
Selection findChildObject(const Selection& sel,
std::string_view name,
bool i18n = false) const;
Expand All @@ -122,7 +121,6 @@ class Universe
float faintest,
float tolerance = 0.0f) const;

private:
std::unique_ptr<StarDatabase> starCatalog{nullptr};
std::unique_ptr<DSODatabase> dsoCatalog{nullptr};
std::unique_ptr<SolarSystemCatalog> solarSystemCatalog{nullptr};
Expand Down

0 comments on commit e13024d

Please sign in to comment.