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: 2a8169acb701
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 850c0ec8684e
Choose a head ref
  • 12 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 7, 2017

  1. trying it with packed

    eggrobin committed Mar 7, 2017
    Copy the full SHA
    4d46cad View commit details
  2. journalling is broken

    eggrobin committed Mar 7, 2017
    Copy the full SHA
    8cd7e24 View commit details
  3. merge

    eggrobin committed Mar 7, 2017
    Copy the full SHA
    f26e01f View commit details
  4. prepare

    eggrobin committed Mar 7, 2017
    Copy the full SHA
    b4411ad View commit details

Commits on Mar 8, 2017

  1. call it for all vessels

    eggrobin committed Mar 8, 2017
    Copy the full SHA
    941d6bd View commit details
  2. trickybugs

    eggrobin committed Mar 8, 2017
    Copy the full SHA
    16a04b6 View commit details
  3. deconst

    eggrobin committed Mar 8, 2017
    Copy the full SHA
    1e07814 View commit details
  4. Understand a bug!

    eggrobin committed Mar 8, 2017
    Copy the full SHA
    c2411fb View commit details
  5. Copy the full SHA
    e9ffa55 View commit details
  6. remove spammy traces

    eggrobin committed Mar 8, 2017
    Copy the full SHA
    0c052cb View commit details
  7. After pleroy's review

    eggrobin committed Mar 8, 2017
    Copy the full SHA
    e9bf9f2 View commit details
  8. Merge pull request #1232 from eggrobin/test-the-things

    Encountering further bugs
    eggrobin authored Mar 8, 2017
    Copy the full SHA
    850c0ec View commit details
Showing with 46 additions and 17 deletions.
  1. +4 −0 ksp_plugin/part.cpp
  2. +2 −0 ksp_plugin/pile_up.cpp
  3. +4 −1 ksp_plugin/plugin.cpp
  4. +15 −2 ksp_plugin/vessel.cpp
  5. +14 −5 ksp_plugin/vessel.hpp
  6. +7 −9 ksp_plugin_adapter/ksp_plugin_adapter.cs
