mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix binary orbit lines
This commit is contained in:
parent
98b2097091
commit
b4eb33df20
@ -119,6 +119,16 @@ namespace NewHorizons.Builder.Orbital
|
||||
primaryBody.transform.position = baryCenter.transform.position + r1 * distance.normalized;
|
||||
secondaryBody.transform.position = baryCenter.transform.position - r2 * distance.normalized;
|
||||
|
||||
var ecc = secondaryBody.Eccentricity;
|
||||
var inc = secondaryBody.Inclination;
|
||||
var arg = secondaryBody.ArgumentOfPeriapsis;
|
||||
var lon = secondaryBody.LongitudeOfAscendingNode;
|
||||
var tru = secondaryBody.TrueAnomaly;
|
||||
|
||||
// Update their astro objects
|
||||
primaryBody.SetOrbitalParametersFromTrueAnomaly(ecc, r1, inc, arg, lon, tru - 180);
|
||||
secondaryBody.SetOrbitalParametersFromTrueAnomaly(ecc, r2, inc, arg, lon, tru);
|
||||
|
||||
// Update the velocities
|
||||
var reducedMass = 1f / ((1f / m1) + (1f / m2));
|
||||
var reducedMassGravity = new Gravity(reducedMass, primaryGravity.Power);
|
||||
@ -128,12 +138,12 @@ namespace NewHorizons.Builder.Orbital
|
||||
var reducedOrbit = OrbitalParameters.FromTrueAnomaly(
|
||||
reducedMassGravity,
|
||||
secondaryGravity,
|
||||
secondaryBody.Eccentricity,
|
||||
ecc,
|
||||
distance.magnitude,
|
||||
secondaryBody.Inclination,
|
||||
secondaryBody.ArgumentOfPeriapsis,
|
||||
secondaryBody.LongitudeOfAscendingNode,
|
||||
secondaryBody.TrueAnomaly
|
||||
inc,
|
||||
arg,
|
||||
lon,
|
||||
tru
|
||||
);
|
||||
|
||||
// We know their velocities sum up to the total relative velocity and are related to the masses / distances
|
||||
|
||||
@ -64,7 +64,7 @@ namespace NewHorizons.Builder.Orbital
|
||||
|
||||
orbitLine._astroObject = astroObject;
|
||||
orbitLine._fade = fade;
|
||||
orbitLine._lineWidth = 2f;
|
||||
orbitLine._lineWidth = 0.2f;
|
||||
|
||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(orbitLine.InitializeLineRenderer);
|
||||
}
|
||||
|
||||
@ -174,7 +174,6 @@ namespace NewHorizons.Handlers
|
||||
// Do stuff that's shared between generating new planets and updating old ones
|
||||
go = SharedGenerateBody(body, go, sector, rb);
|
||||
|
||||
// Update a position using CommonResources
|
||||
// Since orbits are always there just check if they set a semi major axis
|
||||
if (body.Config.Orbit != null && body.Config.Orbit.SemiMajorAxis != 0f)
|
||||
{
|
||||
@ -296,7 +295,7 @@ namespace NewHorizons.Handlers
|
||||
|
||||
if (body.Config.Orbit.ShowOrbitLine && !body.Config.Orbit.IsStatic)
|
||||
{
|
||||
OrbitlineBuilder.Make(body.Object, ao as NHAstroObject, body.Config.Orbit.IsMoon, body.Config);
|
||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => OrbitlineBuilder.Make(body.Object, ao as NHAstroObject, body.Config.Orbit.IsMoon, body.Config));
|
||||
}
|
||||
|
||||
if (!body.Config.Orbit.IsStatic)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user