Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the stc parser #2201

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/celengine/body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@ float Body::getTemperature(double time) const
}
else // the sun is a barycenter
{
const auto* orbitingStars = sun->getOrbitingStars();
if (orbitingStars == nullptr || orbitingStars->empty())
auto orbitingStars = sun->getOrbitingStars();
if (orbitingStars.empty())
return 0.0f;

const UniversalCoord bodyPos = getPosition(time);
float flux = 0.0f;
for (const auto *s : *orbitingStars)
for (const auto *s : orbitingStars)
{
float distFromSun = (float)s->getPosition(time).distanceFromKm(bodyPos);
float lum = math::square(s->getRadius()) * pow(s->getTemperature(), 4.0f);
Expand Down
20 changes: 9 additions & 11 deletions src/celengine/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,17 +1117,15 @@ static double getPreferredDistance(const Selection& selection)
{
// Handle star system barycenters specially, using the same approach as
// for reference points in solar systems.
const std::vector<Star*>* orbitingStars = selection.star()->getOrbitingStars();
double maxOrbitRadius = orbitingStars == nullptr
? 0.0
: std::accumulate(orbitingStars->begin(), orbitingStars->end(), 0.0,
[](double r, const Star* s)
{
const celestia::ephem::Orbit* orbit = s->getOrbit();
return orbit == nullptr
? r
: std::max(r, orbit->getBoundingRadius());
});
auto orbitingStars = selection.star()->getOrbitingStars();
double maxOrbitRadius = std::accumulate(orbitingStars.begin(), orbitingStars.end(), 0.0,
[](double r, const Star* s)
{
const celestia::ephem::Orbit* orbit = s->getOrbit();
return orbit == nullptr
? r
: std::max(r, orbit->getBoundingRadius());
});

return maxOrbitRadius == 0.0 ? astro::AUtoKilometers(1.0) : maxOrbitRadius * 5.0;
}
Expand Down
Loading
Loading