@ -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
// Find which body is gravitationally dominant for the given body
int find_dominant_body ( SimulationState * sim , int body_index ) {
int find_dominant_body ( SimulationState * sim , int body_index ) {
if ( body_index < 0 | | body_index > = sim - > body_count ) {
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 compu te_initial_velocities ( SimulationState * sim ) {
void calcula te_initial_velocities ( SimulationState * sim ) {
int root_indices [ 32 ] ;
int root_indices [ 32 ] ;
int root_count ;
int root_count ;
Vec3 barycenter = compute_system_barycenter ( sim , root_indices , & 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 ) ;
set_child_bodies_velocity ( sim ) ;
}
}
void calculate_initial_velocities ( SimulationState * sim ) {
compute_initial_velocities ( sim ) ;
}
// Calculate SOI radii for all bodies
// Calculate SOI radii for all bodies
void calculate_soi_radii ( SimulationState * sim ) {
void calculate_soi_radii ( SimulationState * sim ) {
for ( int i = 0 ; i < sim - > body_count ; i + + ) {
for ( int i = 0 ; i < sim - > body_count ; i + + ) {