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

Commits on Apr 13, 2019

  1. Copy the full SHA
    f926599 View commit details

Commits on Apr 14, 2019

  1. Copy the full SHA
    38f4f73 View commit details
  2. Copy the full SHA
    1774170 View commit details
  3. Merge.

    pleroy committed Apr 14, 2019
    Copy the full SHA
    8608d84 View commit details

Commits on Apr 17, 2019

  1. After egg's review.

    pleroy committed Apr 17, 2019
    Copy the full SHA
    46c0520 View commit details
  2. Merge pull request #2136 from pleroy/1565

    Render the guidance node in the adapter and not in the flight planner
    pleroy authored Apr 17, 2019
    Copy the full SHA
    c210223 View commit details
Showing with 209 additions and 160 deletions.
  1. +20 −59 ksp_plugin_adapter/flight_planner.cs
  2. +188 −101 ksp_plugin_adapter/ksp_plugin_adapter.cs
  3. +1 −0 ksp_plugin_adapter/main_window.cs
79 changes: 20 additions & 59 deletions ksp_plugin_adapter/flight_planner.cs
Original file line number Diff line number Diff line change
@@ -35,6 +35,26 @@ public void RenderButton() {
}
}

public bool show_guidance { get => show_guidance_; }

public override void Load(ConfigNode node) {
base.Load(node);

String show_guidance_value =
node.GetAtMostOneValue("show_guidance");
if (show_guidance_value != null) {
show_guidance_ = Convert.ToBoolean(show_guidance_value);
}
}

public override void Save(ConfigNode node) {
base.Save(node);

node.SetValue("show_guidance",
show_guidance_,
createIfNotFound : true);
}

protected override String Title => "Flight plan";

protected override void RenderWindow(int window_id) {
@@ -270,7 +290,6 @@ private void RenderFlightPlan(string vessel_guid) {
private void RenderUpcomingEvents() {
string vessel_guid = vessel_.id.ToString();
double current_time = plugin.CurrentTime();
bool should_clear_guidance = true;

Style.HorizontalLine();
if (first_future_manoeuvre_.HasValue) {
@@ -309,8 +328,6 @@ private void RenderUpcomingEvents() {
TimeWarp.fetch.WarpTo(manoeuvre.burn.initial_time - 60);
}
}
should_clear_guidance &= ShowGuidance(manoeuvre,
first_future_manoeuvre);
}
} else {
// Reserve some space to avoid the UI changing shape if we have
@@ -319,61 +336,6 @@ private void RenderUpcomingEvents() {
Style.Warning(UnityEngine.GUI.skin.label));
UnityEngine.GUILayout.Space(Width(1));
}

if (should_clear_guidance && guidance_node_ != null) {
guidance_node_.RemoveSelf();
guidance_node_ = null;
}
}

// Returns true iff the guidance node should be cleared.
internal bool ShowGuidance(NavigationManoeuvre manoeuvre,
int manoeuvre_index) {
string vessel_guid = vessel_.id.ToString();
XYZ guidance = plugin.FlightPlanGetGuidance(vessel_guid, manoeuvre_index);
if (show_guidance_ &&
!double.IsNaN(guidance.x + guidance.y + guidance.z)) {
if (guidance_node_ == null ||
!vessel_.patchedConicSolver.maneuverNodes.Contains(
guidance_node_)) {
while (vessel_.patchedConicSolver.maneuverNodes.Count > 0) {
vessel_.patchedConicSolver.maneuverNodes.Last().RemoveSelf();
}
guidance_node_ = vessel_.patchedConicSolver.AddManeuverNode(
manoeuvre.burn.initial_time);
} else if (vessel_.patchedConicSolver.maneuverNodes.Count > 1) {
while (vessel_.patchedConicSolver.maneuverNodes.Count > 1) {
if (vessel_.patchedConicSolver.maneuverNodes.First() ==
guidance_node_) {
vessel_.patchedConicSolver.maneuverNodes.Last().RemoveSelf();
} else {
vessel_.patchedConicSolver.maneuverNodes.First().RemoveSelf();
}
}
}
var stock_orbit = guidance_node_.patch;
Vector3d stock_velocity_at_node_time =
stock_orbit.getOrbitalVelocityAtUT(
manoeuvre.burn.initial_time).xzy;
Vector3d stock_displacement_from_parent_at_node_time =
stock_orbit.getRelativePositionAtUT(
manoeuvre.burn.initial_time).xzy;
UnityEngine.Quaternion stock_frenet_frame_to_world =
UnityEngine.Quaternion.LookRotation(
stock_velocity_at_node_time,
Vector3d.Cross(
stock_velocity_at_node_time,
stock_displacement_from_parent_at_node_time));
guidance_node_.DeltaV =
((Vector3d)manoeuvre.burn.delta_v).magnitude *
(Vector3d)(UnityEngine.Quaternion.Inverse(
stock_frenet_frame_to_world) *
(Vector3d)guidance);
guidance_node_.UT = manoeuvre.burn.initial_time;
vessel_.patchedConicSolver.UpdateFlightPlan();
return false;
}
return true;
}

internal static string FormatPositiveTimeSpan (TimeSpan span) {
@@ -453,7 +415,6 @@ internal bool TryParsePlanLength(string str, out double value) {
private int? first_future_manoeuvre_;

private bool show_guidance_ = false;
private ManeuverNode guidance_node_;

private const double log10_time_lower_rate = 0.0;
private const double log10_time_upper_rate = 7.0;
Loading