Skip to content

Commit

Permalink
SystemGen: orbital shell sets station inclination
Browse files Browse the repository at this point in the history
  • Loading branch information
sturnclaw committed Oct 15, 2023
1 parent 8e189bd commit 309eecc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/galaxy/StarSystemGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,20 +1668,29 @@ void PopulateStarSystemGenerator::PopulateAddStations(SystemBody *sbody, StarSys
// I like to think that we'd fill several "shells" of orbits at once rather than fill one and move out further
static const Uint32 MAX_ORBIT_SHELLS = 3;
fixed shells[MAX_ORBIT_SHELLS];
fixed shellIncl[MAX_ORBIT_SHELLS];

if (innerOrbit != orbMaxS) {
shells[0] = innerOrbit; // low
shells[1] = innerOrbit + ((orbMaxS - innerOrbit) * fixed(1, 2)); // med
shells[2] = orbMaxS; // high

shellIncl[0] = rand.NormFixed() * FIXED_PI;
shellIncl[1] = rand.NormFixed() * FIXED_PI;
shellIncl[2] = rand.NormFixed() * FIXED_PI;
} else {
shells[0] = shells[1] = shells[2] = innerOrbit;
shellIncl[0] = shellIncl[1] = shellIncl[2] = rand.NormFixed() * FIXED_PI;
}

Uint32 orbitIdx = 0;
double orbitSlt = 0.0;
const double orbitSeparation = (NumToMake > 1) ? ((M_PI * 2.0) / double(NumToMake - 1)) : M_PI;

for (Uint32 i = 0; i < NumToMake; i++) {
// Pick the orbit we've currently placing a station into.
const fixed currOrbit = shells[orbitIdx];
const fixed currOrbitIncl = shells[orbitIdx];
++orbitIdx;
if (orbitIdx >= MAX_ORBIT_SHELLS) // wrap it
{
Expand All @@ -1706,7 +1715,7 @@ void PopulateStarSystemGenerator::PopulateAddStations(SystemBody *sbody, StarSys
// slightly random min/max orbital distance
sp->m_eccentricity = rand.NormFixed().Abs() * fixed(1, 8);
// perturb the orbital plane to avoid all stations falling in line with each other
sp->m_inclination = rand.NormFixed() * fixed(1, 4) * FIXED_PI;
sp->m_inclination = currOrbitIncl + rand.NormFixed() * fixed(1, 4) * FIXED_PI;
// station spacing around the primary body
sp->m_argOfPeriapsis = rand.Fixed() * FIXED_PI * 2;
// TODO: no axial tilt for stations / axial tilt in general is strangely modeled
Expand Down

0 comments on commit 309eecc

Please sign in to comment.