Skip to content

Commit

Permalink
Satellites: Avoid bad orbit lines (Fix #3934)
Browse files Browse the repository at this point in the history
- Don't parallelize when orbits are needed
- Not a perfect solution, but it takes deeper
  insight into the plugin code to really solve the issue
  • Loading branch information
gzotti committed Nov 2, 2024
1 parent 3deaff2 commit 6b003f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion plugins/Satellites/src/Satellite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ void Satellite::update(const StelCore *core, const double JD)
phaseAngle = std::acos(-1.0*(std::sin(decSun)*std::sin(decSat) + std::cos(decSun)*std::cos(decSat)*std::cos(raSun - raSat)));

// Compute orbit points to draw orbit line.
if (orbitDisplayed) computeOrbitPoints();
// We suppress computing so that no lines are computed in parallel as long as this uses static variables.
if (orbitLinesFlag && orbitDisplayed) computeOrbitPoints();
}
}

Expand Down
24 changes: 19 additions & 5 deletions plugins/Satellites/src/Satellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2840,11 +2840,25 @@ void Satellites::update(double deltaTime)
sat->update(core, JD);
}
#else
const auto updateSat = [this, JD](QSharedPointer<Satellite>& sat){
if (sat->initialized && sat->displayed)
sat->update(core, JD);
};
QtConcurrent::blockingMap(QThreadPool::globalInstance(), satellites, updateSat);
// TODO: sat->update is an obvious candidate for parallelisation and without orbits, it indeed helps a lot.
// Unfortunately, the call to Satellite::computeOrbitPoints(); uses static variables, which messes up the orbit lines.
// We can compute satellites in parallel, but only if orbits are suppressed, until this is fixed.
if (getFlagOrbitLines())
{
for (const auto& sat : std::as_const(satellites))
{
if (sat->initialized && sat->displayed)
sat->update(core, JD);
}
}
else
{
const auto updateSat = [this, JD](QSharedPointer<Satellite>& sat){
if (sat->initialized && sat->displayed)
sat->update(core, JD);
};
QtConcurrent::blockingMap(QThreadPool::globalInstance(), satellites, updateSat);
}
#endif
}

Expand Down

0 comments on commit 6b003f7

Please sign in to comment.