Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 11c7cbf53b51
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c5a999f27211
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 12, 2021

  1. Cleanup.

    pleroy committed Jun 12, 2021
    Copy the full SHA
    4888d7e View commit details
  2. Merge pull request #3031 from pleroy/Cleanup

    Some cleanups in class Vessel
    pleroy authored Jun 12, 2021
    Copy the full SHA
    c5a999f View commit details
Showing with 61 additions and 48 deletions.
  1. +41 −41 ksp_plugin/vessel.cpp
  2. +20 −7 ksp_plugin/vessel.hpp
82 changes: 41 additions & 41 deletions ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
@@ -363,6 +363,47 @@ void Vessel::StopPrognosticator() {
prognosticator_.Stop();
}

void Vessel::RequestOrbitAnalysis(Time const& mission_duration) {
if (!orbit_analyser_.has_value()) {
// TODO(egg): perhaps we should get the history parameters from the plugin;
// on the other hand, these are probably overkill for high orbits anyway,
// and given that we know many things about our trajectory in the analyser,
// perhaps we should pick something appropriate automatically instead. The
// default will do in the meantime.
orbit_analyser_.emplace(ephemeris_, DefaultHistoryParameters());
}
if (orbit_analyser_->last_parameters().has_value() &&
orbit_analyser_->last_parameters()->mission_duration !=
mission_duration) {
orbit_analyser_->Interrupt();
}
orbit_analyser_->RequestAnalysis(
{.first_time = psychohistory_->back().time,
.first_degrees_of_freedom = psychohistory_->back().degrees_of_freedom,
.mission_duration = mission_duration});
}

void Vessel::ClearOrbitAnalyser() {
orbit_analyser_.reset();
}

double Vessel::progress_of_orbit_analysis() const {
if (!orbit_analyser_.has_value()) {
return 0;
}
return orbit_analyser_->progress_of_next_analysis();
}

void Vessel::RefreshOrbitAnalysis() {
if (orbit_analyser_.has_value()) {
orbit_analyser_->RefreshAnalysis();
}
}

OrbitAnalyser::Analysis* Vessel::orbit_analysis() {
return orbit_analyser_.has_value() ? orbit_analyser_->analysis() : nullptr;
}

std::string Vessel::ShortDebugString() const {
return name_ + " (" + guid_ + ")";
}
@@ -486,47 +527,6 @@ void Vessel::FillContainingPileUpsFromMessage(
}
}

void Vessel::RequestOrbitAnalysis(Time const& mission_duration) {
if (!orbit_analyser_.has_value()) {
// TODO(egg): perhaps we should get the history parameters from the plugin;
// on the other hand, these are probably overkill for high orbits anyway,
// and given that we know many things about our trajectory in the analyser,
// perhaps we should pick something appropriate automatically instead. The
// default will do in the meantime.
orbit_analyser_.emplace(ephemeris_, DefaultHistoryParameters());
}
if (orbit_analyser_->last_parameters().has_value() &&
orbit_analyser_->last_parameters()->mission_duration !=
mission_duration) {
orbit_analyser_->Interrupt();
}
orbit_analyser_->RequestAnalysis(
{.first_time = psychohistory_->back().time,
.first_degrees_of_freedom = psychohistory_->back().degrees_of_freedom,
.mission_duration = mission_duration});
}

void Vessel::ClearOrbitAnalyser() {
orbit_analyser_.reset();
}

double Vessel::progress_of_orbit_analysis() const {
if (!orbit_analyser_.has_value()) {
return 0;
}
return orbit_analyser_->progress_of_next_analysis();
}

void Vessel::RefreshOrbitAnalysis() {
if (orbit_analyser_.has_value()) {
orbit_analyser_->RefreshAnalysis();
}
}

OrbitAnalyser::Analysis* Vessel::orbit_analysis() {
return orbit_analyser_.has_value() ? orbit_analyser_->analysis() : nullptr;
}

void Vessel::MakeAsynchronous() {
synchronous_ = false;
}
27 changes: 20 additions & 7 deletions ksp_plugin/vessel.hpp
Original file line number Diff line number Diff line change
@@ -97,6 +97,7 @@ class Vessel {
// called.
virtual void FreeParts();

// Clears the forces and torques on all parts.
virtual void ClearAllIntrinsicForcesAndTorques();

// If the history is empty, appends a single point to it, computed as the
@@ -171,6 +172,25 @@ class Vessel {
// Stop the asynchronous prognosticator as soon as convenient.
void StopPrognosticator();

// Stops any analyser running for a different mission duration and triggers a
// new analysis.
void RequestOrbitAnalysis(Time const& mission_duration);

// Stops the analyser.
void ClearOrbitAnalyser();

// Returns a number between 0 and 1 indicating how far we are within the
// current analysis.
double progress_of_orbit_analysis() const;

// Prepares the last completed analysis so that will be returned by
// |orbit_analysis|.
// TODO(phl): This API is weird. Why does the caller need a 2-step dance?
void RefreshOrbitAnalysis();

// Returns the latest completed analysis, if there is one.
OrbitAnalyser::Analysis* orbit_analysis();

// Returns "vessel_name (GUID)".
std::string ShortDebugString() const;

@@ -188,13 +208,6 @@ class Vessel {
PileUp::PileUpForSerializationIndex const&
pile_up_for_serialization_index);

void RequestOrbitAnalysis(Time const& mission_duration);
void ClearOrbitAnalyser();

double progress_of_orbit_analysis() const;
void RefreshOrbitAnalysis();
OrbitAnalyser::Analysis* orbit_analysis();

static void MakeAsynchronous();
static void MakeSynchronous();