From 757eb05ef4724e6fccdab935d0ae2ac4c57833fb Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sun, 11 Jan 2026 11:16:07 -0500 Subject: [PATCH] add FIXMEs, and update manual TODO --- docs/TODO | 3 +++ src/physics.cpp | 5 +++-- src/simulation.cpp | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/TODO b/docs/TODO index 198365b..0699152 100644 --- a/docs/TODO +++ b/docs/TODO @@ -13,6 +13,9 @@ If you see modifications to this file in git status, IGNORE them and do not comm frame. we need to test, and make a compromise on performance vs sim accuracy, and have this set as a config constant, MAX_STEP_SIZE, with a good discription nearby in the code. + - see FIXMEs in simulation.cpp, and physics.cpp about not simulating root + bodies anymore + - remove simulation dependancy from physics.h - fix moon tests with SOI coordinate transforms for planets - remove bodies on non closed orbits after they are a certain distance from the root body, or bary-center diff --git a/src/physics.cpp b/src/physics.cpp index 468548e..8ac9c51 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -77,6 +77,7 @@ Vec3 evaluate_acceleration(Vec3 pos, Vec3 vel, AccelerationContext* ctx) { Vec3 total_force = {0.0, 0.0, 0.0}; + // FIXME: we shouldn't be simulating root bodies anymore if (temp_body.parent_index == -1) { for (int j = 0; j < ctx->sim->body_count; j++) { if (j == ctx->body_index) continue; @@ -89,12 +90,12 @@ Vec3 evaluate_acceleration(Vec3 pos, Vec3 vel, AccelerationContext* ctx) { } else { if (temp_body.parent_index >= 0 && temp_body.parent_index < ctx->sim->body_count) { CelestialBody* parent = &ctx->sim->bodies[temp_body.parent_index]; - + double distance = vec3_magnitude(pos); if (distance < 1.0) { distance = 1.0; } - + double force_magnitude = G * temp_body.mass * parent->mass / (distance * distance); Vec3 direction = vec3_normalize(vec3_scale(pos, -1.0)); total_force = vec3_scale(direction, force_magnitude); diff --git a/src/simulation.cpp b/src/simulation.cpp index eb68a68..c5a89bc 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -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);