|
|
|
|
@ -68,6 +68,7 @@ int add_spacecraft(SimulationState* sim, Spacecraft* craft) {
|
|
|
|
|
return new_idx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FIXME: dead code
|
|
|
|
|
// Add a body to the simulation at runtime
|
|
|
|
|
int add_body_to_simulation(SimulationState* sim, CelestialBody* body) { |
|
|
|
|
if (sim->body_count >= sim->max_bodies) { |
|
|
|
|
@ -146,6 +147,8 @@ int find_dominant_body(SimulationState* sim, int body_index) {
|
|
|
|
|
|
|
|
|
|
return new_parent; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FIXME: dead code: don't remove before updating calculate_soi_radius
|
|
|
|
|
// Update sphere of influence radius using Hill sphere approximation
|
|
|
|
|
// r_soi = a * (m/M)^(2/5) where a = semi-major axis, m = body mass, M = parent mass
|
|
|
|
|
void update_soi(CelestialBody* body, CelestialBody* parent, double semi_major_axis) { |
|
|
|
|
@ -168,6 +171,8 @@ void update_simulation(SimulationState* sim) {
|
|
|
|
|
sim->time += sim->dt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FIXME: fails to check for root body
|
|
|
|
|
// need set: body->soi_radius = 1e15; // 1000 AU in meters
|
|
|
|
|
// Calculate SOI radius for a single body
|
|
|
|
|
// r_soi = a * (m/M)^(2/5) where a = semi-major axis, m = body mass, M = parent mass
|
|
|
|
|
// Returns SOI radius in meters
|
|
|
|
|
|