|
|
|
|
@ -79,6 +79,7 @@ void update_simulation(SimulationState* sim) {
|
|
|
|
|
for (int i = 0; i < sim->body_count; i++) { |
|
|
|
|
CelestialBody* body = &sim->bodies[i]; |
|
|
|
|
|
|
|
|
|
// FIXME: we shouldn't be simulating root bodies anymore
|
|
|
|
|
if (body->parent_index == -1) { |
|
|
|
|
AccelerationContext ctx; |
|
|
|
|
ctx.sim = sim; |
|
|
|
|
@ -219,6 +220,8 @@ void compute_global_coordinates(SimulationState* sim) {
|
|
|
|
|
if (body->parent_index == -1) { |
|
|
|
|
body->position = body->local_position; |
|
|
|
|
body->velocity = body->local_velocity; |
|
|
|
|
// FIXME: parent_index > body_count is an error in config file, we
|
|
|
|
|
// should either verify that in config_loader, or have an assert here
|
|
|
|
|
} else if (body->parent_index >= 0 && body->parent_index < sim->body_count) { |
|
|
|
|
CelestialBody* parent = &sim->bodies[body->parent_index]; |
|
|
|
|
body->position = vec3_add(body->local_position, parent->position); |
|
|
|
|
|