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

Commits on Mar 21, 2017

  1. Copy the full SHA
    d3c0324 View commit details
  2. Copy the full SHA
    eb7240d View commit details
  3. TODO

    eggrobin committed Mar 21, 2017
    Copy the full SHA
    8e5a13d View commit details
  4. Copy the full SHA
    5a40d19 View commit details
  5. killing the gravitic thing is a bad idea, it makes the non-part thing…

    …s (physicalObjects) fly everywhere. Maybe someday we should handle those, but that seems really tedious
    eggrobin committed Mar 21, 2017
    Copy the full SHA
    ea71f5a View commit details
  6. This does not fix the issue, so let's revert it

    This reverts commit ea71f5a.
    eggrobin committed Mar 21, 2017
    Copy the full SHA
    b876eb9 View commit details
  7. blarg.

    This reverts commit 5a40d19.
    eggrobin committed Mar 21, 2017
    Copy the full SHA
    8c23581 View commit details
  8. Copy the full SHA
    c492293 View commit details
  9. rename rename

    eggrobin committed Mar 21, 2017
    Copy the full SHA
    699ec4a View commit details
  10. Merge pull request #1276 from eggrobin/names

    Names
    eggrobin authored Mar 21, 2017
    Copy the full SHA
    d45cafb View commit details
Showing with 41 additions and 7 deletions.
  1. +3 −0 ksp_plugin/plugin.cpp
  2. +11 −0 ksp_plugin/vessel.cpp
  3. +6 −1 ksp_plugin/vessel.hpp
  4. +21 −6 ksp_plugin_adapter/ksp_plugin_adapter.cs
3 changes: 3 additions & 0 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -389,6 +389,9 @@ void Plugin::InsertOrKeepVessel(GUID const& vessel_guid,
ephemeris_.get(),
prediction_parameters_));
not_null<Vessel*> const vessel = it->second.get();
if (vessel->name() != vessel_name) {
vessel->set_name(vessel_name);
}
kept_vessels_.emplace(vessel);
vessel->set_parent(parent);
if (loaded) {
11 changes: 11 additions & 0 deletions ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ Vessel::Vessel(GUID const& guid,
prediction_(make_not_null_unique<DiscreteTrajectory<Barycentric>>()) {}

Vessel::~Vessel() {
LOG(INFO) << "Destroying vessel " << ShortDebugString();
// The parts must remove themselves from their pile-ups *before* any of them
// starts to destroy, otherwise |clear_pile_up| might access destroyed parts.
for (auto const& pair : parts_) {
@@ -58,6 +59,16 @@ GUID const& Vessel::guid() const {
return guid_;
}

std::string const& Vessel::name() const {
return name_;
}

void Vessel::set_name(std::string const& new_name) {
LOG(INFO) << "Vessel " << ShortDebugString() << " is now known as "
<< new_name;
name_ = new_name;
}

not_null<MasslessBody const*> Vessel::body() const {
return &body_;
}
7 changes: 6 additions & 1 deletion ksp_plugin/vessel.hpp
Original file line number Diff line number Diff line change
@@ -59,6 +59,11 @@ class Vessel {
// Returns the GUID passed at construction.
virtual GUID const& guid() const;

// Returns the name.
virtual std::string const& name() const;
// Changes the name.
virtual void set_name(std::string const& new_name);

// Returns the body for this vessel.
virtual not_null<MasslessBody const*> body() const;

@@ -166,7 +171,7 @@ class Vessel {
DiscreteTrajectory<Barycentric>::Iterator last_authoritative() const;

GUID const guid_;
std::string const name_;
std::string name_;

MasslessBody const body_;
Ephemeris<Barycentric>::AdaptiveStepParameters
27 changes: 21 additions & 6 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -423,8 +423,6 @@ public override void OnLoad(ConfigNode node) {
String[] serializations = node.GetValues(principia_key);
Log.Info("Serialization has " + serializations.Length + " chunks");
foreach (String serialization in serializations) {
Log.Info("serialization is " + serialization.Length +
" characters long");
Interface.DeserializePlugin(serialization,
serialization.Length,
ref deserializer,
@@ -834,8 +832,8 @@ private System.Collections.IEnumerator
// transforms of loaded vessels & their parts.
if (has_active_vessel_in_space() && !FlightGlobals.ActiveVessel.packed &&
plugin_.HasVessel(FlightGlobals.ActiveVessel.id.ToString())) {
// TODO(egg): move this to the C++, this is just to check that I
// understand the issue.
Vector3d q_correction_at_root_part = Vector3d.zero;
Vector3d v_correction_at_root_part = Vector3d.zero;
foreach (Vessel vessel in FlightGlobals.VesselsLoaded) {
// TODO(egg): if I understand anything, there should probably be a
// special treatment for loaded packed vessels. I don't understand
@@ -848,13 +846,28 @@ private System.Collections.IEnumerator
continue;
}
QP part_actual_degrees_of_freedom =
plugin_.GetPartActualDegreesOfFreedom(part.flightID, FlightGlobals.ActiveVessel.rootPart.flightID);
plugin_.GetPartActualDegreesOfFreedom(
part.flightID,
FlightGlobals.ActiveVessel.rootPart.flightID);
if (part == FlightGlobals.ActiveVessel.rootPart) {
q_correction_at_root_part =
(Vector3d)part_actual_degrees_of_freedom.q - part.rb.position;
v_correction_at_root_part =
(Vector3d)part_actual_degrees_of_freedom.p - part.rb.velocity;
}

// TODO(egg): use the centre of mass. Here it's a bit tedious, some
// transform nonsense must probably be done.
part.rb.position = (Vector3d)part_actual_degrees_of_freedom.q;
part.rb.velocity = (Vector3d)part_actual_degrees_of_freedom.p;
}
}
foreach (physicalObject physical_object in
FlightGlobals.physicalObjects.Where(o => o != null &&
o.rb != null)) {
physical_object.rb.position += q_correction_at_root_part;
physical_object.rb.velocity += v_correction_at_root_part;
}
QP main_body_dof = plugin_.CelestialWorldDegreesOfFreedom(
FlightGlobals.ActiveVessel.mainBody.flightGlobalsIndex,
FlightGlobals.ActiveVessel.rootPart.flightID);
@@ -948,7 +961,7 @@ private void ReportVesselsAndParts() {
foreach (Part part in vessel.parts.Where((part) => part.rb != null)) {
plugin_.InsertOrKeepLoadedPart(
part.flightID,
part.partName,
part.name,
part.physicsMass,
vessel.id.ToString(),
vessel.mainBody.flightGlobalsIndex,
@@ -965,6 +978,8 @@ private void ReportVesselsAndParts() {
} else if (inserted) {
foreach (ProtoPartSnapshot part in
vessel.protoVessel.protoPartSnapshots) {
// TODO(egg): perhaps we can live with the asteroids if we detect
// them here and reassign their flightID.
plugin_.InsertUnloadedPart(
part.flightID,
part.partName,