Skip to content

Commit

Permalink
Revert "Merge branch 'development'"
Browse files Browse the repository at this point in the history
This reverts commit 5c190a2, reversing
changes made to 38c1607.
  • Loading branch information
Ezriilc committed Jul 13, 2018
1 parent 3863564 commit 80e6151
Show file tree
Hide file tree
Showing 17 changed files with 1,543 additions and 1,652 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -15,7 +15,6 @@ DTAR*/
*.userprefs

HyperEdit.fronbow.*
todo.md

# Build results
[Dd]ebug/
Expand Down
62 changes: 53 additions & 9 deletions Source/Core.cs
Expand Up @@ -12,8 +12,7 @@
[assembly: System.Reflection.AssemblyDescription("A plugin mod for Kerbal Space Program")]
[assembly: System.Reflection.AssemblyCompany("Kerbaltek")]
[assembly: System.Reflection.AssemblyCopyright("Erickson Swift")]
[assembly: System.Reflection.AssemblyVersion("1.5.8")]
[assembly: System.Reflection.AssemblyFileVersion("1.5.8")]
[assembly: System.Reflection.AssemblyVersion("1.5.6.01")]

[KSPAddon(KSPAddon.Startup.SpaceCentre, true)] // Determines when plugin starts.
public class HyperEditModule : MonoBehaviour {
Expand Down Expand Up @@ -84,12 +83,12 @@ public class HyperEditBehaviour : MonoBehaviour {

public HyperEditBehaviour() // Constructor. Don't init data here cuz Unity, do so in Awake();
{
//Extensions.Log("[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.0000") + "]: Constructor()");
// Extensions.Log("[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.0000") + "]: Constructor()");
}

public void Awake() // Called after scene (designated w/ KSPAddon) loads, but before Start(). Init data here.
{
//Extensions.Log("[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.0000") + "]: Awake()");
// Extensions.Log("[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.0000") + "]: Awake()");
View.Window.AreWindowsOpenChange += AreWindowsOpenChange;
GameEvents.onGUIApplicationLauncherReady.Add(AddAppLauncher);
GameEvents.onGUIApplicationLauncherDestroyed.Add(RemoveAppLauncher);
Expand All @@ -100,7 +99,6 @@ public class HyperEditBehaviour : MonoBehaviour {
{
//Extensions.Log("[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.0000") + "]: Start()");
ReloadConfig();
Model.PlanetEditor.TryApplyFileDefaults();
}

private void CreateCoreView() {
Expand Down Expand Up @@ -267,10 +265,10 @@ public class HyperEditBehaviour : MonoBehaviour {

public static class IoExt {
private static readonly string PluginDir = System.IO.Path.Combine(System.IO.Path.ChangeExtension(typeof(IoExt).Assembly.Location, null), "..");
private static readonly string PluginDataDir = System.IO.Path.Combine(PluginDir, "HyperEdit");
private static readonly string PluginDataDir = System.IO.Path.Combine(PluginDir, "PluginData");

//private static readonly string RootDir = System.IO.Path.Combine(System.IO.Path.ChangeExtension(typeof(IoExt).Assembly.Location, null), "HyperEdit");
private static readonly string RootDir = PluginDataDir;
//private static readonly string RootDir = System.IO.Path.Combine(System.IO.Path.ChangeExtension(typeof(IoExt).Assembly.Location, null), "PluginData");
private static readonly string RootDir = PluginDataDir;

static IoExt() {
if (!System.IO.Directory.Exists(RootDir)) {
Expand Down Expand Up @@ -557,7 +555,53 @@ public static class Extensions {
return false;
}

/// Borrowed from https://github.com/KSP-KOS/KOS.
/// <summary>
/// Fix the strange too-large or too-small angle degrees that are sometimes
/// returned by KSP, normalizing them into a constrained 360 degree range.
/// </summary>
/// <param name="inAngle">input angle in degrees</param>
/// <param name="rangeStart">
/// Bottom of 360 degree range to normalize to.
/// ( 0 means the range [0..360]), while -180 means [-180,180] )
/// </param>
/// <returns>the same angle, normalized to the range given.</returns>
public static double DegreeFix(double inAngle, double rangeStart) {
double rangeEnd = rangeStart + 360.0;
double outAngle = inAngle;
while (outAngle > rangeEnd)
outAngle -= 360.0;
while (outAngle < rangeStart)
outAngle += 360.0;
return outAngle;
}


}


public static class Utils {
/// Borrowed from https://github.com/KSP-KOS/KOS.
/// <summary>
/// Fix the strange too-large or too-small angle degrees that are sometimes
/// returned by KSP, normalizing them into a constrained 360 degree range.
/// </summary>
/// <param name="inAngle">input angle in degrees</param>
/// <param name="rangeStart">
/// Bottom of 360 degree range to normalize to.
/// ( 0 means the range [0..360]), while -180 means [-180,180] )
/// </param>
/// <returns>the same angle, normalized to the range given.</returns>
public static double DegreeFix(double inAngle, double rangeStart) {
double rangeEnd = rangeStart + 360.0;
double outAngle = inAngle;
while (outAngle > rangeEnd)
outAngle -= 360.0;
while (outAngle < rangeStart)
outAngle += 360.0;
return outAngle;
}



}
}
30 changes: 11 additions & 19 deletions Source/Model/Lander.cs
Expand Up @@ -173,7 +173,7 @@ public static class DoLander {
public static void LoadLast(Action<double, double, double, CelestialBody> onLoad) {
var lastC = SavedCoords.Find(c => c.Name == RecentEntryName);
//double-check coords are correct (so that we don't load invalid data!)
onLoad(Utils.DegreeFix(lastC.Lat,0) , lastC.Lon, lastC.Alt, lastC.Body);
onLoad(Extensions.DegreeFix(lastC.Lat,0) , lastC.Lon, lastC.Alt, lastC.Body);
}

public static void Load(Action<double, double, double, CelestialBody> onLoad) {
Expand Down Expand Up @@ -382,9 +382,7 @@ public class LanderAttachment : MonoBehaviour {
}

// 0.2 meters per frame
//var degrees = Math.Round(0.02 / Body.Radius * (180 / Math.PI), 6);
// approx 1m
var degrees = Math.Round(0.1 / Body.Radius * (180 / Math.PI), 6);
var degrees = 0.2 / Body.Radius * (180 / Math.PI);

var changed = false;
if (GameSettings.TRANSLATE_UP.GetKey()) {
Expand All @@ -396,11 +394,11 @@ public class LanderAttachment : MonoBehaviour {
changed = true;
}
if (GameSettings.TRANSLATE_LEFT.GetKey()) {
Longitude -= degrees;
Longitude -= degrees / Math.Cos(Latitude * (Math.PI / 180));
changed = true;
}
if (GameSettings.TRANSLATE_RIGHT.GetKey()) {
Longitude += degrees;
Longitude += degrees / Math.Cos(Latitude * (Math.PI / 180));
changed = true;
}

Expand Down Expand Up @@ -463,8 +461,6 @@ public class LanderAttachment : MonoBehaviour {
var checkPQSAlt = FlightGlobals.ActiveVessel.pqsAltitude;
double terrainAlt = GetTerrainAltitude();

//double vesselHeight = Bounds[vessel.id]

Extensions.ALog("-------------------");
Extensions.ALog("m1. Body.Radius = ", Body.Radius);
Extensions.ALog("m2. PQS SurfaceHeight = ", pqs.GetSurfaceHeight(Body.GetRelSurfaceNVector(Latitude, Longitude)));
Expand Down Expand Up @@ -609,21 +605,19 @@ public class LanderAttachment : MonoBehaviour {
teleportVelocity += teleportPosition.normalized * (Body.gravParameter / teleportPosition.sqrMagnitude);

Quaternion rotation;

vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, false); //disable SAS as it causes unknown results!



if (SetRotation) {
// Need to check vessel and find up for the root command pod
var up = vessel.upAxis;
var vType = vessel.vesselType.ToString();

vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, false); //hopefully this disables SAS as it causes unknown results!

var from = Vector3d.up; //Sensible default for all vessels

if (vessel.displaylandedAt == "Runway" ||
(vessel.vesselType.ToString() == "Plane" || vessel.vesselType.ToString() == "Rover" || vessel.vesselType.ToString() == "Base") ) {
if (vessel.displaylandedAt == "Runway" || vessel.vesselType.ToString() == "Plane") {
from = vessel.vesselTransform.up;
}



var to = teleportPosition.xzy.normalized;
rotation = Quaternion.FromToRotation(from, to);
} else {
Expand All @@ -638,8 +632,6 @@ public class LanderAttachment : MonoBehaviour {
vessel.SetOrbit(orbit);
vessel.SetRotation(rotation);

vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, true); //enable SAS for stability

if (teleportedToLandingAlt) {
AlreadyTeleported = true;
Extensions.Log(" :FINISHED TELEPORTING:");
Expand Down

0 comments on commit 80e6151

Please sign in to comment.