From e374c0529a65b145952bfdd1763a25c78a47f092 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Thu, 8 Jan 2026 18:32:21 -0500 Subject: [PATCH] Remove unused add_body() and consolidate velocity initialization - Removed add_body() function (unused across codebase) - Renamed compute_initial_velocities() to calculate_initial_velocities() - Removed redundant wrapper function Removed 26 lines of dead code --- src/simulation.cpp | 32 +------------------------------- src/simulation.h | 4 ---- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index 63bbff1..8e2575e 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -25,32 +25,6 @@ void destroy_simulation(SimulationState* sim) { } } -// Add a celestial body to the simulation -void add_body(SimulationState* sim, const char* name, double mass, double radius, - Vec3 pos, Vec3 vel, int parent_index, float r, float g, float b, - double eccentricity, double semi_major_axis) { - if (sim->body_count >= sim->max_bodies) { - return; // No more space - } - - CelestialBody* body = &sim->bodies[sim->body_count]; - strncpy(body->name, name, 63); - body->name[63] = '\0'; - body->mass = mass; - body->radius = radius; - body->position = pos; - body->velocity = vel; - body->soi_radius = 0.0; // Will be calculated later - body->parent_index = parent_index; - body->color[0] = r; - body->color[1] = g; - body->color[2] = b; - body->eccentricity = eccentricity; - body->semi_major_axis = semi_major_axis; - - sim->body_count++; -} - // Find which body is gravitationally dominant for the given body int find_dominant_body(SimulationState* sim, int body_index) { if (body_index < 0 || body_index >= sim->body_count) { @@ -268,7 +242,7 @@ static void print_system_info_if_multiple_roots(int root_count, Vec3 barycenter) } } -void compute_initial_velocities(SimulationState* sim) { +void calculate_initial_velocities(SimulationState* sim) { int root_indices[32]; int root_count; Vec3 barycenter = compute_system_barycenter(sim, root_indices, &root_count); @@ -285,10 +259,6 @@ void compute_initial_velocities(SimulationState* sim) { set_child_bodies_velocity(sim); } -void calculate_initial_velocities(SimulationState* sim) { - compute_initial_velocities(sim); -} - // Calculate SOI radii for all bodies void calculate_soi_radii(SimulationState* sim) { for (int i = 0; i < sim->body_count; i++) { diff --git a/src/simulation.h b/src/simulation.h index 739680f..1ecee79 100644 --- a/src/simulation.h +++ b/src/simulation.h @@ -29,9 +29,6 @@ struct SimulationState { // Simulation management functions SimulationState* create_simulation(int max_bodies, double time_step); void destroy_simulation(SimulationState* sim); -void add_body(SimulationState* sim, const char* name, double mass, double radius, - Vec3 pos, Vec3 vel, int parent_index, float r, float g, float b, - double eccentricity, double semi_major_axis); // SOI and simulation update functions int find_dominant_body(SimulationState* sim, int body_index); @@ -39,7 +36,6 @@ void update_soi(CelestialBody* body, CelestialBody* parent, double semi_major_ax void update_simulation(SimulationState* sim); // Velocity initialization -void compute_initial_velocities(SimulationState* sim); void calculate_initial_velocities(SimulationState* sim); // SOI helpers