Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* small improvements and contractWeight * not required anymore * contractWeight * fix logspam and contracts * not needed * avoid infinites * recompile * added version.cs * recompile * changelog and version * remove contracts crap from the plugin * now it's not my problem anymore * recompile * new version log and recompile
- Loading branch information
Showing
12 changed files
with
169 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
{ | ||
"MAJOR": 1, | ||
"MINOR": 6, | ||
"PATCH": 4, | ||
"PATCH": 5, | ||
"BUILD": 0 | ||
}, | ||
"KSP_VERSION": | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
|
||
namespace SigmaBinaryPlugin | ||
{ | ||
public class EncounterMathFixer | ||
{ | ||
public static int FindClosestPointsRevertedCauseNewOneSucks(Orbit p, Orbit s, ref double CD, ref double CCD, ref double FFp, ref double FFs, ref double SFp, ref double SFs, double epsilon, int maxIterations, ref int iterationCount) | ||
{ | ||
Orbit.FindClosestPoints_old(p, s, ref CD, ref CCD, ref FFp, ref FFs, ref SFp, ref SFs, epsilon, maxIterations, ref iterationCount); | ||
return 2; | ||
} | ||
|
||
public static bool CheckEncounterButDontBitchAboutIt(Orbit p, Orbit nextPatch, double startEpoch, OrbitDriver sec, CelestialBody targetBody, PatchedConics.SolverParameters pars) | ||
{ | ||
Orbit orbit = sec.orbit; | ||
double num = 1.1; | ||
if (GameSettings.ALWAYS_SHOW_TARGET_APPROACH_MARKERS && sec.celestialBody == targetBody) | ||
{ | ||
num = Math.Sqrt(orbit.semiMajorAxis / sec.celestialBody.sphereOfInfluence); | ||
} | ||
if (!Orbit.PeApIntersects(p, orbit, sec.celestialBody.sphereOfInfluence * num)) | ||
{ | ||
return false; | ||
} | ||
if (p.closestEncounterLevel < Orbit.EncounterSolutionLevel.ORBIT_INTERSECT) | ||
{ | ||
p.closestEncounterLevel = Orbit.EncounterSolutionLevel.ORBIT_INTERSECT; | ||
p.closestEncounterBody = sec.celestialBody; | ||
} | ||
double clEctr = p.ClEctr1; | ||
double clEctr2 = p.ClEctr2; | ||
double fEVp = p.FEVp; | ||
double fEVs = p.FEVs; | ||
double sEVp = p.SEVp; | ||
double sEVs = p.SEVs; | ||
int num2 = Orbit.FindClosestPoints(p, orbit, ref clEctr, ref clEctr2, ref fEVp, ref fEVs, ref sEVp, ref sEVs, 0.0001, pars.maxGeometrySolverIterations, ref pars.GeoSolverIterations); | ||
if (num2 < 1) | ||
{ | ||
return false; | ||
} | ||
double dTforTrueAnomaly = p.GetDTforTrueAnomaly(fEVp, 0.0); | ||
double dTforTrueAnomaly2 = p.GetDTforTrueAnomaly(sEVp, 0.0); | ||
double num3 = dTforTrueAnomaly + startEpoch; | ||
double num4 = dTforTrueAnomaly2 + startEpoch; | ||
|
||
// avoid bad numbers | ||
if (double.IsInfinity(num3) && !double.IsInfinity(num4)) | ||
num3 = num4; | ||
if (double.IsInfinity(num4) && !double.IsInfinity(num3)) | ||
num4 = num3; | ||
|
||
if (double.IsInfinity(num3) && double.IsInfinity(num4)) | ||
{ | ||
Debug.Log("CheckEncounter: both intercept UTs are infinite"); | ||
return false; | ||
} | ||
if ((num3 < p.StartUT || num3 > p.EndUT) && (num4 < p.StartUT || num4 > p.EndUT)) | ||
{ | ||
return false; | ||
} | ||
if (num4 < num3 || num3 < p.StartUT || num3 > p.EndUT) | ||
{ | ||
UtilMath.SwapValues(ref fEVp, ref sEVp); | ||
UtilMath.SwapValues(ref fEVs, ref sEVs); | ||
UtilMath.SwapValues(ref clEctr, ref clEctr2); | ||
UtilMath.SwapValues(ref dTforTrueAnomaly, ref dTforTrueAnomaly2); | ||
UtilMath.SwapValues(ref num3, ref num4); | ||
} | ||
if (num4 < p.StartUT || num4 > p.EndUT || double.IsInfinity(num4)) | ||
{ | ||
num2 = 1; | ||
} | ||
p.numClosePoints = num2; | ||
p.FEVp = fEVp; | ||
p.FEVs = fEVs; | ||
p.SEVp = sEVp; | ||
p.SEVs = sEVs; | ||
p.ClEctr1 = clEctr; | ||
p.ClEctr2 = clEctr2; | ||
if (Math.Min(p.ClEctr1, p.ClEctr2) > sec.celestialBody.sphereOfInfluence) | ||
{ | ||
if (GameSettings.ALWAYS_SHOW_TARGET_APPROACH_MARKERS && sec.celestialBody == targetBody) | ||
{ | ||
p.UTappr = startEpoch; | ||
p.ClAppr = PatchedConics.GetClosestApproach(p, orbit, startEpoch, p.nearestTT * 0.5, pars); | ||
p.closestTgtApprUT = p.UTappr; | ||
} | ||
return false; | ||
} | ||
if (p.closestEncounterLevel < Orbit.EncounterSolutionLevel.SOI_INTERSECT_1) | ||
{ | ||
p.closestEncounterLevel = Orbit.EncounterSolutionLevel.SOI_INTERSECT_1; | ||
p.closestEncounterBody = sec.celestialBody; | ||
} | ||
p.timeToTransition1 = dTforTrueAnomaly; | ||
p.secondaryPosAtTransition1 = orbit.getPositionAtUT(num3); | ||
Debug.DrawLine(ScaledSpace.LocalToScaledSpace(p.referenceBody.position), ScaledSpace.LocalToScaledSpace(p.secondaryPosAtTransition1), Color.yellow); | ||
p.timeToTransition2 = dTforTrueAnomaly2; | ||
p.secondaryPosAtTransition2 = orbit.getPositionAtUT(num4); | ||
Debug.DrawLine(ScaledSpace.LocalToScaledSpace(p.referenceBody.position), ScaledSpace.LocalToScaledSpace(p.secondaryPosAtTransition2), Color.red); | ||
p.nearestTT = p.timeToTransition1; | ||
p.nextTT = p.timeToTransition2; | ||
if (double.IsNaN(p.nearestTT)) | ||
{ | ||
Debug.Log(string.Concat(new object[] { "nearestTT is NaN! t1: ", p.timeToTransition1, ", t2: ", p.timeToTransition2, ", FEVp: ", p.FEVp, ", SEVp: ", p.SEVp })); | ||
} | ||
p.UTappr = startEpoch; | ||
p.ClAppr = PatchedConics.GetClosestApproach(p, orbit, startEpoch, p.nearestTT * 0.5, pars); | ||
if (PatchedConics.EncountersBody(p, orbit, nextPatch, sec, startEpoch, pars)) | ||
{ | ||
return true; | ||
} | ||
if (num2 > 1) | ||
{ | ||
p.closestEncounterLevel = Orbit.EncounterSolutionLevel.SOI_INTERSECT_2; | ||
p.closestEncounterBody = sec.celestialBody; | ||
Debug.DrawLine(ScaledSpace.LocalToScaledSpace(p.getPositionAtUT(p.UTappr)), ScaledSpace.LocalToScaledSpace(orbit.getPositionAtUT(p.UTappr)), XKCDColors.Orange * 0.5f); | ||
p.UTappr = startEpoch + p.nearestTT; | ||
p.ClAppr = PatchedConics.GetClosestApproach(p, orbit, startEpoch, (p.nextTT - p.nearestTT) * 0.5, pars); | ||
if (PatchedConics.EncountersBody(p, orbit, nextPatch, sec, startEpoch, pars)) | ||
{ | ||
return true; | ||
} | ||
Debug.DrawLine(ScaledSpace.LocalToScaledSpace(p.getPositionAtUT(p.UTappr)), ScaledSpace.LocalToScaledSpace(orbit.getPositionAtUT(p.UTappr)), XKCDColors.Orange); | ||
} | ||
if (sec.celestialBody == targetBody) | ||
{ | ||
p.closestTgtApprUT = p.UTappr; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using UnityEngine; | ||
|
||
|
||
namespace SigmaBinaryPlugin | ||
{ | ||
[KSPAddon(KSPAddon.Startup.Instantly, true)] | ||
class Version : MonoBehaviour | ||
{ | ||
void Awake() | ||
{ | ||
Debug.Log("[SigmaLog] Version Check: Sigma Binary v1.6.5"); | ||
} | ||
} | ||
} |