Browse Source

add FIXMEs, and update manual TODO

main
cinnaboot 6 months ago
parent
commit
757eb05ef4
  1. 3
      docs/TODO
  2. 5
      src/physics.cpp
  3. 3
      src/simulation.cpp

3
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

5
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);

3
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);

Loading…
Cancel
Save