Skip to content

Commit

Permalink
Satellite plugin: a few tiny speedups
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed Aug 27, 2024
1 parent 4f80edf commit c363593
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions plugins/Satellites/src/Satellite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ Satellite::Satellite(const QString& identifier, const QVariantMap& map)
{ gSatWrapper::BELOW_HORIZON, N_("The satellite is below the horizon") }
};

update(0.);
StelCore *core = StelApp::getInstance().getCore();
double JD=core->getJD();
update(core, JD, 0.);
}

Satellite::~Satellite()
Expand Down Expand Up @@ -810,12 +812,12 @@ void Satellite::recomputeSatData()
calculateSatDataFromLine2(tleElements.second);
}

void Satellite::update(double)
void Satellite::update(StelCore *core, double JD, double deltaTime)
{
Q_UNUSED(deltaTime)
if (pSatWrapper && orbitValid)
{
StelCore* core = StelApp::getInstance().getCore();
epochTime = core->getJD(); // + timeShift; // We have "true" JD (UTC) from core, satellites don't need JDE!
epochTime = JD; // + timeShift; // We have "true" JD (UTC) from core, satellites don't need JDE!

pSatWrapper->setEpoch(epochTime);
position = pSatWrapper->getTEMEPos();
Expand Down
7 changes: 5 additions & 2 deletions plugins/Satellites/src/Satellite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ class Satellite : public StelObject
//! the tleElements values and configures internal orbit parameters.
void setNewTleElements(const QString& tle1, const QString& tle2);

// calculate faders, new position
void update(double deltaTime);
//! calculate faders, new position
//! @param core current StelCore
//! @param JD Julian day, UTC. (Satellites don't use JDE!)
//! @param deltaTime (currently unused)
void update(StelCore *core, double JD, double deltaTime);

double getDoppler(double freq) const;
static bool showLabels;
Expand Down
5 changes: 3 additions & 2 deletions plugins/Satellites/src/Satellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2809,7 +2809,8 @@ void Satellites::update(double deltaTime)
if (!hintFader && hintFader.getInterstate() <= 0.f)
return;

StelCore *core = StelApp::getInstance().getCore();
static StelCore *core = StelApp::getInstance().getCore();
double JD=core->getJD();

if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not show satellites when time rate is over limit
return;
Expand All @@ -2822,7 +2823,7 @@ void Satellites::update(double deltaTime)
for (const auto& sat : std::as_const(satellites))
{
if (sat->initialized && sat->displayed)
sat->update(deltaTime);
sat->update(core, JD, deltaTime);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/AstroCalcDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ void AstroCalcDialog::drawAziVsTimeDiagram()
#ifdef USE_STATIC_PLUGIN_SATELLITES
if (isSatellite)
{
sat->update(0.0);
sat->update(core, JD, 0.0);
}
else
#endif
Expand Down Expand Up @@ -5030,7 +5030,7 @@ void AstroCalcDialog::drawAltVsTimeDiagram()
if (isSatellite)
{
// update data for that single satellite only
sat->update(0.0);
sat->update(core, JD, 0.0);
}
#endif
StelUtils::rectToSphe(&az, &alt, selectedObject->getAltAzPosAuto(core));
Expand Down

0 comments on commit c363593

Please sign in to comment.