4 changes: 4 additions & 0 deletions ksp_plugin/part.cpp
Original file line number Diff line number Diff line change
@@ -84,6 +84,8 @@ void Part::set_tail_is_authoritative(bool const tail_is_authoritative) {

void Part::set_containing_pile_up(IteratorOn<std::list<PileUp>> const pile_up) {
CHECK(!is_piled_up());
LOG(INFO) << "Adding part " << part_id_ << " to the pile up at "
<< &*pile_up.iterator();
containing_pile_up_ = pile_up;
}

@@ -101,6 +103,8 @@ void Part::clear_pile_up() {
if (is_piled_up()) {
IteratorOn<std::list<PileUp>> pile_up = *containing_pile_up_;
for (not_null<Part*> const part : pile_up.iterator()->parts()) {
LOG(INFO) << "Removing part " << part->part_id()
<< " from its pile up at " << &*pile_up.iterator();
part->containing_pile_up_ = std::experimental::nullopt;
}
CHECK(!is_piled_up());
2 changes: 2 additions & 0 deletions ksp_plugin/pile_up.cpp
Original file line number Diff line number Diff line change
@@ -175,6 +175,8 @@ void PileUp::AdvanceTime(
}

void PileUp::NudgeParts() const {
// TODO(egg): this is wrong! when we have computed a prolongation, we must use
// it here...
auto const actual_centre_of_mass =
psychohistory_->last().degrees_of_freedom();

5 changes: 4 additions & 1 deletion ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -417,6 +417,8 @@ void Plugin::InsertUnloadedPart(
1 * Kilogram,
vessel->parent()->current_degrees_of_freedom(current_time_) +
relative);
// NOTE(egg): we do not keep the part; it may disappear just as we load, if
// it happens to be a part with no physical significance (rb == null).
not_null<Part*> const part = vessel->part(part_id);
Subset<Part>::MakeSingleton(*part, part);
}
@@ -435,7 +437,6 @@ void Plugin::InsertOrKeepLoadedPart(
not_null<Vessel*>& associated_vessel = it->second;
not_null<Vessel*> const current_vessel = associated_vessel;
if (vessel == current_vessel) {
vessel->KeepPart(part_id);
} else {
associated_vessel = vessel;
vessel->AddPart(current_vessel->ExtractPart(part_id));
@@ -464,6 +465,7 @@ void Plugin::InsertOrKeepLoadedPart(
mass,
world_to_barycentric(part_degrees_of_freedom));
}
vessel->KeepPart(part_id);
not_null<Part*> part = vessel->part(part_id);
part->set_mass(mass);
Subset<Part>::MakeSingleton(*part, part);
@@ -483,6 +485,7 @@ void Plugin::FreeVesselsAndPartsAndCollectPileUps() {
for (auto it = vessels_.cbegin(); it != vessels_.cend();) {
not_null<Vessel*> vessel = it->second.get();
if (kept_vessels_.erase(vessel)) {
vessel->PreparePsychohistory(current_time_);
++it;
} else {
CHECK(!is_loaded(vessel));
17 changes: 15 additions & 2 deletions ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@ void Vessel::set_parent(not_null<Celestial const*> const parent) {
void Vessel::AddPart(not_null<std::unique_ptr<Part>> part) {
PartId const id = part->part_id();
LOG(INFO) << "Adding part " << id << " to vessel at " << this;
kept_parts_.insert(part.get());
parts_.emplace(id, std::move(part));
}

@@ -72,8 +71,9 @@ void Vessel::KeepPart(PartId const id) {

void Vessel::FreeParts() {
for (auto it = parts_.begin(); it != parts_.end();) {
not_null<Part const*> part = it->second.get();
not_null<Part*> part = it->second.get();
if (kept_parts_.count(part) == 0) {
part->clear_pile_up();
it = parts_.erase(it);
} else {
++it;
@@ -83,6 +83,19 @@ void Vessel::FreeParts() {
kept_parts_.clear();
}

void Vessel::PreparePsychohistory(Instant const& t) {
CHECK(!parts_.empty());
if (psychohistory_->Size() == 0) {
LOG(INFO) << "Preparing psychohistory of vessel at " << this;
BarycentreCalculator<DegreesOfFreedom<Barycentric>, Mass> calculator;
ForAllParts([&calculator](Part& part) {
calculator.Add(part.degrees_of_freedom(), part.mass());
});
psychohistory_->Append(t, calculator.Get());
psychohistory_is_authoritative_ = true;
}
}

not_null<Part*> Vessel::part(PartId const id) const {
return FindOrDie(parts_, id).get();
}
19 changes: 14 additions & 5 deletions ksp_plugin/vessel.hpp
Original file line number Diff line number Diff line change
@@ -57,7 +57,9 @@ class Vessel {
virtual not_null<Celestial const*> parent() const;
virtual void set_parent(not_null<Celestial const*> parent);

// Adds the given part to this vessel.
// Adds the given part to this vessel. Note that this does not add the part
// to the set of kept parts, and that unless |KeepPart| is called, the part
// will be removed by the next call to |FreeParts|.
virtual void AddPart(not_null<std::unique_ptr<Part>> part);
// Removes and returns the part with the given ID. This may empty |parts_|,
// as happens when a vessel ceases to exist while loaded. Note that in that
@@ -66,12 +68,19 @@ class Vessel {
// Prevents the part with the given ID from being removed in the next call to
// |FreeParts|.
virtual void KeepPart(PartId id);
// Removes any part for which |AddPart| or |KeepPart| has not been called
// since the last call to |FreePart|. Checks that there are still parts left
// after the removals; thus a call to |AddPart| must occur before |FreeParts|
// is first called.
// Removes any part for which |KeepPart| has not been called since the last
// call to |FreePart|. Checks that there are still parts left after the
// removals; thus a call to |AddPart| must occur before |FreeParts| is first
// called.
virtual void FreeParts();

// If the psychohistory is empty, appends a single authoritative point to it,
// computed as the barycentre of all parts. |parts_| must not be empty.
// After this call, |psychohistory_| is never empty again.
// TODO(egg): ... except ForgetBefore. This will break things, so
// ForgetBefore should not clear the psychohistory altogether.
virtual void PreparePsychohistory(Instant const& t);

// Returns the part with the given ID. Such a part must have been added using
// |AddPart|.
virtual not_null<Part*> part(PartId id) const;
16 changes: 7 additions & 9 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -728,10 +728,11 @@ private System.Collections.IEnumerator
// physics simulation, which is why we report them before calling
// |AdvanceTime|.
foreach (Vessel vessel1 in FlightGlobals.VesselsLoaded) {
if (plugin_.HasVessel(vessel1.id.ToString())) {
if (plugin_.HasVessel(vessel1.id.ToString()) && !vessel1.packed) {
if (vessel1.isEVA && vessel1.evaController.OnALadder) {
var vessel2 = vessel1.evaController.LadderPart.vessel;
if (vessel2 != null && plugin_.HasVessel(vessel2.id.ToString())) {
if (vessel2 != null && plugin_.HasVessel(vessel2.id.ToString()) &&
!vessel2.packed) {
plugin_.ReportCollision(vessel1.rootPart.flightID,
vessel1.evaController.LadderPart.flightID);
}
@@ -794,7 +795,7 @@ private System.Collections.IEnumerator
// TODO(egg): if I understand anything, there should probably be a
// special treatment for loaded packed vessels. I don't understand
// anything though.
if (!vessel.loaded || !plugin_.HasVessel(vessel.id.ToString())) {
if (vessel.packed || !plugin_.HasVessel(vessel.id.ToString())) {
continue;
}
foreach (Part part in vessel.parts) {
@@ -815,7 +816,7 @@ private System.Collections.IEnumerator
part.rb.velocity = (Vector3d)part_actual_degrees_of_freedom.p;
}
}
if (has_active_vessel_in_space() && FlightGlobals.ActiveVessel.loaded) {
if (has_active_vessel_in_space() && !FlightGlobals.ActiveVessel.packed) {
QP main_body_dof = plugin_.CelestialWorldDegreesOfFreedom(
FlightGlobals.ActiveVessel.mainBody.flightGlobalsIndex);
Log.Error("change in framevel: " +
@@ -867,14 +868,11 @@ private void ReportVesselsAndParts() {
if (PluginRunning()) {
foreach (Vessel vessel in FlightGlobals.Vessels.Where(is_in_space)) {
bool inserted;
// WTF? or should I use !packed?
bool actually_loaded_with_real_parts =
vessel.loaded && !vessel.parts.TrueForAll(part => part.rb == null);
plugin_.InsertOrKeepVessel(vessel.id.ToString(),
vessel.mainBody.flightGlobalsIndex,
actually_loaded_with_real_parts,
!vessel.packed,
out inserted);
if (actually_loaded_with_real_parts) {
if (!vessel.packed) {
QP main_body_degrees_of_freedom =
new QP{q = (XYZ)vessel.mainBody.position,
p = (XYZ)(-krakensbane.FrameVel)};