Skip to content

Commit

Permalink
start tweaking things, mention mockingbirdnest#1441
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Jul 16, 2017
1 parent 73a0cbf commit 3654108
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ksp_plugin/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void principia__AdvanceTime(Plugin* const plugin,
void principia__AdvanceParts(Plugin* const plugin, double const t) {
journal::Method<journal::AdvanceParts> m({plugin, t});
CHECK_NOTNULL(plugin);
plugin->AdvanceParts(FromGameTime(*plugin, t));
plugin->CatchUpLaggingPileUps(FromGameTime(*plugin, t));
return m.Return();
}

Expand Down
4 changes: 4 additions & 0 deletions ksp_plugin/pile_up.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ void PileUp::NudgeParts() const {
}
}

Instant const& PileUp::time() {
return psychohistory_->last().time();
}

void PileUp::WriteToMessage(not_null<serialization::PileUp*> message) const {
for (auto const part : parts_) {
message->add_part_id(part->part_id());
Expand Down
2 changes: 2 additions & 0 deletions ksp_plugin/pile_up.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class PileUp {
// |DeformPileUpIfNeeded|.
void NudgeParts() const;

Instant const& time();

void WriteToMessage(not_null<serialization::PileUp*> message) const;
static PileUp ReadFromMessage(
serialization::PileUp const& message,
Expand Down
22 changes: 11 additions & 11 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void Plugin::FreeVesselsAndPartsAndCollectPileUps() {
vessel.ForSomePart([this](Part& first_part) {
Subset<Part>::Find(first_part).mutable_properties().Collect(
&pile_ups_,
current_time_,
previous_time_,
DefaultProlongationParameters(),
DefaultHistoryParameters(),
ephemeris_.get());
Expand All @@ -533,17 +533,17 @@ void Plugin::SetPartApparentDegreesOfFreedom(
part, world_to_apparent_bubble(degrees_of_freedom));
}

void Plugin::AdvanceParts(Instant const& t) {
void Plugin::CatchUpLaggingPileUps() {
CHECK(!initializing_);
CHECK_GT(t, current_time_);

ephemeris_->Prolong(t);
for (PileUp& pile_up : pile_ups_) {
pile_up.DeformPileUpIfNeeded();
pile_up.AdvanceTime(t);
// TODO(egg): now that |NudgeParts| doesn't need the bubble barycentre
// anymore, it could be part of |PileUp::AdvanceTime|.
pile_up.NudgeParts();
if (pile_up.time() < current_time_) {
pile_up.DeformPileUpIfNeeded();
pile_up.AdvanceTime(current_time_);
// TODO(egg): now that |NudgeParts| doesn't need the bubble barycentre
// anymore, it could be part of |PileUp::AdvanceTime|.
pile_up.NudgeParts();
}
}
}

Expand Down Expand Up @@ -591,7 +591,7 @@ void Plugin::AdvanceTime(Instant const& t, Angle const& planetarium_rotation) {
CHECK_GT(t, current_time_);

// In some cases involving physics dewarping, the vessel may have an
// authoritative point in the future. Bail out early.
// authoritative point in the future, see #1441. Bail out early.
Instant last_authoritative_time = Instant() - Infinity<Time>();
for (auto const& pair : vessels_) {
Vessel const& vessel = *pair.second;
Expand All @@ -608,7 +608,7 @@ void Plugin::AdvanceTime(Instant const& t, Angle const& planetarium_rotation) {
tails_are_empty = part.tail().Empty();
});
if (tails_are_empty) {
AdvanceParts(t);
CatchUpLaggingPileUps(t);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ksp_plugin/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class Plugin {
// Advances time on the pile ups to |t|, filling the tails of all parts up to
// instant |t|. The vessels are unaffected, and |current_time_| remains
// unchanged.
virtual void AdvanceParts(Instant const& t);
virtual void CatchUpLaggingPileUps();

// Returns the degrees of freedom of the given part in |World|, assuming that
// the origin of |World| is fixed at the centre of mass of the
Expand All @@ -231,7 +231,7 @@ class Plugin {

// Simulates the system until instant |t|. Sets |current_time_| to |t|.
// Must be called after initialization.
// Calls |AdvanceParts| if it has not been called; otherwise the vessels are
// Calls |CatchUpLaggingPileUps| if it has not been called; otherwise the vessels are
// advanced using the tails previously computed during that call.
// Clears the intrinsic force on all loaded parts.
// |t| must be greater than |current_time_|. |planetarium_rotation| is the
Expand Down

0 comments on commit 3654108

Please sign in to comment.